View | Details | Raw Unified | Return to bug 32324
Collapse All | Expand All

(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/Makefile (+4 lines)
Line 0    Link Here 
1
#!/usr/bin/make -f
2
3
test:
4
	$(MAKE) -C tests
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/Makefile (+4 lines)
Line 0    Link Here 
1
#!/usr/bin/make -f
2
3
test:
4
	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 (+10 lines)
Line 0    Link Here 
1
#!/bin/sh
2
set -e
3
4
set --
5
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
6
[ 0 -eq "$check_ldap_access" ]
7
8
set -- --check_ldap_access
9
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
10
[ 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 (+10 lines)
Line 0    Link Here 
1
#!/bin/sh
2
set -e
3
4
set --
5
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
6
[ -z "$check_ldap_availability" ]
7
8
set -- --check_ldap_availability
9
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
10
[ 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 (+17 lines)
Line 0    Link Here 
1
#!/bin/sh
2
set -e
3
4
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
5
6
profile_file=$(mktemp)
7
trap "rm -f '$profile_file'" EXIT
8
9
[ -z "$(get_profile_var)" ]
10
11
[ -z "$(get_profile_var var)" ]
12
13
echo 'var=val' >"$profile_file"
14
[ "val" = "$(get_profile_var var)" ]
15
16
rm -f "$profile_file"
17
[ -z "$(get_profile_var)" ]
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header-arg.sh (+8 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
4
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
5
6
header="$(info_header dummy msg)"
7
grep -Eq "^=== .* \([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\) ===$" <<<"$header"
8
grep -Eq "^__NAME__:.* msg$" <<<"$header"
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-info_header.sh (+8 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
4
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
5
6
header="$(info_header)"
7
grep -Eq "^=== .* \([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\) ===$" <<<"$header"
8
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 (+18 lines)
Line 0    Link Here 
1
#!/bin/sh
2
set -e
3
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
4
5
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
6
7
profile_file=$(mktemp)
8
trap "rm -f '$profile_file'" EXIT
9
10
is_variable_set || die "empty"
11
12
is_variable_set "var" || die "unset"
13
14
echo 'var=val' >"$profile_file"
15
is_variable_set "var" && die "set"
16
17
rm -f "$profile_file"
18
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 (+30 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
DOMAIN="example.com"
4
LDAP_BASE="dc=example,dc=com"
5
LDAP_FQDN="ldap.$DOMAIN"
6
HOST_DN="cn=host,$LDAP_BASE"
7
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
8
9
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
10
11
univention-config-registry () {
12
	[ "shell" = "$1" ] || exit 1
13
	shift
14
	while [ $# -ge 1 ]
15
	do
16
		case "$1" in
17
			server/role) echo 'server_role="domaincontroller_backup"' ;;
18
			ldap/base) echo "ldap_base=\"$LDAP_BASE\"" ;;
19
			ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;;
20
			ldap/hostdn) echo "ldap_hostdn=\"$HOST_DN\"" ;;
21
			*) die "$*" ;;
22
		esac
23
		shift
24
	done
25
}
26
ldapsearch () {
27
	die "$*"
28
}
29
30
[ "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 (+30 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
DOMAIN="example.com"
4
LDAP_BASE="dc=example,dc=com"
5
LDAP_FQDN="ldap.$DOMAIN"
6
HOST_DN="cn=host,$LDAP_BASE"
7
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
8
9
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
10
11
univention-config-registry () {
12
	[ "shell" = "$1" ] || exit 1
13
	shift
14
	while [ $# -ge 1 ]
15
	do
16
		case "$1" in
17
			server/role) echo 'server_role="domaincontroller_master"' ;;
18
			ldap/base) echo "ldap_base=\"$LDAP_BASE\"" ;;
19
			ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;;
20
			ldap/hostdn) echo "ldap_hostdn=\"$HOST_DN\"" ;;
21
			*) die "$*" ;;
22
		esac
23
		shift
24
	done
25
}
26
ldapsearch () {
27
	die "$*"
28
}
29
30
[ "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 (+65 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
DOMAIN="example.com"
4
LDAP_BASE="dc=example,dc=com"
5
LDAP_FQDN="ldap.$DOMAIN"
6
HOST_DN="cn=host,$LDAP_BASE"
7
USER_NAME="user mit Umlauten äöüÄÖÜß"
8
USER_DN="uid=$USER_NAME,cn=users in Bremen,$LDAP_BASE"
9
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
10
11
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
12
13
profile_file=$(mktemp)
14
trap "rm -f '$profile_file'" EXIT
15
echo "ldap_username=\"$USER_NAME\"" >"$profile_file"
16
17
univention-config-registry () {
18
	[ "shell" = "$1" ] || exit 1
19
	shift
20
	while [ $# -ge 1 ]
21
	do
22
		case "$1" in
23
			server/role) echo 'server_role="domaincontroller_slave"' ;;
24
			ldap/base) echo "dap_base=\"$LDAP_BASE\"" ;;
25
			ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;;
26
			ldap/hostdn) echo "ldap_hostdn=\"$HOST_DN\"" ;;
27
			*) die "$*" ;;
