Skip to content

Commit

Permalink
ncp-config: dont save passwords
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Knöppler <[email protected]>
Signed-off-by: nachoparker <[email protected]>
  • Loading branch information
theCalcaholic authored and nachoparker committed Jan 22, 2020
1 parent 3af0c46 commit 4a99207
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 0 additions & 2 deletions bin/ncp/CONFIG/nc-passwd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# More at: https://ownyourbits.com
#



configure()
{
# update password
Expand Down
15 changes: 15 additions & 0 deletions etc/library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ function run_app_unsafe()

echo "" >> $log

clear_password_fields "$cfg_file"
return "$ret"
}

Expand Down Expand Up @@ -278,6 +279,20 @@ function check_distro()
return 1
}

function clear_password_fields()
{
local cfg_file="$1"
local cfg="$(cat "$cfg_file")"
local len="$(jq '.params | length' <<<"$cfg")"
for (( i = 0 ; i < len ; i++ )); do
local type="$(jq -r ".params[$i].type" <<<"$cfg")"

This comment has been minimized.

Copy link
@theCalcaholic

theCalcaholic Jan 22, 2020

Author Collaborator

Out of interest: Why didn't you go with my approach (using jq for field filtering) and instead implemented it yourself?

This comment has been minimized.

Copy link
@nachoparker

nachoparker Jan 22, 2020

Member

because it doesn't work :)

it only returns the params array element and only if it is of type "password", therefore removing all other types.

This comment has been minimized.

Copy link
@theCalcaholic

theCalcaholic Jan 30, 2020

Author Collaborator

Ah okay :D
I suppose I should have tested it with a more complex cfg file ^^

local val="$( jq -r ".params[$i].value" <<<"$cfg")"
[[ "$type" == "password" ]] && val=""
cfg="$(jq -r ".params[$i].value=\"$val\"" <<<"$cfg")"
done
echo "$cfg" > "$cfg_file"
}

function apt_install()
{
apt-get update
Expand Down

0 comments on commit 4a99207

Please sign in to comment.