Repository: ranger Updated Branches: refs/heads/master d9f54d72c -> 8d39dfe99
RANGER-1835:The installer of the security admin should not repeatedly add a user to the same group. Signed-off-by: peng.jianhua <peng.jian...@zte.com.cn> Project: http://git-wip-us.apache.org/repos/asf/ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/8d39dfe9 Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/8d39dfe9 Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/8d39dfe9 Branch: refs/heads/master Commit: 8d39dfe99051968055f0f46a9275f59a276fc84a Parents: d9f54d7 Author: peng.jianhua <peng.jian...@zte.com.cn> Authored: Fri Oct 13 11:15:49 2017 +0800 Committer: peng.jianhua <peng.jian...@zte.com.cn> Committed: Mon Oct 16 14:54:18 2017 +0800 ---------------------------------------------------------------------- security-admin/scripts/setup.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ranger/blob/8d39dfe9/security-admin/scripts/setup.sh ---------------------------------------------------------------------- diff --git a/security-admin/scripts/setup.sh b/security-admin/scripts/setup.sh index 1630684..e2a69b7 100755 --- a/security-admin/scripts/setup.sh +++ b/security-admin/scripts/setup.sh @@ -1164,7 +1164,7 @@ do_authentication_setup(){ } #===================================================================== setup_unix_user_group(){ - log "[I] Setting up UNIX user : ${unix_user} and group: ${unix_group}"; + log "[I] Setting up UNIX user : ${unix_user} and group: ${unix_group}" #create group if it does not exist egrep "^$unix_group" /etc/group >& /dev/null @@ -1179,7 +1179,7 @@ setup_unix_user_group(){ if [ $? -ne 0 ] then check_user_pwd ${unix_user_pwd} - log "[I] Creating new user and adding to group"; + log "[I] Creating new user and adding to group" useradd ${unix_user} -g ${unix_group} -m check_ret_status $? "useradd ${unix_user} failed" @@ -1193,10 +1193,17 @@ EOF chpasswd < ${passwdtmpfile} rm -rf ${passwdtmpfile} else - log "[I] User already exists, adding it to group"; - usermod -g ${unix_group} ${unix_user} + useringroup=`id ${unix_user}` + useringrouparr=(${useringroup// / }) + if [[ ${useringrouparr[1]} =~ "(${unix_group})" ]] + then + log "[I] the ${unix_user} user already exists and belongs to group ${unix_group}" + else + log "[I] User already exists, adding it to group ${unix_group}" + usermod -g ${unix_group} ${unix_user} + fi fi - log "[I] Setting up UNIX user : ${unix_user} and group: ${unix_group} DONE"; + log "[I] Setting up UNIX user : ${unix_user} and group: ${unix_group} DONE" } setup_install_files(){