28
		esac
29
		shift
30
	done
31
}
32
ldapsearch () {
33
	while [ $# -ge 1 ]
34
	do
35
		case "$1" in
36
			-x|-Z|-ZZ|-L|-LL) ;;
37
			-D) [ "$HOST_DN" = "$2" ] || die "$*" ; shift ;;
38
			-y) [ "/etc/machine.secret" = "$2" ] || die "$*" ; shift ;;
39
			-h) [ "$LDAP_FQDN" = "$2" ] || die "$*" ; shift ;;
40
			-*) die "$*" ;;
41
			*"(uid=$USER_NAME)"*) ;;
42
			dn) ;;
43
			*) die "$*" ;;
44
		esac
45
		shift
46
	done
47
	echo -n "dn:: "
48
	echo "$USER_DN" | base64 | sed -e '2,$s/^/ /'
49
}
50
type ldapsearch-wrapper >/dev/null 2>&1 || ldapsearch-wrapper () {
51
	sed -e '1{h;$n;d;};/^[ \t]/{H;g;s/\n[ \t]//;$n;h;d;};x;${p;x;}'
52
}
53
type ldapsearch-base64 >/dev/null 2>&1 || ldapsearch-base64 () {
54
	local line
55
	while read key val
56
	do
57
		case "$key" in
58
		"") echo ;;
59
		dn::) echo "dn: $(base64 -d <<<"$val")" ;;
60
		*) die "$key"  ;;
61
		esac
62
	done
63
}
64
65
[ "$USER_DN" = "$(ldap_binddn)" ]
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_binddn-slave.sh (+56 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
DOMAIN="example.com"
4
LDAP_BASE="dc=example,dc=com"
5
LDAP_FQDN="ldap.$DOMAIN"
6
HOST_DN="cn=host,$LDAP_BASE"
7
USER_NAME="user"
8
USER_DN="uid=$USER_NAME,cn=users,$LDAP_BASE"
9
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
10
11
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
12
13
profile_file=$(mktemp)
14
trap "rm -f '$profile_file'" EXIT
15
echo "ldap_username=\"$USER_NAME\"" >"$profile_file"
16
17
univention-config-registry () {
18
	[ "shell" = "$1" ] || exit 1
19
	shift
20
	while [ $# -ge 1 ]
21
	do
22
		case "$1" in
23
			server/role) echo 'server_role="domaincontroller_slave"' ;;
24
			ldap/base) echo "ldap_base=\"$LDAP_BASE\"" ;;
25
			ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;;
26
			ldap/hostdn) echo "ldap_hostdn=\"$HOST_DN\"" ;;
27
			*) die "$*" ;;
28
		esac
29
		shift
30
	done
31
}
32
ldapsearch () {
33
	while [ $# -ge 1 ]
34
	do
35
		case "$1" in
36
			-x|-Z|-ZZ|-L|-LL) ;;
37
			-D) [ "$HOST_DN" = "$2" ] || die "$*" ; shift ;;
38
			-y) [ "/etc/machine.secret" = "$2" ] || die "$*" ; shift ;;
39
			-h) [ "$LDAP_FQDN" = "$2" ] || die "$*" ; shift ;;
40
			-*) die "$*" ;;
41
			*"(uid=$USER_NAME)"*) ;;
42
			dn) ;;
43
			*) die "$*" ;;
44
		esac
45
		shift
46
	done
47
	echo "dn: $USER_DN"
