Repository: ranger
Updated Branches:
  refs/heads/master 37c95f703 -> 18abc714b


RANGER-1467:The password is not set after the user is created by install 
program during installing Ranger Policy Admin. We should set password like db 
user.

Signed-off-by: zhangqiang2 <zhangqia...@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/18abc714
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/18abc714
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/18abc714

Branch: refs/heads/master
Commit: 18abc714ba48dde9f11d930a94a1ce59c292d77f
Parents: 37c95f7
Author: peng.jianhua <peng.jian...@zte.com.cn>
Authored: Sun Mar 26 04:55:15 2017 -0400
Committer: zhangqiang2 <zhangqia...@zte.com.cn>
Committed: Sun Mar 26 04:59:43 2017 -0400

----------------------------------------------------------------------
 security-admin/scripts/install.properties |  1 +
 security-admin/scripts/setup.sh           | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/18abc714/security-admin/scripts/install.properties
----------------------------------------------------------------------
diff --git a/security-admin/scripts/install.properties 
b/security-admin/scripts/install.properties
index f323c95..06a1b89 100644
--- a/security-admin/scripts/install.properties
+++ b/security-admin/scripts/install.properties
@@ -106,6 +106,7 @@ policymgr_supportedcomponents=
 # ------- UNIX User CONFIG ----------------
 #
 unix_user=ranger
+unix_user_pwd=ranger
 unix_group=ranger
 
 #

http://git-wip-us.apache.org/repos/asf/ranger/blob/18abc714/security-admin/scripts/setup.sh
----------------------------------------------------------------------
diff --git a/security-admin/scripts/setup.sh b/security-admin/scripts/setup.sh
index 2e7752d..e77b2a9 100755
--- a/security-admin/scripts/setup.sh
+++ b/security-admin/scripts/setup.sh
@@ -81,6 +81,7 @@ policymgr_https_keystore_keyalias=$(get_prop 
'policymgr_https_keystore_keyalias'
 policymgr_https_keystore_password=$(get_prop 
'policymgr_https_keystore_password' $PROPFILE)
 policymgr_supportedcomponents=$(get_prop 'policymgr_supportedcomponents' 
$PROPFILE)
 unix_user=$(get_prop 'unix_user' $PROPFILE)
+unix_user_pwd=$(get_prop 'unix_user_pwd' $PROPFILE)
 unix_group=$(get_prop 'unix_group' $PROPFILE)
 authentication_method=$(get_prop 'authentication_method' $PROPFILE)
 remoteLoginEnabled=$(get_prop 'remoteLoginEnabled' $PROPFILE)
@@ -159,6 +160,13 @@ check_ret_status_for_groupadd(){
     fi
 }
 
+check_user_pwd(){
+    if [ -z "$1" ]; then
+        log "[E] The unix user password is empty. Please set user password.";
+        exit 1;
+    fi
+}
+
 is_command () {
     log "[I] check if command $1 exists"
     type "$1" >/dev/null
@@ -1254,12 +1262,24 @@ setup_unix_user_group(){
                check_ret_status_for_groupadd $? "Creating group ${unix_group} 
failed"
        fi
 
+       #create user if it does not exists
        id -u ${unix_user} > /dev/null 2>&1
        if [ $? -ne 0 ]
        then
+               check_user_pwd ${unix_user_pwd}
            log "[I] Creating new user and adding to group";
         useradd ${unix_user} -g ${unix_group} -m
                check_ret_status $? "useradd ${unix_user} failed"
+
+               passwdtmpfile=passwd.tmp
+               if [  -f "$passwdtmpfile" ]; then
+                       rm -rf  ${passwdtmpfile}
+               fi
+               cat> ${passwdtmpfile} << EOF
+${unix_user}:${unix_user_pwd}
+EOF
+               chpasswd <  ${passwdtmpfile}
+               rm -rf  ${passwdtmpfile}
        else
            log "[I] User already exists, adding it to group";
            usermod -g ${unix_group} ${unix_user}

Reply via email to