From 15dc0cde754d03e96ee1cc43f88813cf845d41f9 Mon Sep 17 00:00:00 2001 From: Mikhail Novosyolov Date: Sun, 20 Jun 2021 10:05:51 +0300 Subject: [PATCH] avoid odd file --- back_pwquality.sh | 1 - common.sh | 9 +++++++++ front_pwquality.sh | 2 -- front_pwquality_cli.sh | 13 ++++++++++--- parse_pwquality.sh | 8 -------- 5 files changed, 19 insertions(+), 14 deletions(-) delete mode 100755 parse_pwquality.sh diff --git a/back_pwquality.sh b/back_pwquality.sh index af171be..87fd22c 100644 --- a/back_pwquality.sh +++ b/back_pwquality.sh @@ -8,7 +8,6 @@ then else source /usr/share/linux-infosec-setupper/common.sh fi -source "${SHARE_DIR_PWQUALITY}/parse_pwquality.sh" _mk_pwquality_conf() { local failed=0 diff --git a/common.sh b/common.sh index a884300..7776673 100644 --- a/common.sh +++ b/common.sh @@ -102,3 +102,12 @@ _validate_email(){ return 1 fi } + +_pw_parse_conf() { + while read -r line; do + case "$line" in + *=*) echo "${line// /}" ;; + *) echo "${line}=1" ;; + esac + done < "${DESTDIR}/etc/security/pwquality.conf" +} diff --git a/front_pwquality.sh b/front_pwquality.sh index f8eec87..edce42b 100644 --- a/front_pwquality.sh +++ b/front_pwquality.sh @@ -6,10 +6,8 @@ set -e if [ -f ./common.sh ] && [ -f "$0" ] then source common.sh - source parse_pwquality.sh else source /usr/share/linux-infosec-setupper/common.sh - source "${SHARE_DIR_PWQUALITY}/parse_pwquality.sh" fi PWQUALITY_FRONT=1 diff --git a/front_pwquality_cli.sh b/front_pwquality_cli.sh index 1840616..186eba0 100644 --- a/front_pwquality_cli.sh +++ b/front_pwquality_cli.sh @@ -2,6 +2,16 @@ source "${DESTDIR}/usr/share/linux-infosec-setupper/common.sh" +# detect running from git tree +if [ -f ./common.sh ] && [ -f "$0" ] +then + source common.sh + source back_pwquality.sh +else + source /usr/share/linux-infosec-setupper/common.sh + source "${SHARE_DIR_PWQUALITY}/back_pwquality.sh" +fi + # Check whether we are running the script for the first time # Since the config may be standard from the package, it may not be parsed correctly. # We write our default config instead of the original one, so that the parsing works correctly @@ -10,9 +20,6 @@ if ! [[ -f "${VAR_DIR_PWQUALITY}/pw_changed" ]]; then install -D -m 444 /dev/null "${VAR_DIR_PWQUALITY}/pw_changed" || { error $"Unable to write to file %s" "${VAR_DIR_PWQUALITY}/pw_changed"; exit 1; } fi -source "${SHARE_DIR_PWQUALITY}/parse_pwquality.sh" -source "${SHARE_DIR_PWQUALITY}/back_pwquality.sh" - while read -r line; do declare "$line" || { error $"Unable to parse /etc/security/pwquality.conf correctly; execute \n%s" "rm ${VAR_DIR_PWQUALITY}/pw_changed"; exit 1; }; done < <(_pw_parse_conf) PWQUALITY_FRONT=1 diff --git a/parse_pwquality.sh b/parse_pwquality.sh deleted file mode 100755 index d03a3f6..0000000 --- a/parse_pwquality.sh +++ /dev/null @@ -1,8 +0,0 @@ -_pw_parse_conf() { -while read -r line; do - case "$line" in - *=*) echo "${line// /}" ;; - *) echo "${line}=1" ;; - esac -done < "${DESTDIR}/etc/security/pwquality.conf" -}