added file dependency check, switched back to english, smaller fix and improvements
This commit is contained in:
@@ -11,35 +11,47 @@
|
||||
# * WITH_LDAP_KERB: Shall we install requirements for LDAP/Kerberos auth ?
|
||||
# * REMOTE_USERS: List of remote users to add
|
||||
# * LOCAL_USERS: List of local users to create
|
||||
# * REMOVE_USERS: List of username to remove
|
||||
# * DEFAULT_SHELL: The shell to use when creating new users
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_authnz=0.1.3
|
||||
export VER_authnz=0.1.4
|
||||
export DEP_authnz="upgrade_dist"
|
||||
|
||||
# Users (from Ldap)
|
||||
add_remote_user()
|
||||
{
|
||||
backupdist /etc/passwd /etc/shadow /etc/group
|
||||
#sed -i -e '/^fatal/d' /etc/passwd /etc/shadow /etc/group
|
||||
echo "+$1::::::" >> /etc/passwd
|
||||
echo "+$1::::::::" >> /etc/shadow
|
||||
}
|
||||
|
||||
# Remove users
|
||||
remove_user()
|
||||
{
|
||||
# Using sed is more universal than any distro commands
|
||||
sed -i -e "/^$1/d" /etc/passwd /etc/shadow /etc/group
|
||||
}
|
||||
|
||||
# Create a local user
|
||||
create_user()
|
||||
{
|
||||
if [[ $(noerror --noout id $1) != 0 ]]; then
|
||||
prnt I "Création de l'utilisateur $1 ..."
|
||||
prnt I "Creating user $1..."
|
||||
useradd --create-home --shell $DEFAULT_SHELL --user-group $1
|
||||
else
|
||||
prnt W "L'utilisateur $1 existe déjà. Rien à faire..."
|
||||
prnt W "The user $1 already exists. Nothing to do..."
|
||||
fi
|
||||
}
|
||||
|
||||
# Authentication
|
||||
authnz()
|
||||
{
|
||||
backupdist /etc/passwd /etc/shadow /etc/group
|
||||
for usr in $REMOVE_USERS; do
|
||||
prnt I "Removing user $usr..."
|
||||
remove_user $usr
|
||||
done
|
||||
|
||||
if [[ $WITH_LDAP_KERB == yes ]]; then
|
||||
pkginst krb5-user libpam-krb5 libnss-ldap libpam-ldap nscd
|
||||
|
||||
@@ -54,6 +66,7 @@ authnz()
|
||||
scv_restart nscd
|
||||
|
||||
for usr in $REMOTE_USERS; do
|
||||
prnt I "Adding remote user $usr..."
|
||||
add_remote_user $usr
|
||||
done
|
||||
fi
|
||||
@@ -63,7 +76,7 @@ authnz()
|
||||
fi
|
||||
|
||||
for usr in $LOCAL_USERS; do
|
||||
prnt I "Création de l'utilisateur $usr..."
|
||||
prnt I "Creating user $usr..."
|
||||
create_user $usr
|
||||
done
|
||||
}
|
||||
@@ -72,21 +85,27 @@ precheck_authnz()
|
||||
{
|
||||
if [[ $WITH_LDAP_KERB == "yes" ]]; then
|
||||
if [[ -n $REMOTE_USERS ]]; then
|
||||
prnt I "Les utilisateurs distants suivants seront accessible :"
|
||||
prnt I "The following distant users will be accessible:"
|
||||
prnt m "\t* $REMOTE_USERS"
|
||||
else
|
||||
prnt W "Pas d'utilisateur distant bien que LDAP/Kerberos soit activé !"
|
||||
prnt W "No distant user but LDAP/Kerberos is activated!"
|
||||
fi
|
||||
file_exists auth/{krb5,libnss-ldap,pam_ldap,nsswitch}.conf
|
||||
pam/common-{session,account,password,auth}
|
||||
else
|
||||
if [[ -n $REMOTE_USERS ]]; then
|
||||
prnt E "Impossible d'ajouter des utilisateurs distants sans les méchanismes d'authentication."
|
||||
prnt E "Impossible to add distant users authentication mechanism."
|
||||
die 109
|
||||
fi
|
||||
fi
|
||||
if [[ -n $LOCAL_USERS ]]; then
|
||||
prnt I "Les utilisateurs locaux suivants seront créés :"
|
||||
prnt I "The following local users will be created:"
|
||||
prnt m "\t* $LOCAL_USERS"
|
||||
fi
|
||||
if [[ -n $REMOvE_USERS ]]; then
|
||||
prnt I "The following users will be removed:"
|
||||
prnt m "\t* $REMOVE_USERS"
|
||||
fi
|
||||
}
|
||||
|
||||
export -f authnz
|
||||
|
||||
Reference in New Issue
Block a user