several improvement and armonisation in filefct.sh, module auth and patch_snmp improved
This commit is contained in:
@@ -20,30 +20,51 @@
|
||||
# * DEFAULT_SHELL: The shell to use when creating new users
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_authnz=0.1.6
|
||||
export VER_authnz=0.2.0
|
||||
export DEP_authnz="upgrade_dist"
|
||||
|
||||
# Users (from Ldap)
|
||||
add_remote_user()
|
||||
{
|
||||
echo "+$1::::::" >> /etc/passwd
|
||||
echo "+$1::::::::" >> /etc/shadow
|
||||
if [[ $(grep "^$1:" /etc/passwd) ]]; then
|
||||
prnt W "A local user with name $1 already exists, adding anyway!"
|
||||
fi
|
||||
if [[ $(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/passwd) ]]; then
|
||||
prnt W "The remote user $1 is already connectable, nothing to do in shadow."
|
||||
else
|
||||
echo "+$1::::::::" >> /etc/shadow
|
||||
prnt I "User $1 added to shadow..."
|
||||
fi
|
||||
}
|
||||
|
||||
# Remove users
|
||||
remove_user()
|
||||
{
|
||||
# Using sed is more universal than any distro commands
|
||||
sed -i -e "/^$1/d" /etc/passwd /etc/shadow /etc/group /etc/gshadow
|
||||
if [[ $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
|
||||
# Using sed is more universal than any distro commands
|
||||
sed -i -e "/^$1:/d" /etc/{passwd,shadow,group,gshadow}
|
||||
else
|
||||
prnt W "User $1 don't exists in auth files, nothing to do."
|
||||
fi
|
||||
}
|
||||
|
||||
# Create a local user
|
||||
create_user()
|
||||
create_local_user()
|
||||
{
|
||||
if [[ $(noerror --noout id $1) != 0 ]]; then
|
||||
prnt I "Creating user $1..."
|
||||
# The following should be replaced by a more universal version
|
||||
useradd --create-home --shell $DEFAULT_SHELL --user-group $1
|
||||
if [[ $(directory_exists home_skell) ]]; then
|
||||
useradd --create-home --shell $DEFAULT_SHELL --user-group $1 \
|
||||
--skell $(select_directory home_skell)
|
||||
else
|
||||
useradd --create-home --shell $DEFAULT_SHELL --user-group $1
|
||||
fi
|
||||
else
|
||||
prnt W "The user $1 already exists. Nothing to do..."
|
||||
fi
|
||||
@@ -52,8 +73,8 @@ create_user()
|
||||
# Authentication
|
||||
authnz()
|
||||
{
|
||||
backupdist /etc/passwd /etc/shadow /etc/group
|
||||
tagfile /etc/passwd /etc/shadow /etc/group
|
||||
backup_dist /etc/passwd /etc/shadow /etc/group
|
||||
tag_file /etc/passwd /etc/shadow /etc/group
|
||||
for usr in $REMOVE_USERS; do
|
||||
prnt I "Removing user $usr..."
|
||||
remove_user $usr
|
||||
@@ -62,14 +83,14 @@ authnz()
|
||||
if [[ $WITH_LDAP_KERB == yes ]]; then
|
||||
pkginst krb5-user libpam-krb5 libnss-ldap libpam-ldap nscd
|
||||
|
||||
backupdist /etc/krb5.conf /etc/libnss-ldap.conf /etc/pam_ldap.conf \
|
||||
backup_dist /etc/krb5.conf /etc/libnss-ldap.conf /etc/pam_ldap.conf \
|
||||
/etc/nsswitch.conf /etc/pam.d/common-session \
|
||||
/etc/pam.d/common-account /etc/pam.d/common-password \
|
||||
/etc/pam.d/common-auth
|
||||
installfile authnz/krb5.conf authnz/libnss-ldap.conf \
|
||||
install_file authnz/krb5.conf authnz/libnss-ldap.conf \
|
||||
authnz/pam_ldap.conf authnz/nsswitch.conf /etc
|
||||
|
||||
tagfile /etc/krb5.conf /etc/libnss-ldap.conf /etc/pam-ldap.conf
|
||||
tag_file /etc/krb5.conf /etc/libnss-ldap.conf /etc/pam-ldap.conf
|
||||
sed -i -e "s/@REALM@/${REALM^^}/g" -e "s/@DOMAIN@/$REALM/g" \
|
||||
-e "s/@KDC_SERVER@/$KDC_SERVER/" -e "s/@KADM_SERVER@/$KADM_SERVER/" \
|
||||
/etc/krb5.conf
|
||||
@@ -79,8 +100,8 @@ authnz()
|
||||
-e "s/@LDAP_ADM@/$LDAP_ADM/" /etc/pam-ldap.conf
|
||||
|
||||
|
||||
installfile authnz/common-{session,account,password,auth} /etc/pam.d
|
||||
tagfile /etc/pam.d/common-{session,account,password,auth}
|
||||
install_file authnz/common-{session,account,password,auth} /etc/pam.d
|
||||
tag_file /etc/pam.d/common-{session,account,password,auth}
|
||||
|
||||
scv_restart nscd
|
||||
|
||||
@@ -96,7 +117,7 @@ authnz()
|
||||
|
||||
for usr in $LOCAL_USERS; do
|
||||
prnt I "Creating user $usr..."
|
||||
create_user $usr
|
||||
create_local_user $usr
|
||||
done
|
||||
}
|
||||
|
||||
@@ -114,7 +135,7 @@ precheck_authnz()
|
||||
else
|
||||
prnt W "No distant user but LDAP/Kerberos is activated!"
|
||||
fi
|
||||
file_exists auth/{krb5,libnss-ldap,pam_ldap,nsswitch}.conf
|
||||
file_must_exists auth/{krb5,libnss-ldap,pam_ldap,nsswitch}.conf
|
||||
pam/common-{session,account,password,auth}
|
||||
else
|
||||
if [[ -n $REMOTE_USERS ]]; then
|
||||
|
||||
Reference in New Issue
Block a user