@@ -, +, @@ --- .../base/univention-system-setup/Makefile | 4 ++ .../base/univention-system-setup/tests/Makefile | 4 ++ .../tests/setup_utils-check_ldap_access.sh | 10 +++ .../tests/setup_utils-check_ldap_available.sh | 10 +++ .../tests/setup_utils-get_profile_var.sh | 17 +++++ .../tests/setup_utils-info_header-arg.sh | 8 +++ .../tests/setup_utils-info_header.sh | 8 +++ .../tests/setup_utils-is_variable_set.sh | 18 ++++++ .../tests/setup_utils-ldap_binddn-backup.sh | 30 +++++++++ .../tests/setup_utils-ldap_binddn-master.sh | 30 +++++++++ .../tests/setup_utils-ldap_binddn-slave-base64.sh | 65 ++++++++++++++++++++ .../tests/setup_utils-ldap_binddn-slave.sh | 56 +++++++++++++++++ .../tests/setup_utils-ldap_bindpwd-backup.sh | 29 +++++++++ .../tests/setup_utils-ldap_bindpwd-master.sh | 29 +++++++++ .../tests/setup_utils-ldap_bindpwd-slave.sh | 32 ++++++++++ .../tests/setup_utils-progress_error.sh | 7 +++ .../tests/setup_utils-progress_join_error.sh | 7 +++ .../tests/setup_utils-progress_msg.sh | 7 +++ .../tests/setup_utils-progress_next_step.sh | 16 +++++ .../tests/setup_utils-progress_steps.sh | 7 +++ .../tests/setup_utils-setvice_start.sh | 12 ++++ .../tests/setup_utils-setvice_stop.sh | 12 ++++ 22 files changed, 418 insertions(+) create mode 100644 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/Makefile create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/Makefile create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_access.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_available.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-get_profile_var.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header-arg.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-is_variable_set.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-backup.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-master.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave-base64.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-backup.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-master.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-slave.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_error.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_join_error.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_msg.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_next_step.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_steps.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_start.sh create mode 100755 branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_stop.sh --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/Makefile +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/Makefile @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +test: + $(MAKE) -C tests --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/Makefile +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/Makefile @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +test: + run-parts --verbose --regex='\.sh$$' -- . --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_access.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_access.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +set -- +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh +[ 0 -eq "$check_ldap_access" ] + +set -- --check_ldap_access +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh +[ 1 -eq "$check_ldap_access" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_available.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_available.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +set -- +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh +[ -z "$check_ldap_availability" ] + +set -- --check_ldap_availability +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh +[ 1 -eq "$check_ldap_availability" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-get_profile_var.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-get_profile_var.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -e + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +profile_file=$(mktemp) +trap "rm -f '$profile_file'" EXIT + +[ -z "$(get_profile_var)" ] + +[ -z "$(get_profile_var var)" ] + +echo 'var=val' >"$profile_file" +[ "val" = "$(get_profile_var var)" ] + +rm -f "$profile_file" +[ -z "$(get_profile_var)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header-arg.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header-arg.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +header="$(info_header dummy msg)" +grep -Eq "^=== .* \([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\) ===$" <<<"$header" +grep -Eq "^__NAME__:.* msg$" <<<"$header" --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +header="$(info_header)" +grep -Eq "^=== .* \([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\) ===$" <<<"$header" +grep -Eq "^__NAME__:(.*) \1$" <<<"$header" --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-is_variable_set.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-is_variable_set.sh @@ -0,0 +1,18 @@ +#!/bin/sh +set -e +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +profile_file=$(mktemp) +trap "rm -f '$profile_file'" EXIT + +is_variable_set || die "empty" + +is_variable_set "var" || die "unset" + +echo 'var=val' >"$profile_file" +is_variable_set "var" && die "set" + +rm -f "$profile_file" +is_variable_set "var" || die "missing" --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-backup.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-backup.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e +DOMAIN="example.com" +LDAP_BASE="dc=example,dc=com" +LDAP_FQDN="ldap.$DOMAIN" +HOST_DN="cn=host,$LDAP_BASE" +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +univention-config-registry () { + [ "shell" = "$1" ] || exit 1 + shift + while [ $# -ge 1 ] + do + case "$1" in + server/role) echo 'server_role="domaincontroller_backup"' ;; + ldap/base) echo "ldap_base=\"$LDAP_BASE\"" ;; + ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;; + ldap/hostdn) echo "ldap_hostdn=\"$HOST_DN\"" ;; + *) die "$*" ;; + esac + shift + done +} +ldapsearch () { + die "$*" +} + +[ "cn=admin,$LDAP_BASE" = "$(ldap_binddn)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-master.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-master.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -e +DOMAIN="example.com" +LDAP_BASE="dc=example,dc=com" +LDAP_FQDN="ldap.$DOMAIN" +HOST_DN="cn=host,$LDAP_BASE" +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +univention-config-registry () { + [ "shell" = "$1" ] || exit 1 + shift + while [ $# -ge 1 ] + do + case "$1" in + server/role) echo 'server_role="domaincontroller_master"' ;; + ldap/base) echo "ldap_base=\"$LDAP_BASE\"" ;; + ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;; + ldap/hostdn) echo "ldap_hostdn=\"$HOST_DN\"" ;; + *) die "$*" ;; + esac + shift + done +} +ldapsearch () { + die "$*" +} + +[ "cn=admin,$LDAP_BASE" = "$(ldap_binddn)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave-base64.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave-base64.sh @@ -0,0 +1,65 @@ +#!/bin/bash +set -e +DOMAIN="example.com" +LDAP_BASE="dc=example,dc=com" +LDAP_FQDN="ldap.$DOMAIN" +HOST_DN="cn=host,$LDAP_BASE" +USER_NAME="user mit Umlauten äöüÄÖÜß" +USER_DN="uid=$USER_NAME,cn=users in Bremen,$LDAP_BASE" +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +profile_file=$(mktemp) +trap "rm -f '$profile_file'" EXIT +echo "ldap_username=\"$USER_NAME\"" >"$profile_file" + +univention-config-registry () { + [ "shell" = "$1" ] || exit 1 + shift + while [ $# -ge 1 ] + do + case "$1" in + server/role) echo 'server_role="domaincontroller_slave"' ;; + ldap/base) echo "dap_base=\"$LDAP_BASE\"" ;; + ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;; + ldap/hostdn) echo "ldap_hostdn=\"$HOST_DN\"" ;; + *) die "$*" ;; + esac + shift + done +} +ldapsearch () { + while [ $# -ge 1 ] + do + case "$1" in + -x|-Z|-ZZ|-L|-LL) ;; + -D) [ "$HOST_DN" = "$2" ] || die "$*" ; shift ;; + -y) [ "/etc/machine.secret" = "$2" ] || die "$*" ; shift ;; + -h) [ "$LDAP_FQDN" = "$2" ] || die "$*" ; shift ;; + -*) die "$*" ;; + *"(uid=$USER_NAME)"*) ;; + dn) ;; + *) die "$*" ;; + esac + shift + done + echo -n "dn:: " + echo "$USER_DN" | base64 | sed -e '2,$s/^/ /' +} +type ldapsearch-wrapper >/dev/null 2>&1 || ldapsearch-wrapper () { + sed -e '1{h;$n;d;};/^[ \t]/{H;g;s/\n[ \t]//;$n;h;d;};x;${p;x;}' +} +type ldapsearch-base64 >/dev/null 2>&1 || ldapsearch-base64 () { + local line + while read key val + do + case "$key" in + "") echo ;; + dn::) echo "dn: $(base64 -d <<<"$val")" ;; + *) die "$key" ;; + esac + done +} + +[ "$USER_DN" = "$(ldap_binddn)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave.sh @@ -0,0 +1,56 @@ +#!/bin/bash +set -e +DOMAIN="example.com" +LDAP_BASE="dc=example,dc=com" +LDAP_FQDN="ldap.$DOMAIN" +HOST_DN="cn=host,$LDAP_BASE" +USER_NAME="user" +USER_DN="uid=$USER_NAME,cn=users,$LDAP_BASE" +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +profile_file=$(mktemp) +trap "rm -f '$profile_file'" EXIT +echo "ldap_username=\"$USER_NAME\"" >"$profile_file" + +univention-config-registry () { + [ "shell" = "$1" ] || exit 1 + shift + while [ $# -ge 1 ] + do + case "$1" in + server/role) echo 'server_role="domaincontroller_slave"' ;; + ldap/base) echo "ldap_base=\"$LDAP_BASE\"" ;; + ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;; + ldap/hostdn) echo "ldap_hostdn=\"$HOST_DN\"" ;; + *) die "$*" ;; + esac + shift + done +} +ldapsearch () { + while [ $# -ge 1 ] + do + case "$1" in + -x|-Z|-ZZ|-L|-LL) ;; + -D) [ "$HOST_DN" = "$2" ] || die "$*" ; shift ;; + -y) [ "/etc/machine.secret" = "$2" ] || die "$*" ; shift ;; + -h) [ "$LDAP_FQDN" = "$2" ] || die "$*" ; shift ;; + -*) die "$*" ;; + *"(uid=$USER_NAME)"*) ;; + dn) ;; + *) die "$*" ;; + esac + shift + done + echo "dn: $USER_DN" +} +type ldapsearch-wrapper >/dev/null 2>&1 || ldapsearch-wrapper () { + sed -e '1{h;$n;d;};/^[ \t]/{H;g;s/\n[ \t]//;$n;h;d;};x;${p;x;}' +} +ldapsearch-base64 () { + /bin/cat +} + +[ "$USER_DN" = "$(ldap_binddn)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-backup.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-backup.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e +DOMAIN="example.com" +LDAP_BASE="dc=example,dc=com" +LDAP_FQDN="ldap.$DOMAIN" +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +univention-config-registry () { + [ "shell" = "$1" ] || exit 1 + shift + while [ $# -ge 1 ] + do + case "$1" in + ldap/base) echo "dap_base=\"$LDAP_BASE\"" ;; + ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;; + server/role) echo 'server_role="domaincontroller_backup"' ;; + *) die "$*" ;; + esac + shift + done +} +cat () { + [ "/etc/ldap.secret" = "$1" ] || exit 1 + echo -n "univention" +} + +[ "univention" = "$(ldap_bindpwd)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-master.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-master.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e +DOMAIN="example.com" +LDAP_BASE="dc=example,dc=com" +LDAP_FQDN="ldap.$DOMAIN" +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +univention-config-registry () { + [ "shell" = "$1" ] || exit 1 + shift + while [ $# -ge 1 ] + do + case "$1" in + ldap/base) echo "dap_base=\"$LDAP_BASE\"" ;; + ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;; + server/role) echo 'server_role="domaincontroller_master"' ;; + *) die "$*" ;; + esac + shift + done +} +cat () { + [ "/etc/ldap.secret" = "$1" ] || exit 1 + echo -n "univention" +} + +[ "univention" = "$(ldap_bindpwd)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-slave.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-slave.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e +DOMAIN="example.com" +LDAP_BASE="dc=example,dc=com" +LDAP_FQDN="ldap.$DOMAIN" +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +profile_file=$(mktemp) +trap "rm -f '$profile_file'" EXIT +echo 'ldap_password="univention"' >"$profile_file" + +univention-config-registry () { + [ "shell" = "$1" ] || exit 1 + shift + while [ $# -ge 1 ] + do + case "$1" in + ldap/base) echo "dap_base=\"$LDAP_BASE\"" ;; + ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;; + server/role) echo 'server_role="domaincontroller_slave"' ;; + *) die "$*" ;; + esac + shift + done +} +cat () { + exit 2 +} + +[ "univention" = "$(ldap_bindpwd)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_error.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_error.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +[ "__ERR__:" = "$(progress_error)" ] +[ "__ERR__:msg" = "$(progress_error msg)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_join_error.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_join_error.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +[ "__JOINERR__:" = "$(progress_join_error)" ] +[ "__JOINERR__:msg" = "$(progress_join_error msg)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_msg.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_msg.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +[ "__MSG__:" = "$(progress_msg)" ] +[ "__MSG__:msg" = "$(progress_msg msg)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_next_step.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_next_step.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +tmp=$(mktemp) +trap "rm -f '$tmp'" EXIT + +progress_next_step >"$tmp" +grep -Fq '__STEP__:' "$tmp" +progress_next_step >"$tmp" +grep -Fq '__STEP__:1' "$tmp" +progress_next_step 42 >"$tmp" +grep -Fq '__STEP__:42' "$tmp" +progress_next_step >"$tmp" +grep -Fq '__STEP__:42' "$tmp" --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_steps.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_steps.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +[ "__STEPS__:" = "$(progress_steps)" ] +[ "__STEPS__:42" = "$(progress_steps 42)" ] --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_start.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_start.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e +SERVICE="../../bin/true" +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +invoke-rc.d () { + [ "$SERVICE" = "$1" ] || die "$*" + [ "start" = "$2" ] || die "$*" +} +service_start "$SERVICE" --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_stop.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_stop.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e +SERVICE="../../bin/true" +die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; } + +. ../usr/lib/univention-system-setup/scripts/setup_utils.sh + +invoke-rc.d () { + [ "$SERVICE" = "$1" ] || die "$*" + [ "stop" = "$2" ] || die "$*" +} +service_stop "$SERVICE" -- --- .../usr/lib/univention-system-setup/scripts/setup_utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh @@ -53,7 +53,7 @@ do done # writes an info header -# @param script path +# @param script path (unused) # @param description (optional) info_header() { @@ -111,7 +111,7 @@ progress_next_step() } is_variable_set() -{ +{ # INVERTED return code: returns '1' if found, '0' if not if [ ! -e $profile_file ]; then return 0 fi -- --- .../usr/lib/univention-system-setup/scripts/setup_utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh @@ -144,7 +144,7 @@ service_stop () { for service in $@; do if [ -x /etc/init.d/$service ]; then - /etc/init.d/$service stop + invoke-rc.d "$service" stop fi done } @@ -152,7 +152,7 @@ service_start () { for service in $@; do if [ -x /etc/init.d/$service ]; then - /etc/init.d/$service start + invoke-rc.d "$service" start fi done } -- --- .../univention-system-setup/scripts/setup_utils.sh | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh @@ -57,14 +57,13 @@ done # @param description (optional) info_header() { - _path=$(readlink -m "$0") + _path="$(readlink -m "$0")" script="${_path##*scripts/}" echo "=== $script ($(date +'%Y-%m-%d %H:%M:%S')) ===" # information for the internal progress handler # print the name of the script... if not specified the script name - name="$2" - [ -z "$name" ] && name="$script" + name="${2:-$script}" echo "__NAME__:$script $name" } @@ -112,7 +111,7 @@ progress_next_step() is_variable_set() { # INVERTED return code: returns '1' if found, '0' if not - if [ ! -e $profile_file ]; then + if [ ! -e "$profile_file" ]; then return 0 fi @@ -128,7 +127,7 @@ is_variable_set() } get_profile_var () { - if [ ! -e $profile_file ]; then + if [ ! -e "$profile_file" ]; then return fi @@ -142,16 +141,20 @@ get_profile_var () service_stop () { - for service in $@; do - if [ -x /etc/init.d/$service ]; then + for service in "$@" + do + if [ -x "/etc/init.d/$service" ] + then invoke-rc.d "$service" stop fi done } service_start () { - for service in $@; do - if [ -x /etc/init.d/$service ]; then + for service in "$@" + do + if [ -x "/etc/init.d/$service" ] + then invoke-rc.d "$service" start fi done -- --- .../base/univention-system-setup/debian/changelog | 6 ++++++ .../univention-system-setup/scripts/setup_utils.sh | 22 ++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/debian/changelog +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/debian/changelog @@ -1,3 +1,9 @@ +univention-system-setup (7.0.29-1) unstable; urgency=low + + * Fix ldapsearch wrapping and encoding (Bug #32324) + + -- Philipp Hahn Fri, 23 Aug 2013 08:18:04 +0200 + univention-system-setup (7.0.28-1) unstable; urgency=low * Revert second half of change of 7.0.26-1 (Bug #31960) --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh @@ -118,12 +118,7 @@ is_variable_set() if [ -z "$1" ]; then return 0 fi - value=`egrep "^$1=" $profile_file ` - if [ -z "$value" ]; then - return 0 - else - return 1 - fi + ! egrep -q "^$1=" "$profile_file" } get_profile_var () { @@ -135,8 +130,7 @@ get_profile_var () return fi - value=`egrep "^$1=" $profile_file |sed -e 's|#.*||' | sed -e "s|^$1=||" | sed -e 's|"||g;s| $||g'` - echo "$value" + sed -rne "s/^$1=//;T;s/#.*//;s/([\"'])(.*)\1 *$/\2/;p;q" "$profile_file" } service_stop () @@ -166,10 +160,12 @@ ldap_binddn () if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then echo "cn=admin,$ldap_base" else - ldap_username=`get_profile_var ldap_username` + ldap_username="$(get_profile_var ldap_username)" if [ -n "$ldap_username" ]; then - dn=`ldapsearch -x -ZZ -D "$ldap_hostdn" -y /etc/machine.secret -h $ldap_master "(&(objectClass=person)(uid=$ldap_username))" | grep "dn: " | sed -e 's|dn: ||' | head -n 1` - echo "$dn" + ldapsearch -x -ZZ -D "$ldap_hostdn" -y /etc/machine.secret -h "$ldap_master" "(&(objectClass=person)(uid=$ldap_username))" dn | + ldapsearch-wrapper | + ldapsearch-base64 | + sed -ne 's|^dn: ||;T;p;q' fi fi } @@ -178,9 +174,9 @@ ldap_bindpwd () { eval "$(univention-config-registry shell server/role ldap/base ldap/master)" if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then - echo "`cat /etc/ldap.secret`" + cat /etc/ldap.secret else - ldap_password=`get_profile_var ldap_password` + ldap_password="$(get_profile_var ldap_password)" if [ -n "$ldap_password" ]; then echo "$ldap_password" fi -- --- .../usr/lib/univention-system-setup/scripts/setup_utils.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh +++ a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh @@ -57,6 +57,7 @@ done # @param description (optional) info_header() { + local _path _script name _path="$(readlink -m "$0")" script="${_path##*scripts/}" echo "=== $script ($(date +'%Y-%m-%d %H:%M:%S')) ===" @@ -135,6 +136,7 @@ get_profile_var () service_stop () { + local service for service in "$@" do if [ -x "/etc/init.d/$service" ] @@ -145,6 +147,7 @@ service_stop () } service_start () { + local service for service in "$@" do if [ -x "/etc/init.d/$service" ] @@ -156,6 +159,7 @@ service_start () ldap_binddn () { + local server_role ldap_base ldap_master ldap_hostdn ldap_username eval "$(univention-config-registry shell server/role ldap/base ldap/master ldap/hostdn)" if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then echo "cn=admin,$ldap_base" @@ -172,7 +176,8 @@ ldap_binddn () ldap_bindpwd () { - eval "$(univention-config-registry shell server/role ldap/base ldap/master)" + local server_role ldap_password + eval "$(univention-config-registry shell server/role)" if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then cat /etc/ldap.secret else --