mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
users: Handle errors better during POSIX user operations
- If during an action, user does not exist ignore. - If during an action, return a non-zero exist status. - Catch an errors during actions as exceptions. - Display a message that corresponding POSIX operation failed.
This commit is contained in:
1 parent
d27cd02193
commit
a3de3ae277
9 files changed
+114
-35
No files matched your search
@@ -20,7 +20,14 @@
|
||||
|
||||
username="$1"
|
||||
|
||||
getent passwd "$username"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed: user not found"
|
||||
exit
|
||||
fi
|
||||
|
||||
usermod --expiredate "" "$username"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed"
|
||||
exit 2
|
||||
fi
|
||||
Reference in new issue
Block a user