Fix the unlock linux host script to support users without password (#19665)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
* Fixed the Linux unlock script to support passwordless users.
|
||||
@@ -6,6 +6,16 @@ do
|
||||
echo "$user"
|
||||
if [ "$user" != "root" ]; then
|
||||
echo "Unlocking password for $user"
|
||||
passwd -u $user
|
||||
STDERR=$(passwd -u "$user" 2>&1 >/dev/null)
|
||||
if [ $? -eq 3 ]; then
|
||||
# possibly due to the user not having a password
|
||||
# use this convoluted case approach to avoid bashisms (POSIX portable)
|
||||
case "$STDERR" in
|
||||
*"unlocking the password would result in a passwordless account"* )
|
||||
# unlock and delete password to set it back to empty
|
||||
passwd -ud "$user"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -6,6 +6,16 @@ do
|
||||
echo "$user"
|
||||
if [ "$user" != "root" ]; then
|
||||
echo "Unlocking password for $user"
|
||||
passwd -u $user
|
||||
STDERR=$(passwd -u "$user" 2>&1 >/dev/null)
|
||||
if [ $? -eq 3 ]; then
|
||||
# possibly due to the user not having a password
|
||||
# use this convoluted case approach to avoid bashisms (POSIX portable)
|
||||
case "$STDERR" in
|
||||
*"unlocking the password would result in a passwordless account"* )
|
||||
# unlock and delete password to set it back to empty
|
||||
passwd -ud "$user"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user