From 469b9c9b89710aca1823c76fddc1fb01353ee8dc Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Mon, 15 Apr 2024 10:49:10 -0700 Subject: [PATCH] only return password when given -v option --- bin/vhost-user-get.sh | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/bin/vhost-user-get.sh b/bin/vhost-user-get.sh index 6b3cc2e..99aab14 100755 --- a/bin/vhost-user-get.sh +++ b/bin/vhost-user-get.sh @@ -17,6 +17,7 @@ help() echo "" echo " -h Print this help." echo " -u Only return info about specified username, otherwise all usernames are returned." + echo " -v Verbose - include unencrypted passwords, if available." echo " -c CVS - Output in cvs format, instead of tabbed table." } @@ -38,19 +39,25 @@ else usernames=(`ls /home/`) fi -output="uid username passwd jailed fpmmax" +if [[ -n $verbose ]]; then + output="uid username passwd jailed fpmmax" +else + output="uid username jailed fpmmax" +fi for username in "${usernames[@]}" do userid=(`stat -c '%u' /home/$username`) - if [[ -f /home/$username/.passwd ]]; then - password=(`awk -F : '{ print $2 }' /home/$username/.passwd`) - if [[ -f /root/.vhost.ini ]]; then - vhost::set-opensslpass - password=`echo "$password" | openssl aes-256-cbc -d -a -pass pass:$opensslpass -pbkdf2` + if [[ -n $verbose ]]; then + if [[ -f /home/$username/.passwd ]]; then + password=(`awk -F : '{ print $2 }' /home/$username/.passwd`) + if [[ -f /root/.vhost.ini ]]; then + vhost::set-opensslpass + password=`echo "$password" | openssl aes-256-cbc -d -a -pass pass:$opensslpass -pbkdf2` + fi + else + password="(unknown)" fi - else - password="(unknown)" fi shell=(`grep $username /etc/passwd|awk -F : '{ print $6 }'`) if [[ $shell = "/usr/jails/$username/./home/$username" ]]; then @@ -58,12 +65,17 @@ do else jailed="No" fi - if [[ -f /etc/php/$phpVersion/fpm/pool.d/$username.conf ]]; then - fpmmax=(`grep pm.max_children /etc/php/$phpVersion/fpm/pool.d/$username.conf |awk -F = '{ gsub(/ /,""); print $2 }'`); - else - fpmmax=0 + + fpmmax=0 + if [[ -f "/etc/php/$phpVersion/fpm/pool.d/$username.conf" ]]; then + fpmax=$(grep pm.max_children /etc/php/$phpVersion/fpm/pool.d/$username.conf | awk -F '=' '{ print $2 }' | tr -d ' ') + fi + + if [[ -n $verbose ]]; then + output="$output${NL}$userid $username $password $jailed $fpmmax" + else + output="$output${NL}$userid $username $jailed $fpmmax" fi - output="$output${NL}$userid $username $password $jailed $fpmmax" done if [[ $cvs ]]; then @@ -71,4 +83,3 @@ if [[ $cvs ]]; then else echo "$output" | column -t fi -