You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by sn...@apache.org on 2014/08/18 08:36:41 UTC
[2/4] git commit: ARGUS-6 - Modified usersync to import
username/group in a mixed (no case) or a specific case (lower, upper)
ARGUS-6 - Modified usersync to import username/group in a mixed (no
case) or a specific case (lower,upper)
Project: http://git-wip-us.apache.org/repos/asf/incubator-argus/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-argus/commit/2e06b599
Tree: http://git-wip-us.apache.org/repos/asf/incubator-argus/tree/2e06b599
Diff: http://git-wip-us.apache.org/repos/asf/incubator-argus/diff/2e06b599
Branch: refs/heads/master
Commit: 2e06b5998f891f09d76d7048bf08d9d72e628766
Parents: 3495911
Author: sneethiraj <sn...@apache.org>
Authored: Sun Aug 17 18:39:59 2014 -0400
Committer: sneethiraj <sn...@apache.org>
Committed: Sun Aug 17 18:39:59 2014 -0400
----------------------------------------------------------------------
.../config/UserGroupSyncConfig.java | 27 ++++++++++++++++
unixauthservice/scripts/initd | 4 ++-
unixauthservice/scripts/install.properties | 5 +++
unixauthservice/scripts/install.sh | 33 ++++++++++++++++----
4 files changed, 62 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/2e06b599/ugsync/src/main/java/com/xasecure/unixusersync/config/UserGroupSyncConfig.java
----------------------------------------------------------------------
diff --git a/ugsync/src/main/java/com/xasecure/unixusersync/config/UserGroupSyncConfig.java b/ugsync/src/main/java/com/xasecure/unixusersync/config/UserGroupSyncConfig.java
index 7a5938b..497959c 100644
--- a/ugsync/src/main/java/com/xasecure/unixusersync/config/UserGroupSyncConfig.java
+++ b/ugsync/src/main/java/com/xasecure/unixusersync/config/UserGroupSyncConfig.java
@@ -79,6 +79,16 @@ public class UserGroupSyncConfig {
private static final String DEFAULT_USER_NAME_ATTRIBUTE = "cn";
+ public static final String UGSYNC_NONE_CASE_CONVERSION_VALUE = "none" ;
+ public static final String UGSYNC_LOWER_CASE_CONVERSION_VALUE = "lower" ;
+ public static final String UGSYNC_UPPER_CASE_CONVERSION_VALUE = "upper" ;
+
+ private static final String UGSYNC_USERNAME_CASE_CONVERSION_PARAM = "ldapGroupSync.username.caseConversion" ;
+ private static final String UGSYNC_GROUPNAME_CASE_CONVERSION_PARAM = "ldapGroupSync.groupname.caseConversion" ;
+
+ private static final String DEFAULT_UGSYNC_USERNAME_CASE_CONVERSION_VALUE = UGSYNC_LOWER_CASE_CONVERSION_VALUE ;
+ private static final String DEFAULT_UGSYNC_GROUPNAME_CASE_CONVERSION_VALUE = UGSYNC_LOWER_CASE_CONVERSION_VALUE ;
+
private static final String DEFAULT_USER_GROUP_NAME_ATTRIBUTE = "memberof,ismemberof";
private Properties prop = new Properties() ;
@@ -349,5 +359,22 @@ public class UserGroupSyncConfig {
return userGroupNameAttributeSet;
}
+ public String getUserNameCaseConversion() {
+ String ret = prop.getProperty(UGSYNC_USERNAME_CASE_CONVERSION_PARAM, DEFAULT_UGSYNC_USERNAME_CASE_CONVERSION_VALUE) ;
+ return ret.trim().toLowerCase() ;
+ }
+
+ public String getGroupNameCaseConversion() {
+ String ret = prop.getProperty(UGSYNC_GROUPNAME_CASE_CONVERSION_PARAM, DEFAULT_UGSYNC_GROUPNAME_CASE_CONVERSION_VALUE) ;
+ return ret.trim().toLowerCase() ;
+ }
+
+ public String getProperty(String aPropertyName) {
+ return prop.getProperty(aPropertyName) ;
+ }
+
+ public String getProperty(String aPropertyName, String aDefaultValue) {
+ return prop.getProperty(aPropertyName, aDefaultValue) ;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/2e06b599/unixauthservice/scripts/initd
----------------------------------------------------------------------
diff --git a/unixauthservice/scripts/initd b/unixauthservice/scripts/initd
index 11f6c36..b874c06 100644
--- a/unixauthservice/scripts/initd
+++ b/unixauthservice/scripts/initd
@@ -1,8 +1,10 @@
#!/bin/bash
+INSTALL_BASE=/usr/lib
+
MOD_NAME=uxugsync
-MOD_DIR=/etc/${MOD_NAME}
+MOD_DIR=${INSTALL_BASE}/${MOD_NAME}
if [ -L ${MOD_DIR} ]
then
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/2e06b599/unixauthservice/scripts/install.properties
----------------------------------------------------------------------
diff --git a/unixauthservice/scripts/install.properties b/unixauthservice/scripts/install.properties
index 5c361c7..4331fd2 100644
--- a/unixauthservice/scripts/install.properties
+++ b/unixauthservice/scripts/install.properties
@@ -74,4 +74,9 @@ SYNC_LDAP_USER_NAME_ATTRIBUTE = cn
# You could provide multiple attribute names separated by comma
# default value: memberof, ismemberof
SYNC_LDAP_USER_GROUP_NAME_ATTRIBUTE = memberof,ismemberof
+#
+# UserSync - Case Conversion Flags
+# possible values: none, lower, upper
+SYNC_LDAP_USERNAME_CASE_CONVERSION=lower
+SYNC_LDAP_GROUPNAME_CASE_CONVERSION=lower
http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/2e06b599/unixauthservice/scripts/install.sh
----------------------------------------------------------------------
diff --git a/unixauthservice/scripts/install.sh b/unixauthservice/scripts/install.sh
index 6e11afc..7b783fe 100755
--- a/unixauthservice/scripts/install.sh
+++ b/unixauthservice/scripts/install.sh
@@ -4,6 +4,8 @@
# Ensure that the user is root
#
+INSTALL_BASE=/usr/lib
+
MOD_NAME="uxugsync"
MY_ID=`id -u`
@@ -20,6 +22,7 @@ then
exit 1
fi
+INSTALL_DIR=${INSTALL_BASE}/${MOD_NAME}
#
# Embed the configuration from install.properties to conf/unixauthservice.properties
@@ -52,7 +55,22 @@ SYNC_LDAP_USER_NAME_ATTRIBUTE=`grep '^[ \t]*SYNC_LDAP_USER_NAME_ATTRIBUTE[ \t]*=
SYNC_LDAP_USER_GROUP_NAME_ATTRIBUTE=`grep '^[ \t]*SYNC_LDAP_USER_GROUP_NAME_ATTRIBUTE[ \t]*=' ${cdir}/install.properties | awk -F= '{ print $2 }' | sed -e 's:[ \t]*::g'`
+SYNC_LDAP_USERNAME_CASE_CONVERSION=`grep '^[ \t]*SYNC_LDAP_USERNAME_CASE_CONVERSION[ \t]*=' ${cdir}/install.properties | awk -F= '{ print $2 }' | sed -e 's:[ \t]*::g'`
+
+SYNC_LDAP_GROUPNAME_CASE_CONVERSION=`grep '^[ \t]*SYNC_LDAP_GROUPNAME_CASE_CONVERSION[ \t]*=' ${cdir}/install.properties | awk -F= '{ print $2 }' | sed -e 's:[ \t]*::g'`
+
+if [ "${SYNC_LDAP_USERNAME_CASE_CONVERSION}" == "" ]
+then
+ SYNC_LDAP_USERNAME_CASE_CONVERSION="none"
+fi
+
+if [ "${SYNC_LDAP_GROUPNAME_CASE_CONVERSION}" == "" ]
+then
+ SYNC_LDAP_GROUPNAME_CASE_CONVERSION="none"
+fi
+
SYNC_LDAP_BIND_KEYSTOREPATH=`grep '^[ \t]*CRED_KEYSTORE_FILENAME[ \t]*=' ${cdir}/install.properties | sed -e 's:^[ \t]*CRED_KEYSTORE_FILENAME[ \t]*=[ \t]*::'`
+
SYNC_LDAP_BIND_ALIAS=ldap.bind.password
if [ "${SYNC_INTERVAL}" != "" ]
@@ -162,6 +180,8 @@ then
-e "s|^\( *ldapGroupSync.userSearchFilter *=\).*-|1 ${SYNC_LDAP_USER_SEARCH_FILTER}|" \
-e "s|^\( *ldapGroupSync.userNameAttribute *=\).*|\1 ${SYNC_LDAP_USER_NAME_ATTRIBUTE}|" \
-e "s|^\( *ldapGroupSync.userGroupNameAttribute *=\).*|\1 ${SYNC_LDAP_USER_GROUP_NAME_ATTRIBUTE}|" \
+ -e "s|^\( *ldapGroupSync.username.caseConversion *=\).*|\1 ${SYNC_LDAP_USERNAME_CASE_CONVERSION}|" \
+ -e "s|^\( *ldapGroupSync.groupname.caseConversion *=\).*|\1 ${SYNC_LDAP_GROUPNAME_CASE_CONVERSION}|" \
${CFG_FILE} > ${NEW_CFG_FILE}
mv ${CFG_FILE} ${CFG_FILE}_archive_`date '+%s'`
mv ${NEW_CFG_FILE} ${CFG_FILE}
@@ -181,23 +201,24 @@ cdirname=`basename ${cdir}`
if [ "${cdirname}" != "" ]
then
- dstdir=/etc/${cdirname}
+ dstdir=${INSTALL_BASE}/${cdirname}
if [ -d ${dstdir} ]
then
ctime=`date '+%s'`
- mkdir -p /etc/xasecure/archive/${ctime}
- mv ${dstdir} /etc/xasecure/archive/${ctime}/
+ archive_dir=${dstdir}-${ctime}
+ mkdir -p ${archive_dir}
+ mv ${dstdir} ${archive_dir}
fi
mkdir ${dstdir}
- if [ -L /etc/${MOD_NAME} ]
+ if [ -L ${INSTALL_DIR} ]
then
- rm -f /etc/${MOD_NAME}
+ rm -f ${INSTALL_DIR}
fi
- ln -s ${dstdir} /etc/${MOD_NAME}
+ ln -s ${dstdir} ${INSTALL_DIR}
(cd ${cdir} ; find . -print | cpio -pdm ${dstdir})
(cd ${cdir} ; cat start.sh | sed -e "s|[ \t]*JAVA_HOME=| JAVA_HOME=${JAVA_HOME}|" > ${dstdir}/start.sh)