diff --git a/modules/authnz.sh b/modules/authnz.sh index 01405b5..e131e33 100644 --- a/modules/authnz.sh +++ b/modules/authnz.sh @@ -1,7 +1,7 @@ # ------------------------------------------------------------------------------ # Add local or remote users # This file is part of the init.sh project -# Copyright (c) 2019-2022 Geoffray Levasseur +# Copyright (c) 2019-2025 Geoffray Levasseur # ------------------------------------------------------------------------------ # This file is distributed under 3-clause BSD license. # The complete license agreement can be obtained at: @@ -23,55 +23,6 @@ export VER_authnz="0.2.2" export DEP_authnz="" -# Users (from Ldap) -add_remote_user() -{ - if [[ -n $(grep "^$1:" /etc/passwd) ]]; then - prnt W "A local user with name $1 already exists, adding anyway!" - fi - 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 [[ -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 - prnt I "User $1 added to shadow..." - fi -} - -# Remove users -remove_user() -{ - 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 [[ -n $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then - # remote case - 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_local_user() -{ - if [[ $(noerror --noout id $1) != 0 ]]; then - prnt I "Creating user $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 -} # Authentication authnz()