48
}
49
type ldapsearch-wrapper >/dev/null 2>&1 || ldapsearch-wrapper () {
50
	sed -e '1{h;$n;d;};/^[ \t]/{H;g;s/\n[ \t]//;$n;h;d;};x;${p;x;}'
51
}
52
ldapsearch-base64 () {
53
	/bin/cat
54
}
55
56
[ "$USER_DN" = "$(ldap_binddn)" ]
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-backup.sh (+29 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
DOMAIN="example.com"
4
LDAP_BASE="dc=example,dc=com"
5
LDAP_FQDN="ldap.$DOMAIN"
6
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
7
8
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
9
10
univention-config-registry () {
11
	[ "shell" = "$1" ] || exit 1
12
	shift
13
	while [ $# -ge 1 ]
14
	do
15
		case "$1" in
16
			ldap/base) echo "dap_base=\"$LDAP_BASE\"" ;;
17
			ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;;
18
			server/role) echo 'server_role="domaincontroller_backup"' ;;
19
			*) die "$*" ;;
20
		esac
21
		shift
22
	done
23
}
24
cat () {
25
	[ "/etc/ldap.secret" = "$1" ] || exit 1
26
	echo -n "univention"
27
}
28
29
[ "univention" = "$(ldap_bindpwd)" ]
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-master.sh (+29 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
DOMAIN="example.com"
4
LDAP_BASE="dc=example,dc=com"
5
LDAP_FQDN="ldap.$DOMAIN"
6
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
7
8
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
9
10
univention-config-registry () {
11
	[ "shell" = "$1" ] || exit 1
12
	shift
13
	while [ $# -ge 1 ]
14
	do
15
		case "$1" in
16
			ldap/base) echo "dap_base=\"$LDAP_BASE\"" ;;
17
			ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;;
18
			server/role) echo 'server_role="domaincontroller_master"' ;;
19
			*) die "$*" ;;
20
		esac
21
		shift
22
	done
23
}
24
cat () {
25
	[ "/etc/ldap.secret" = "$1" ] || exit 1
26
	echo -n "univention"
27
}
28
29
[ "univention" = "$(ldap_bindpwd)" ]
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-ldap_bindpwd-slave.sh (+32 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
DOMAIN="example.com"
4
LDAP_BASE="dc=example,dc=com"
5
LDAP_FQDN="ldap.$DOMAIN"
6
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
7
8
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
9
10
profile_file=$(mktemp)
11
trap "rm -f '$profile_file'" EXIT
12
echo 'ldap_password="univention"' >"$profile_file"
13
14
univention-config-registry () {
15
	[ "shell" = "$1" ] || exit 1
16
	shift
17
	while [ $# -ge 1 ]
18
	do
19
		case "$1" in
20
			ldap/base) echo "dap_base=\"$LDAP_BASE\"" ;;
21
			ldap/master) echo "ldap_master=\"$LDAP_FQDN\"" ;;
22
			server/role) echo 'server_role="domaincontroller_slave"' ;;
23
			*) die "$*" ;;
24
		esac
25
		shift
26
	done
