diff -ur nordugrid-arc-1.0.1.orig/src/services/ldap-infosys/giis/Entry.cpp nordugrid-arc-1.0.1/src/services/ldap-infosys/giis/Entry.cpp --- nordugrid-arc-1.0.1.orig/src/services/ldap-infosys/giis/Entry.cpp 2011-07-23 09:31:23.621415872 +0200 +++ nordugrid-arc-1.0.1/src/services/ldap-infosys/giis/Entry.cpp 2011-08-27 12:47:51.772596434 +0200 @@ -19,12 +19,12 @@ port = atoi(it->substr(18).c_str()); if(it->substr(0, 25) == "Mds-Service-Ldap-suffix: ") suffix = it->substr(25); - if(it->substr(0, 28) == "Mds-Service-Ldap-cachettl: ") - cachetime = atoi(it->substr(28).c_str()); - if(it->substr(0, 27) == "Mds-Service-Ldap-timeout: ") - timelimit = atoi(it->substr(27).c_str()); - if(it->substr(0, 29) == "Mds-Service-Ldap-sizelimit: ") - sizelimit = atoi(it->substr(29).c_str()); + if(it->substr(0, 27) == "Mds-Service-Ldap-cachettl: ") + cachetime = atoi(it->substr(27).c_str()); + if(it->substr(0, 26) == "Mds-Service-Ldap-timeout: ") + timelimit = atoi(it->substr(26).c_str()); + if(it->substr(0, 28) == "Mds-Service-Ldap-sizelimit: ") + sizelimit = atoi(it->substr(28).c_str()); if(it->substr(0, 15) == "Mds-validfrom: ") validfrom = it->substr(15); if(it->substr(0, 13) == "Mds-validto: ") diff -ur nordugrid-arc-1.0.1.orig/src/services/ldap-infosys/grid-infosys-bdii5.in nordugrid-arc-1.0.1/src/services/ldap-infosys/grid-infosys-bdii5.in --- nordugrid-arc-1.0.1.orig/src/services/ldap-infosys/grid-infosys-bdii5.in 2011-07-23 09:31:23.627415796 +0200 +++ nordugrid-arc-1.0.1/src/services/ldap-infosys/grid-infosys-bdii5.in 2011-08-27 14:07:02.880199415 +0200 @@ -137,30 +137,6 @@ esac } - -# Function checks if we are using a nordugrid-patched bdii Returns -# true (1) if bdii is unpatched. Returns false (0) if it is patched. -# In case it is patched, we should disable o=infosys as default. If -# it is not patched, then keep o=infosys since plain bdii does not -# support turning this feature off. -check_if_bdii_unpatched () { - if [ $# != 1 ]; then - error_echo "check_bdii called with too few arguments, wanted bdii_update_file_path" - exit 1 - fi - bdii_update_file=$1 - grep -q "bdii_infosys" $bdii_update_file - if [ $? -eq 0 ]; then - debug_echo "You are using a patched version of BDII." - debug_echo "Will default to turning off o=infosys unless specifically handled in arc.conf" - return 0 - else - debug_echo "Warning: You are using a pure version of BDII." - debug_echo "Will not try to turn o=infosys off since this is not supported." - return 1 - fi -} - ############### Standard configuration ###################### # Set ARC location @@ -290,21 +266,27 @@ bdii_location=${CONFIG_bdii_location:-/usr} giis_location=${CONFIG_giis_location:-$ARC_LOCATION} +bdii_update_cmd=${CONFIG_bdii_update_cmd:-"${bdii_location}/sbin/bdii-update"} +if [ ! -e $bdii_update_cmd ]; then + log_failure_msg "Can not find bdii-update command at: $bdii_update_cmd." + log_failure_msg "Please set bdii_update_cmd in arc.conf" + exit 1 +fi + bdii_tmp_dir=${CONFIG_bdii_tmp_dir:-/var/tmp/arc/bdii} +if grep -q BDII_PID_FILE $bdii_update_cmd ; then +bdii_var_dir=${CONFIG_bdii_var_dir:-/var/lib/arc/bdii} +bdii_run_dir=${CONFIG_bdii_run_dir:-/var/run/arc/bdii} +else bdii_var_dir=${CONFIG_bdii_var_dir:-/var/run/arc/bdii} +bdii_run_dir=$bdii_var_dir +fi bdii_log_dir=${CONFIG_bdii_log_dir:-/var/log/arc/bdii} bdii_log_file="${bdii_log_dir}/bdii-update.log" mkdir -p $bdii_log_dir -bdii_slapd_conf=$bdii_var_dir/bdii-slapd.conf - -bdii_update_cmd=${CONFIG_bdii_update_cmd:-"${bdii_location}/sbin/bdii-update"} -if [ ! -e $bdii_update_cmd ]; then - log_failure_msg "Can not find bdii-update command at: $bdii_update_cmd." - log_failure_msg "Please set bdii_update_cmd in arc.conf" - exit 1 -fi +bdii_slapd_conf=$bdii_run_dir/bdii-slapd.conf bdii_default_ldif_ng=${bdii_tmp_dir}/provider/arc-default.ldif.pl bdii_ldif_dir=${bdii_tmp_dir}/ldif @@ -313,12 +295,11 @@ bdii_port=${CONFIG_port:-2135} -#Using uppercase characters in bdii_bind will break infosys. +# Using uppercase characters in bdii_bind will break infosys. bdii_bind="o=grid" -#TODO add to BDII + bdii_db_config=${CONFIG_bdii_db_config:-"/etc/bdii/DB_CONFIG"} -bdii_database=${CONFIG_bdii_database:-"bdb"} -bdii_fix_glue=${CONFIG_fix_glue:-no} +bdii_database=${CONFIG_bdii_database:-"hdb"} bdii_archive_size=${CONFIG_bdii_archive_size:-0} infosys_compat=${CONFIG_infosys_compat:-"disable"} @@ -346,8 +327,8 @@ fi bdii_delete_delay=${CONFIG_bdii_delete_delay:-0} -update_pid_file=${CONFIG_bdii_update_pid_file:-/var/run/arc/bdii-update.pid} -slapd_pid_file=${CONFIG_slapd_pid_file:-$bdii_var_dir/db/slapd.pid} +update_pid_file=${CONFIG_bdii_update_pid_file:-$bdii_run_dir/bdii-update.pid} +slapd_pid_file=${CONFIG_slapd_pid_file:-$bdii_run_dir/db/slapd.pid} # Debian does not have /var/lock/subsys if [ -d /var/lock/subsys ]; then @@ -360,13 +341,6 @@ lockfile=/var/lock/$prog fi -# o=infosys should be disabled by default if possible. -infosys_debug=${CONFIG_infosys_debug:-"disable"} -bdii_infosys="no" -if [ "x$infosys_debug" = "xenable" ]; then - bdii_infosys="yes" -fi - # Check directories and permissions registrationlog=${CONFIG_registrationlog:-/var/log/arc/inforegistration.log} mkdir -p `dirname $registrationlog` @@ -463,19 +437,20 @@ fi # This will get written to bdii slapd.conf: - slapd_modulepath="modulepath $ldaplib" - slapd_moduleload_index="moduleload back_shell" + if [ -r ${giis_location}/lib64/arc/arc-infoindex-slapd-wrapper.so ]; then + pkglibdir=${giis_location}/lib64/arc + elif [ -r ${giis_location}/lib/arc/arc-infoindex-slapd-wrapper.so ]; then + pkglibdir=${giis_location}/lib/arc + else + error_echo "Error, could not find infoindex slapd wrapper" + exit 1 + fi + slapd_modulepath="modulepath $ldaplib:$pkglibdir" + slapd_moduleload_index1="moduleload back_shell" + slapd_moduleload_index2="moduleload arc-infoindex-slapd-wrapper" fi fi -# If we are running on an unpatched BDII, handle it gracefully by -# having o=infosys enabled. -check_if_bdii_unpatched $bdii_update_cmd -if [ $? -gt 0 ]; then - infosys_debug=enable - bdii_infosys=yes -fi - resource_location="" resource_latitude="" resource_longitude="" @@ -574,29 +549,26 @@ rm -f ${BDII_CONF} std_header ${BDII_CONF} cat <<-EOF >> ${BDII_CONF} - BDII_DIR=$bdii_location - BDII_VAR_DIR=$bdii_var_dir BDII_LOG_FILE=$bdii_log_file - BDII_LOG_LEVEL=DEBUG + BDII_PID_FILE=$update_pid_file + BDII_LOG_LEVEL=ERROR BDII_LDIF_DIR=$bdii_ldif_dir BDII_PROVIDER_DIR=$bdii_provider_dir BDII_PLUGIN_DIR=$bdii_plugin_dir BDII_PORT=$bdii_port - BDII_USER=$bdii_user - BDII_BIND=$bdii_bind BDII_BREATHE_TIME=$bdii_breathe_time BDII_READ_TIMEOUT=$bdii_read_timeout - BDII_DELETE_DELAY=$bdii_delete_delay - BDII_INFOSYS=$bdii_infosys BDII_ARCHIVE_SIZE=$bdii_archive_size - FIX_GLUE=$bdii_fix_glue + BDII_DELETE_DELAY=$bdii_delete_delay + BDII_USER=$bdii_user + BDII_VAR_DIR=$bdii_var_dir SLAPD_CONF=$bdii_slapd_conf EOF } # Call with: create_arc_slapd_conf bdii_dir bdii_slapd_conf_file # Will create file $bdii_slapd_conf, normally located at: -# $bdii_var_dir/arc-slapd.conf +# $bdii_run_dir/arc-slapd.conf create_arc_slapd_conf () { if [ $# != 2 ]; then error_echo "Wrong number of arguments to create_arc_slapd_conf" @@ -639,12 +611,13 @@ $slapd_modulepath $slapd_moduleload - $slapd_moduleload_index + $slapd_moduleload_index1 + $slapd_moduleload_index2 allow bind_v2 - pidfile $bdii_var_dir/db/slapd.pid - argsfile $bdii_var_dir/db/slapd.args + pidfile $bdii_run_dir/db/slapd.pid + argsfile $bdii_run_dir/db/slapd.args loglevel $slapd_loglevel threads $threads idletimeout 120 @@ -668,6 +641,7 @@ cachesize 150000 dbnosync suffix "$suffix" + checkpoint 131072 60 rootdn "$rootdn" rootpw secret directory $bdii_var_dir/db/arc @@ -677,23 +651,21 @@ cachesize 150000 dbnosync suffix "o=glue" + checkpoint 131072 60 rootdn "o=glue" rootpw secret directory $bdii_var_dir/db/glue2 - EOF - if [ "x$infosys_debug" = "xenable" ]; then - cat <<-EOF >> $bdii_slapd_conf # Infosys database definitions database ${bdii_database} - cachesize 150000 + cachesize 60 dbnosync suffix "o=infosys" + checkpoint 131072 60 rootdn "o=infosys" rootpw secret directory $bdii_var_dir/db/stats EOF - fi } # Call with: create_default_ldif bdii_default_ldif_file @@ -1218,32 +1190,35 @@ create_bdii_config_files #Initialize the database directory - create_directory $bdii_var_dir/db/stats "BDII_VAR_DIR/db/stats" + create_directory $bdii_run_dir/db "BDII_RUN_DIR/db" + chown -R $bdii_user:$bdii_user $bdii_run_dir + [ -x /sbin/restorecon ] && /sbin/restorecon -R $bdii_run_dir/db create_directory $bdii_var_dir/db/arc "BDII_VAR_DIR/db/arc" create_directory $bdii_var_dir/db/glue2 "BDII_VAR_DIR/db/glue2" + create_directory $bdii_var_dir/db/stats "BDII_VAR_DIR/db/stats" + chown -R $bdii_user:$bdii_user $bdii_var_dir/db + [ -x /sbin/restorecon ] && /sbin/restorecon -R $bdii_var_dir/db create_directory $bdii_var_dir/archive "BDII_VAR_DIR/archive" chown -R $bdii_user:$bdii_user $bdii_var_dir - [ -x /sbin/restorecon ] && /sbin/restorecon -R $bdii_var_dir chown -R $bdii_user:$bdii_user $bdii_tmp_dir if [ ! -f $bdii_log_file ]; then touch $bdii_log_file fi chown $bdii_user:$bdii_user $bdii_log_file - $RUNUSER -s "$USERSHELL" -c "cp ${bdii_db_config} ${bdii_var_dir}/db/" $bdii_user $RUNUSER -s "$USERSHELL" -c "cp ${bdii_db_config} ${bdii_var_dir}/db/arc" $bdii_user $RUNUSER -s "$USERSHELL" -c "cp ${bdii_db_config} ${bdii_var_dir}/db/glue2" $bdii_user + $RUNUSER -s "$USERSHELL" -c "cp ${bdii_db_config} ${bdii_var_dir}/db/stats" $bdii_user #Need to remove / from mkpasswd, otherwise sed will break. pass=`/usr/bin/mkpasswd -s 0 2> /dev/null` || pass=$RANDOM$RANDOM pass=${pass//\//x} - (umask 077; >> $bdii_slapd_conf) - if [ ! -f ${bdii_slapd_conf} ]; then log_failure_msg "Can not find slapd file: ${bdii_slapd_conf}" exit 1 fi sed -i "s/secret/${pass}/g" $bdii_slapd_conf + [ -x /sbin/restorecon ] && /sbin/restorecon $bdii_slapd_conf # Finished with the config file generation. # Time to start the whole infosys @@ -1290,9 +1265,12 @@ touch ${slapd_lock_file} - if [ ! -f "${slapd_pid_file}" ]; then - sleep 2 - fi + iterlimit=30 + while [ $iterlimit -ge 0 ] && ! [ -f ${slapd_pid_file} ]; do + echo -n "*" + sleep 1 + iterlimit=$(expr $iterlimit - 1) + done if [ -f "${slapd_pid_file}" ]; then ps $(cat ${slapd_pid_file}) >/dev/null 2>&1 @@ -1317,13 +1295,10 @@ $RUNUSER -s "$USERSHELL" -c "${bdii_update_cmd} -c ${BDII_CONF} -d" ${bdii_user} touch ${update_lock_file} - if [ ! -f ${bdii_var_dir}/bdii-update.pid ]; then + if [ ! -f ${update_pid_file} ]; then sleep 2 fi - if [ -f ${bdii_var_dir}/bdii-update.pid ]; then - touch ${update_pid_file} - chown ${bdii_user} ${update_pid_file} - mv ${bdii_var_dir}/bdii-update.pid ${update_pid_file} + if [ -f ${update_pid_file} ]; then ps $(cat ${update_pid_file}) >/dev/null 2>&1 RETVAL=$? else diff -ur nordugrid-arc-1.0.1.orig/src/services/ldap-infosys/grid-infosys.in nordugrid-arc-1.0.1/src/services/ldap-infosys/grid-infosys.in --- nordugrid-arc-1.0.1.orig/src/services/ldap-infosys/grid-infosys.in 2011-07-23 09:31:23.627415796 +0200 +++ nordugrid-arc-1.0.1/src/services/ldap-infosys/grid-infosys.in 2011-08-27 12:00:51.420855684 +0200 @@ -69,13 +69,19 @@ status ;; condrestart | try-restart) - if [ -f /usr/sbin/bdii5-update ]; then + if [ -f /usr/sbin/bdii-update ]; then if [ -f ${slapd_lock_file} ] || [ -f ${update_lock_file} ]; then - restart + stop + # avoid race + sleep 3 + start fi else if [ -f "$PID_FILE" ] ; then - restart + stop + # avoid race + sleep 3 + start fi fi ;;