From ca9b6bada0a9704a1e61336cd29cb3af7c39bc99 Mon Sep 17 00:00:00 2001 From: Bob Robey Date: Tue, 5 Nov 2024 11:53:06 -0600 Subject: [PATCH] Fixing uid scan in bash script --- extras/manage/bin/addAACUsers.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extras/manage/bin/addAACUsers.sh b/extras/manage/bin/addAACUsers.sh index 66cd442..794e559 100755 --- a/extras/manage/bin/addAACUsers.sh +++ b/extras/manage/bin/addAACUsers.sh @@ -40,7 +40,8 @@ fi # First see what user ids and group ids are used by files in # the Home directory tree and set the max to echo "Starting scan for last used uid and gid in our range (12050, 12000) respectively" -sudo find ${HOMEDIR_BASE} -maxdepth 2 -print0 | while read -r -d '' file; do +while read -r -d '' file +do uid=`sudo stat -c %u $file` if [[ ! -z "$uid" ]]; then if (( $uid > ${HACKATHONLASTUSER} )); then @@ -53,8 +54,12 @@ sudo find ${HOMEDIR_BASE} -maxdepth 2 -print0 | while read -r -d '' file; do HACKATHONLASTGROUP=$gid fi fi - #echo "User id is $uuid Group id is $gid for file $file" -done + #echo "User id is $uid Group id is $gid for file $file" +done < <(sudo find ${HOMEDIR_BASE} -maxdepth 2 -print0) +echo "" +echo "After home directory scan last User id is $HACKATHONLASTUSER Group id is $HACKATHONLASTGROUP" +echo "" + echo "Starting scan of /etc/group and /etc/passwd for used gids and uids" while IFS='' read -r line; do gid=`echo $line | cut -d':' -f 3`