Skip to content

Commit 4a99207

Browse files
theCalcaholicnachoparker
authored andcommitted
ncp-config: dont save passwords
Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent 3af0c46 commit 4a99207

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

bin/ncp/CONFIG/nc-passwd.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
# More at: https://ownyourbits.com
99
#
1010

11-
12-
1311
configure()
1412
{
1513
# update password

etc/library.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ function run_app_unsafe()
150150

151151
echo "" >> $log
152152

153+
clear_password_fields "$cfg_file"
153154
return "$ret"
154155
}
155156

@@ -278,6 +279,20 @@ function check_distro()
278279
return 1
279280
}
280281

282+
function clear_password_fields()
283+
{
284+
local cfg_file="$1"
285+
local cfg="$(cat "$cfg_file")"
286+
local len="$(jq '.params | length' <<<"$cfg")"
287+
for (( i = 0 ; i < len ; i++ )); do
288+
local type="$(jq -r ".params[$i].type" <<<"$cfg")"
289+
local val="$( jq -r ".params[$i].value" <<<"$cfg")"
290+
[[ "$type" == "password" ]] && val=""
291+
cfg="$(jq -r ".params[$i].value=\"$val\"" <<<"$cfg")"
292+
done
293+
echo "$cfg" > "$cfg_file"
294+
}
295+
281296
function apt_install()
282297
{
283298
apt-get update

0 commit comments

Comments
 (0)