Add failed to (0|1) regex

master
Артемий 3 years ago
parent f62549af92
commit a023c9165a

@ -78,19 +78,19 @@ _mk_pwquality_conf() {
;; ;;
--gecoscheck) shift; --gecoscheck) shift;
_check_argument_is_number "$1" "--gecoscheck" || failed=1 _check_argument_is_number "$1" "--gecoscheck" || failed=1
[[ "$1" =~ (0|1) ]] || error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1" [[ "$1" =~ (0|1) ]] || { error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1"; failed=1; }
geoscheck="$1" geoscheck="$1"
shift shift
;; ;;
--dictcheck) shift; --dictcheck) shift;
_check_argument_is_number "$1" "--dictcheck" || failed=1 _check_argument_is_number "$1" "--dictcheck" || failed=1
[[ "$1" =~ (0|1) ]] || error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1" [[ "$1" =~ (0|1) ]] || { error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1"; failed=1; }
dickcheck="$1" dickcheck="$1"
shift shift
;; ;;
--usercheck) shift; --usercheck) shift;
_check_argument_is_number "$1" "--usercheck" || failed=1 _check_argument_is_number "$1" "--usercheck" || failed=1
[[ "$1" =~ (0|1) ]] || error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1" [[ "$1" =~ (0|1) ]] || { error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1"; failed=1; }
usercheck="$1" usercheck="$1"
shift shift
;; ;;
@ -101,7 +101,7 @@ _mk_pwquality_conf() {
;; ;;
--enforcing) shift; --enforcing) shift;
_check_argument_is_number "$1" "--enforcing" || failed=1 _check_argument_is_number "$1" "--enforcing" || failed=1
[[ "$1" =~ (0|1) ]] || error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1" [[ "$1" =~ (0|1) ]] || { error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1"; failed=1; }
enforcing="$1" enforcing="$1"
shift shift
;; ;;
@ -111,20 +111,19 @@ _mk_pwquality_conf() {
;; ;;
--enforce_for_root) shift; --enforce_for_root) shift;
_check_argument_is_number "$1" "--enforce_for_root" || failed=1 _check_argument_is_number "$1" "--enforce_for_root" || failed=1
[[ "$1" =~ (0|1) ]] || error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1" [[ "$1" =~ (0|1) ]] || { error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1"; failed=1; }
enforce_for_root="$1" enforce_for_root="$1"
shift shift
;; ;;
--local_users_only) shift; --local_users_only) shift;
_check_argument_is_number "$1" "--local_users_only" || failed=1 _check_argument_is_number "$1" "--local_users_only" || failed=1
[[ "$1" =~ (0|1) ]] || error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1" [[ "$1" =~ (0|1) ]] || { error $"The received parameters are not correct. Expected %s, received %s" $"0 or 1" "$1"; failed=1; }
local_users_only="$1" local_users_only="$1"
shift shift
;; ;;
esac esac
done done
if [ "$failed" != 0 ]; then if [ "$failed" != 0 ]; then
error $"Errors occured when trying to understand how to configure auditd"
return 1 return 1
fi fi
cat <<EOF cat <<EOF
@ -145,6 +144,6 @@ usersubstr = $usersubstr
enforcing = $enforcing enforcing = $enforcing
retry = $retry retry = $retry
EOF EOF
if [ "$enforce_for_root" = 1 ]; then echo "enforce_for_root"; fi if [ "$enforce_for_root" == 1 ]; then echo "enforce_for_root"; fi
if [ "$local_users_only" = 1 ]; then echo "local_users_only"; fi if [ "$local_users_only" == 1 ]; then echo "local_users_only"; fi
} }

@ -18,10 +18,7 @@ _exit(){
trap _exit EXIT ERR trap _exit EXIT ERR
_main(){ _main(){
if _mk_pwquality_conf --minclass STRING 1>/dev/null ; then _mk_pwquality_conf --minclass STRING 1>/dev/null && { echo failed test 1; failed="$((++failed))"; }
echo failed test 1
failed="$((++failed))"
fi
_mk_pwquality_conf --usercheck 1 1>/dev/null || { echo failed test 2 && failed="$((++failed))" ;} _mk_pwquality_conf --usercheck 1 1>/dev/null || { echo failed test 2 && failed="$((++failed))" ;}
! _mk_pwquality_conf --enforcing 1 --retry --usersubstr 1>/dev/null || { echo failed test 3 && failed="$((++failed))" ;} ! _mk_pwquality_conf --enforcing 1 --retry --usersubstr 1>/dev/null || { echo failed test 3 && failed="$((++failed))" ;}
} }

Loading…
Cancel
Save