Univention Bugzilla – Attachment 5391 Details for
Bug 32324
System setup fails with long or Umlaut DN user
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh
32324_USS-ldapsearch.diff (text/plain), 33.66 KB, created by
Philipp Hahn
on 2013-08-23 09:08:20 CEST
(
hide
)
Description:
Fix base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2013-08-23 09:08:20 CEST
Size:
33.66 KB
patch
obsolete
>From 7a7c0e46beca0080227ab828af4c67f7b408950f Mon Sep 17 00:00:00 2001 >Message-Id: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 23 Aug 2013 08:16:33 +0200 >Subject: [PATCH 1/6] Bug #32324: USS: add regression test >Organization: Univention GmbH, Bremen, Germany > >Add a regression test for >usr/lib/univention-system-setup/scripts/setup_utils.sh. >--- > .../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 > >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/Makefile b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/Makefile >new file mode 100644 >index 0000000..65fa527 >--- /dev/null >+++ b/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 >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/Makefile b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/Makefile >new file mode 100755 >index 0000000..3855ca5 >--- /dev/null >+++ b/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$$' -- . >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_access.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_access.sh >new file mode 100755 >index 0000000..f178936 >--- /dev/null >+++ b/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" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_available.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-check_ldap_available.sh >new file mode 100755 >index 0000000..7fabb20 >--- /dev/null >+++ b/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" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-get_profile_var.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-get_profile_var.sh >new file mode 100755 >index 0000000..6ab57e0 >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header-arg.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header-arg.sh >new file mode 100755 >index 0000000..880e7e0 >--- /dev/null >+++ b/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" >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header.sh >new file mode 100755 >index 0000000..8e4e0bf >--- /dev/null >+++ b/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" >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-is_variable_set.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-is_variable_set.sh >new file mode 100755 >index 0000000..e2daaef >--- /dev/null >+++ b/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" >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-backup.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-backup.sh >new file mode 100755 >index 0000000..823701f >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-master.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-master.sh >new file mode 100755 >index 0000000..538cccd >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave-base64.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave-base64.sh >new file mode 100755 >index 0000000..dec7e98 >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave.sh >new file mode 100755 >index 0000000..af56c82 >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-backup.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-backup.sh >new file mode 100755 >index 0000000..8f4cd6e >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-master.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-master.sh >new file mode 100755 >index 0000000..1db393a >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-slave.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-slave.sh >new file mode 100755 >index 0000000..1684c2f >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_error.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_error.sh >new file mode 100755 >index 0000000..e7fa43d >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_join_error.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_join_error.sh >new file mode 100755 >index 0000000..2deef4b >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_msg.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_msg.sh >new file mode 100755 >index 0000000..df31677 >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_next_step.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_next_step.sh >new file mode 100755 >index 0000000..1fe5982 >--- /dev/null >+++ b/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" >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_steps.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_steps.sh >new file mode 100755 >index 0000000..5797c13 >--- /dev/null >+++ b/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)" ] >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_start.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_start.sh >new file mode 100755 >index 0000000..03776ef >--- /dev/null >+++ b/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" >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_stop.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_stop.sh >new file mode 100755 >index 0000000..cc8e991 >--- /dev/null >+++ b/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" >-- >1.7.10.4 > > >From d15caa8a7ba731cef4b4601444331619d68ef00b Mon Sep 17 00:00:00 2001 >Message-Id: <d15caa8a7ba731cef4b4601444331619d68ef00b.1377241639.git.hahn@univention.de> >In-Reply-To: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >References: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 23 Aug 2013 08:18:36 +0200 >Subject: [PATCH 2/6] Bug #32324: USS: Fix comments >Organization: Univention GmbH, Bremen, Germany > >Fix wrong or misleading comments. >--- > .../usr/lib/univention-system-setup/scripts/setup_utils.sh | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >index 569d396..b0fb1e9 100644 >--- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >+++ b/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 >-- >1.7.10.4 > > >From d612a5b77d1118836ccf4f9b74f890c38011b223 Mon Sep 17 00:00:00 2001 >Message-Id: <d612a5b77d1118836ccf4f9b74f890c38011b223.1377241639.git.hahn@univention.de> >In-Reply-To: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >References: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 23 Aug 2013 08:18:36 +0200 >Subject: [PATCH 3/6] Bug #32324: USS: Use invoke-rc.d >Organization: Univention GmbH, Bremen, Germany > >Use invoke-rc.d to not break chroot installations. >--- > .../usr/lib/univention-system-setup/scripts/setup_utils.sh | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >index b0fb1e9..0d5417f 100644 >--- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >+++ b/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 > } >-- >1.7.10.4 > > >From bee100ff300a77a6207e3d1269af226e490ae6d2 Mon Sep 17 00:00:00 2001 >Message-Id: <bee100ff300a77a6207e3d1269af226e490ae6d2.1377241639.git.hahn@univention.de> >In-Reply-To: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >References: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 23 Aug 2013 08:18:36 +0200 >Subject: [PATCH 4/6] Bug #32324: USS: Fix shell variable quoting >Organization: Univention GmbH, Bremen, Germany > >Fix quoting of shell variables. >--- > .../univention-system-setup/scripts/setup_utils.sh | 21 +++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >index 0d5417f..9bffab5 100644 >--- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >+++ b/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 >-- >1.7.10.4 > > >From f21f84d1af191d987edde5ee56f4831ec61e3f3f Mon Sep 17 00:00:00 2001 >Message-Id: <f21f84d1af191d987edde5ee56f4831ec61e3f3f.1377241639.git.hahn@univention.de> >In-Reply-To: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >References: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 23 Aug 2013 08:18:36 +0200 >Subject: [PATCH 5/6] Bug #32324: USS: Fix ldapsearch wrapping and encoding >Organization: Univention GmbH, Bremen, Germany > >Use ldapsearch-wrapper and ldapsearch-base64. >Only retrieve "dn" from ldapsearch. >Convert 'echo "$(...)"' to '...'. >Simplify (cat|grep|sed|head)+' constructs. >--- > .../base/univention-system-setup/debian/changelog | 6 ++++++ > .../univention-system-setup/scripts/setup_utils.sh | 22 ++++++++------------ > 2 files changed, 15 insertions(+), 13 deletions(-) > >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/debian/changelog b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/debian/changelog >index fa40f38..4e8bd47 100644 >--- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/debian/changelog >+++ b/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 <hahn@univention.de> 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) >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >index 9bffab5..257f603 100644 >--- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >+++ b/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 >-- >1.7.10.4 > > >From e4146e1034b71770dc700f4bb9f334ed0e75c601 Mon Sep 17 00:00:00 2001 >Message-Id: <e4146e1034b71770dc700f4bb9f334ed0e75c601.1377241639.git.hahn@univention.de> >In-Reply-To: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >References: <7a7c0e46beca0080227ab828af4c67f7b408950f.1377241639.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 23 Aug 2013 08:18:36 +0200 >Subject: [PATCH 6/6] Bug #32324: USS: Fix local variables >Organization: Univention GmbH, Bremen, Germany > >Declare variables as local in function to prevent clobbering global >variables of the same name. >--- > .../usr/lib/univention-system-setup/scripts/setup_utils.sh | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > >diff --git a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh b/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >index 257f603..f5a24a9 100644 >--- a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/usr/lib/univention-system-setup/scripts/setup_utils.sh >+++ b/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 >-- >1.7.10.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 32324
: 5391