27
}
28
cat () {
29
	exit 2
30
}
31
32
[ "univention" = "$(ldap_bindpwd)" ]
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_error.sh (+7 lines)
Line 0    Link Here 
1
#!/bin/sh
2
set -e
3
4
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
5
6
[ "__ERR__:" = "$(progress_error)" ]
7
[ "__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 (+7 lines)
Line 0    Link Here 
1
#!/bin/sh
2
set -e
3
4
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
5
6
[ "__JOINERR__:" = "$(progress_join_error)" ]
7
[ "__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 (+7 lines)
Line 0    Link Here 
1
#!/bin/sh
2
set -e
3
4
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
5
6
[ "__MSG__:" = "$(progress_msg)" ]
7
[ "__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 (+16 lines)
Line 0    Link Here 
1
#!/bin/sh
2
set -e
3
4
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
5
6
tmp=$(mktemp)
7
trap "rm -f '$tmp'" EXIT
8
9
progress_next_step >"$tmp"
10
grep -Fq '__STEP__:' "$tmp"
11
progress_next_step >"$tmp"
12
grep -Fq '__STEP__:1' "$tmp"
13
progress_next_step 42 >"$tmp"
14
grep -Fq '__STEP__:42' "$tmp"
15
progress_next_step >"$tmp"
16
grep -Fq '__STEP__:42' "$tmp"
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-progress_steps.sh (+7 lines)
Line 0    Link Here 
1
#!/bin/sh
2
set -e
3
4
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
5
6
[ "__STEPS__:" = "$(progress_steps)" ]
7
[ "__STEPS__:42" = "$(progress_steps 42)" ]
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_start.sh (+12 lines)
Line 0    Link Here 
1
#!/bin/bash
2
set -e
3
SERVICE="../../bin/true"
4
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
5
6
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
7
8
invoke-rc.d () {
9
	[ "$SERVICE" = "$1" ] || die "$*"
10
	[ "start" = "$2" ] || die "$*"
11
}
12
service_start "$SERVICE"
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/tests/setup_utils-setvice_stop.sh (-2 / +12 lines)
Line 0    Link Here 
0
- 
1
#!/bin/bash
1
--
2
set -e
3
SERVICE="../../bin/true"
4
die () { echo "${FUNCNAME[*]}: $*" >&2; exit 2; }
5
6
. ../usr/lib/univention-system-setup/scripts/setup_utils.sh
7
8
invoke-rc.d () {
9
	[ "$SERVICE" = "$1" ] || die "$*"
10
	[ "stop" = "$2" ] || die "$*"
11
}
12
service_stop "$SERVICE"
2
.../usr/lib/univention-system-setup/scripts/setup_utils.sh         |    4 ++--
13
.../usr/lib/univention-system-setup/scripts/setup_utils.sh         |    4 ++--
3
1 file changed, 2 insertions(+), 2 deletions(-)
14
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 (-4 / +2 lines)
 Lines 53-59   do Link Here 
53
done
53
done
54
54
55
# writes an info header
55
# writes an info header
56
# @param  script path
56
# @param  script path (unused)
57
# @param  description (optional)
57
# @param  description (optional)
58
info_header()
58
info_header()
59
{
59
{
 Lines 111-117   progress_next_step() Link Here 
111
}
111
}
112
112
113
is_variable_set()
113
is_variable_set()
114
{
114
{ # INVERTED return code: returns '1' if found, '0' if not
115
	if [ ! -e $profile_file ]; then
115
	if [ ! -e $profile_file ]; then
116
		return 0
116
		return 0
117
	fi
117
	fi
118
- 
119
--
120
.../usr/lib/univention-system-setup/scripts/setup_utils.sh         |    4 ++--
118
.../usr/lib/univention-system-setup/scripts/setup_utils.sh         |    4 ++--
121
1 file changed, 2 insertions(+), 2 deletions(-)
119
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 (-4 / +2 lines)
 Lines 144-150   service_stop () Link Here 
144
{
144
{
145
	for service in $@; do
145
	for service in $@; do
146
		if [ -x /etc/init.d/$service ]; then
146
		if [ -x /etc/init.d/$service ]; then
147
			/etc/init.d/$service stop
147
			invoke-rc.d "$service" stop
148
		fi
148
		fi
149
	done
149
	done
150
}
150
}
 Lines 152-158   service_start () Link Here 
152
{
152
{
153
	for service in $@; do
153
	for service in $@; do
154
		if [ -x /etc/init.d/$service ]; then
154
		if [ -x /etc/init.d/$service ]; then
155
			/etc/init.d/$service start
155
			invoke-rc.d "$service" start
156
		fi
156
		fi
157
	done
157
	done
158
}
158
}
159
- 
160
--
161
.../univention-system-setup/scripts/setup_utils.sh |   21 +++++++++++---------
159
.../univention-system-setup/scripts/setup_utils.sh |   21 +++++++++++---------
162
1 file changed, 12 insertions(+), 9 deletions(-)
160
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 (-11 / +12 lines)
 Lines 57-70   done Link Here 
57
# @param  description (optional)
57
# @param  description (optional)
58
info_header()
58
info_header()
59
{
59
{
60
	_path=$(readlink -m "$0")
60
	_path="$(readlink -m "$0")"
61
	script="${_path##*scripts/}"
61
	script="${_path##*scripts/}"
62
	echo "=== $script ($(date +'%Y-%m-%d %H:%M:%S')) ==="
62
	echo "=== $script ($(date +'%Y-%m-%d %H:%M:%S')) ==="
63
63
64
	# information for the internal progress handler
64
	# information for the internal progress handler
65
	# print the name of the script... if not specified the script name
65
	# print the name of the script... if not specified the script name
66
	name="$2"
66
	name="${2:-$script}"
67
	[ -z "$name" ] && name="$script"
68
	echo "__NAME__:$script $name"
67
	echo "__NAME__:$script $name"
69
}
68
}
70
69
 Lines 112-118   progress_next_step() Link Here 
112
111
113
is_variable_set()
112
is_variable_set()
114
{ # INVERTED return code: returns '1' if found, '0' if not
113
{ # INVERTED return code: returns '1' if found, '0' if not
115
	if [ ! -e $profile_file ]; then
114
	if [ ! -e "$profile_file" ]; then
116
		return 0
115
		return 0
117
	fi
116
	fi
118
117
 Lines 128-134   is_variable_set() Link Here 
128
}
127
}
129
get_profile_var ()
128
get_profile_var ()
130
{
129
{
131
	if [ ! -e $profile_file ]; then
130
	if [ ! -e "$profile_file" ]; then
132
		return
131
		return
133
	fi
132
	fi
134
133
 Lines 142-157   get_profile_var () Link Here 
142
141
143
service_stop ()
142
service_stop ()
144
{
143
{
145
	for service in $@; do
144
	for service in "$@"
146
		if [ -x /etc/init.d/$service ]; then
145
	do
146
		if [ -x "/etc/init.d/$service" ]
147
		then
147
			invoke-rc.d "$service" stop
148
			invoke-rc.d "$service" stop
148
		fi
149
		fi
149
	done
150
	done
150
}
151
}
151
service_start ()
152
service_start ()
152
{
153
{
153
	for service in $@; do
154
	for service in "$@"
154
		if [ -x /etc/init.d/$service ]; then
155
	do
156
		if [ -x "/etc/init.d/$service" ]
157
		then
155
			invoke-rc.d "$service" start
158
			invoke-rc.d "$service" start
156
		fi
159
		fi
157
	done
160
	done
158
- 
159
--
160
.../base/univention-system-setup/debian/changelog  |    6 ++++++
161
.../base/univention-system-setup/debian/changelog  |    6 ++++++
161
.../univention-system-setup/scripts/setup_utils.sh |   22 ++++++++------------
162
.../univention-system-setup/scripts/setup_utils.sh |   22 ++++++++------------
162
2 files changed, 15 insertions(+), 13 deletions(-)
163
2 files changed, 15 insertions(+), 13 deletions(-)
(-)a/branches/ucs-3.2/ucs-3.2-0/base/univention-system-setup/debian/changelog (+6 lines)
 Lines 1-3    Link Here 
1
univention-system-setup (7.0.29-1) unstable; urgency=low
2
3
  * Fix ldapsearch wrapping and encoding (Bug #32324)
4
5
 -- Philipp Hahn <hahn@univention.de>  Fri, 23 Aug 2013 08:18:04 +0200
6
1
univention-system-setup (7.0.28-1) unstable; urgency=low
7
univention-system-setup (7.0.28-1) unstable; urgency=low
2
8
3
  * Revert second half of change of 7.0.26-1 (Bug #31960)
9
  * 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 (-15 / +9 lines)
 Lines 118-129   is_variable_set() Link Here 
118
	if [ -z "$1" ]; then
118
	if [ -z "$1" ]; then
119
		return 0
119
		return 0
120
	fi
120
	fi
121
	value=`egrep "^$1=" $profile_file `
121
	! egrep -q "^$1=" "$profile_file"
122
	if [ -z "$value" ]; then
123
		return 0
124
	else
125
		return 1
126
	fi
127
}
122
}
128
get_profile_var ()
123
get_profile_var ()
129
{
124
{
 Lines 135-142   get_profile_var () Link Here 
135
		return
130
		return
136
	fi
131
	fi
137
132
138
	value=`egrep "^$1=" $profile_file |sed -e 's|#.*||' | sed -e "s|^$1=||" | sed -e 's|"||g;s| $||g'`
133
	sed -rne "s/^$1=//;T;s/#.*//;s/([\"'])(.*)\1 *$/\2/;p;q" "$profile_file"
139
	echo "$value"
140
}
134
}
141
135
142
service_stop ()
136
service_stop ()
 Lines 166-175   ldap_binddn () Link Here 
166
	if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then
160
	if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then
167
		echo "cn=admin,$ldap_base"
161
		echo "cn=admin,$ldap_base"
168
	else
162
	else
169
		ldap_username=`get_profile_var ldap_username`
163
		ldap_username="$(get_profile_var ldap_username)"
170
		if [ -n "$ldap_username" ]; then
164
		if [ -n "$ldap_username" ]; then
171
			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`
165
			ldapsearch -x -ZZ -D "$ldap_hostdn" -y /etc/machine.secret -h "$ldap_master" "(&(objectClass=person)(uid=$ldap_username))" dn |
172
			echo "$dn"
166
			ldapsearch-wrapper |
167
			ldapsearch-base64 |
168
			sed -ne 's|^dn: ||;T;p;q'
173
		fi
169
		fi
174
	fi
170
	fi
175
}
171
}
 Lines 178-186   ldap_bindpwd () Link Here 
178
{
174
{
179
	eval "$(univention-config-registry shell server/role ldap/base ldap/master)"
175
	eval "$(univention-config-registry shell server/role ldap/base ldap/master)"
180
	if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then
176
	if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then
181
		echo "`cat /etc/ldap.secret`"
177
		cat /etc/ldap.secret
182
	else
178
	else
183
		ldap_password=`get_profile_var ldap_password`
179
		ldap_password="$(get_profile_var ldap_password)"
184
		if [ -n "$ldap_password" ]; then
180
		if [ -n "$ldap_password" ]; then
185
			echo "$ldap_password"
181
			echo "$ldap_password"
186
		fi
182
		fi
187
- 
188
--
189
.../usr/lib/univention-system-setup/scripts/setup_utils.sh      |    7 ++++++-
183
.../usr/lib/univention-system-setup/scripts/setup_utils.sh      |    7 ++++++-
190
1 file changed, 6 insertions(+), 1 deletion(-)
184
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 (-2 / +6 lines)
 Lines 57-62   done Link Here 
57
# @param  description (optional)
57
# @param  description (optional)
58
info_header()
58
info_header()
59
{
59
{
60
	local _path _script name
60
	_path="$(readlink -m "$0")"
61
	_path="$(readlink -m "$0")"
61
	script="${_path##*scripts/}"
62
	script="${_path##*scripts/}"
62
	echo "=== $script ($(date +'%Y-%m-%d %H:%M:%S')) ==="
63
	echo "=== $script ($(date +'%Y-%m-%d %H:%M:%S')) ==="
 Lines 135-140   get_profile_var () Link Here 
135
136
136
service_stop ()
137
service_stop ()
137
{
138
{
139
	local service
138
	for service in "$@"
140
	for service in "$@"
139
	do
141
	do
140
		if [ -x "/etc/init.d/$service" ]
142
		if [ -x "/etc/init.d/$service" ]
 Lines 145-150   service_stop () Link Here 
145
}
147
}
146
service_start ()
148
service_start ()
147
{
149
{
150
	local service
148
	for service in "$@"
151
	for service in "$@"
149
	do
152
	do
150
		if [ -x "/etc/init.d/$service" ]
153
		if [ -x "/etc/init.d/$service" ]
 Lines 156-161   service_start () Link Here 
156
159
157
ldap_binddn ()
160
ldap_binddn ()
158
{
161
{
162
	local server_role ldap_base ldap_master ldap_hostdn ldap_username
159
	eval "$(univention-config-registry shell server/role ldap/base ldap/master ldap/hostdn)"
163
	eval "$(univention-config-registry shell server/role ldap/base ldap/master ldap/hostdn)"
160
	if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then
164
	if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then
161
		echo "cn=admin,$ldap_base"
165
		echo "cn=admin,$ldap_base"
 Lines 172-178   ldap_binddn () Link Here 
172
176
173
ldap_bindpwd ()
177
ldap_bindpwd ()
174
{
178
{
175
	eval "$(univention-config-registry shell server/role ldap/base ldap/master)"
179
	local server_role ldap_password
180
	eval "$(univention-config-registry shell server/role)"
176
	if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then
181
	if [ "$server_role" = "domaincontroller_master" ] || [ "$server_role" = "domaincontroller_backup" ]; then
177
		cat /etc/ldap.secret
182
		cat /etc/ldap.secret
178
	else
183
	else
179
- 

Return to bug 32324