You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by zh...@apache.org on 2017/04/18 02:11:15 UTC
ranger git commit: RANGER-1515:Run updatepolicymgrpassword.sh and
updatepolicymgrpassword.py to update policy mgr password failed.
Repository: ranger
Updated Branches:
refs/heads/master 88c73dfe6 -> 50fb124e5
RANGER-1515:Run updatepolicymgrpassword.sh and updatepolicymgrpassword.py to update policy mgr password failed.
Signed-off-by: zhangqiang2 <zh...@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/50fb124e
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/50fb124e
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/50fb124e
Branch: refs/heads/master
Commit: 50fb124e52235fd076b6bf6a68940ac9f5cb0ed5
Parents: 88c73df
Author: peng.jianhua <pe...@zte.com.cn>
Authored: Fri Apr 14 08:35:10 2017 -0400
Committer: zhangqiang2 <zh...@zte.com.cn>
Committed: Mon Apr 17 22:10:24 2017 -0400
----------------------------------------------------------------------
.../scripts/updatepolicymgrpassword.py | 27 ++++++++++++++++++--
.../scripts/updatepolicymgrpassword.sh | 23 +++++++++++++++--
2 files changed, 46 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ranger/blob/50fb124e/unixauthservice/scripts/updatepolicymgrpassword.py
----------------------------------------------------------------------
diff --git a/unixauthservice/scripts/updatepolicymgrpassword.py b/unixauthservice/scripts/updatepolicymgrpassword.py
index 92c4805..574ce3b 100644
--- a/unixauthservice/scripts/updatepolicymgrpassword.py
+++ b/unixauthservice/scripts/updatepolicymgrpassword.py
@@ -30,10 +30,15 @@ from subprocess import Popen,PIPE
from datetime import date
from datetime import datetime
globalDict = {}
+installglobalDict={}
os_name = platform.system()
os_name = os_name.upper()
+RANGER_USERSYNC_HOME = os.getenv("RANGER_USERSYNC_HOME")
+if RANGER_USERSYNC_HOME is None:
+ RANGER_USERSYNC_HOME = os.getcwd()
+
def check_output(query):
if os_name == "LINUX":
p = subprocess.Popen(shlex.split(query), stdout=subprocess.PIPE)
@@ -69,9 +74,27 @@ def import_properties_from_xml(xml_path, properties_from_xml=None):
print('XML file not found at path : ' + str(xml_path))
return properties_from_xml
+def populate_global_install_dict():
+ global installglobalDict
+ read_config_file = open(os.path.join(RANGER_USERSYNC_HOME,'install.properties'))
+ for each_line in read_config_file.read().split('\n') :
+ each_line = each_line.strip()
+ if len(each_line) == 0:
+ continue
+ elif each_line[0] == "#":
+ continue
+ if re.search('=', each_line):
+ key , value = each_line.split("=",1)
+ key = key.strip()
+ if 'PASSWORD' in key:
+ jceks_file_path = os.path.join(RANGER_USERSYNC_HOME, 'jceks','ranger_db.jceks')
+ value = ''
+ value = value.strip()
+ installglobalDict[key] = value
def main():
global globalDict
+ populate_global_install_dict()
FORMAT = '%(asctime)-15s %(message)s'
logging.basicConfig(format=FORMAT, level=logging.DEBUG)
@@ -102,8 +125,8 @@ def main():
SYNC_POLICY_MGR_ALIAS="ranger.usersync.policymgr.password"
SYNC_POLICY_MGR_PASSWORD = ''
SYNC_POLICY_MGR_USERNAME = ''
- unix_user = "ranger"
- unix_group = "ranger"
+ unix_user = installglobalDict['unix_user']
+ unix_group = installglobalDict['unix_group']
while SYNC_POLICY_MGR_USERNAME == "":
print "Enter policymgr user name:"
http://git-wip-us.apache.org/repos/asf/ranger/blob/50fb124e/unixauthservice/scripts/updatepolicymgrpassword.sh
----------------------------------------------------------------------
diff --git a/unixauthservice/scripts/updatepolicymgrpassword.sh b/unixauthservice/scripts/updatepolicymgrpassword.sh
index a13c030..82be913 100644
--- a/unixauthservice/scripts/updatepolicymgrpassword.sh
+++ b/unixauthservice/scripts/updatepolicymgrpassword.sh
@@ -18,8 +18,6 @@
INSTALL_BASE=$PWD
MOD_NAME="ranger-usersync"
-unix_user=ranger
-unix_group=ranger
INSTALL_DIR=${INSTALL_BASE}
@@ -57,6 +55,27 @@ check_ret_status(){
fi
}
+get_prop(){
+ validateProperty=$(sed '/^\#/d' $2 | grep "^$1\s*=" | tail -n 1) # for validation
+ if test -z "$validateProperty" ; then log "[E] '$1' not found in $2 file while getting....!!"; exit 1; fi
+ value=$(echo $validateProperty | cut -d "=" -f2-)
+ if [[ $1 == *password* ]]
+ then
+ echo $value
+ else
+ echo $value | tr -d \'\"
+ fi
+}
+
+PROPFILE=$PWD/install.properties
+if [ ! -f "${PROPFILE}" ]; then
+ echo "$PROPFILE file not found....!!"
+ exit 1;
+fi
+
+unix_user=$(get_prop 'unix_user' $PROPFILE)
+unix_group=$(get_prop 'unix_group' $PROPFILE)
+
SYNC_LDAP_BIND_KEYSTOREPATH=`grep '^[ \t]*CRED_KEYSTORE_FILENAME[ \t]*=' ${cdir}/install.properties | sed -e 's:^[ \t]*CRED_KEYSTORE_FILENAME[ \t]*=[ \t]*::'`
# END Grep configuration properties from install.properties