improved code quality, few bug fixes
This commit is contained in:
@@ -20,22 +20,22 @@
|
||||
# * DEFAULT_SHELL: The shell to use when creating new users
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_authnz=0.2.2
|
||||
export VER_authnz="0.2.2"
|
||||
export DEP_authnz="upgrade_dist"
|
||||
|
||||
# Users (from Ldap)
|
||||
add_remote_user()
|
||||
{
|
||||
if [[ $(grep "^$1:" /etc/passwd) ]]; then
|
||||
if [[ -n $(grep "^$1:" /etc/passwd) ]]; then
|
||||
prnt W "A local user with name $1 already exists, adding anyway!"
|
||||
fi
|
||||
if [[ $(grep "^+$1:" /etc/passwd) ]]; then
|
||||
if [[ -n $(grep "^+$1:" /etc/passwd) ]]; then
|
||||
prnt W "The remote user $1 is already declared, nothing to do in passwd."
|
||||
else
|
||||
echo "+$1::::::" >> /etc/passwd
|
||||
prnt I "User $1 added to passwd..."
|
||||
fi
|
||||
if [[ $(grep "^+$1:" /etc/shadow) ]]; then
|
||||
if [[ -n $(grep "^+$1:" /etc/shadow) ]]; then
|
||||
prnt W "The remote user $1 is already connectable, nothing to do in shadow."
|
||||
else
|
||||
echo "+$1::::::::" >> /etc/shadow
|
||||
@@ -46,10 +46,10 @@ add_remote_user()
|
||||
# Remove users
|
||||
remove_user()
|
||||
{
|
||||
if [[ $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
if [[ -n $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
# Using sed is more universal than any distro commands - local case
|
||||
sed -i -e "/^$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||
elif [[ $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
elif [[ -n $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
# remote case
|
||||
sed -i -e "/^+$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user