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

(-)a/services/univention-samba4/96univention-samba4.inst (-35 / +34 lines)
 Lines 209-228   stop_conflicting_services() { Link Here 
209
		fi
209
		fi
210
	fi
210
	fi
211
211
212
	tmp_ucr_key_value_list=()
212
	declare -a tmp_ucr_key_value_list=()
213
	if [ "$samba_autostart" != "no" ]; then
213
	if [ "$samba_autostart" != "no" ]; then
214
			tmp_ucr_key_value_list[0]="samba/autostart=no"
214
		tmp_ucr_key_value_list+=("samba/autostart=no")
215
	fi
215
	fi
216
	if [ "$winbind_autostart" != "no" ]; then
216
	if [ "$winbind_autostart" != "no" ]; then
217
			tmp_ucr_key_value_list[${#tmp_ucr_key_value_list[@]}]="winbind/autostart=no"
217
		tmp_ucr_key_value_list+=("winbind/autostart=no")
218
	fi
218
	fi
219
	if [ "$kerberos_autostart" != "no" ]; then
219
	if [ "$kerberos_autostart" != "no" ]; then
220
			tmp_ucr_key_value_list[${#tmp_ucr_key_value_list[@]}]="kerberos/autostart=no"
220
		tmp_ucr_key_value_list+=("kerberos/autostart=no")
221
	fi
221
	fi
222
	if [ -n "$tmp_ucr_key_value_list" ]; then
222
	if [ -n "$tmp_ucr_key_value_list" ]; then
223
		univention-config-registry set "${tmp_ucr_key_value_list[@]}"
223
		univention-config-registry set "${tmp_ucr_key_value_list[@]}"
224
	fi
224
	fi
225
	unset tmp_ucr_key_value_list
226
}
225
}
227
226
228
get_samba_role() {
227
get_samba_role() {
 Lines 309-319   samba_domain_join() { Link Here 
309
		fi
308
		fi
310
	else
309
	else
311
310
312
		# Let's try to join against the S4 Connector 
311
		# Let's try to join against the S4 Connector
313
		s4connector_dc=$(ldapsearch -x -ZZ -LLL -D "$ldap_hostdn" -y /etc/machine.secret \
312
		s4connector_dc=$(ldapsearch -x -ZZ -LLLo ldif-wrap=no -D "$ldap_hostdn" -y /etc/machine.secret \
314
			"(&(univentionService=S4 Connector)(objectClass=univentionDomainController)(!(univentionService=S4 SlavePDC)))" cn \
313
			"(&(univentionService=S4 Connector)(objectClass=univentionDomainController)(!(univentionService=S4 SlavePDC)))" cn \
315
			| ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p')
314
			| sed -n 's/^cn: //p')
316
	
315
317
		if [ -n "$s4connector_dc" ]; then
316
		if [ -n "$s4connector_dc" ]; then
318
			echo "Join against S4 Connector server: $s4connector_dc"
317
			echo "Join against S4 Connector server: $s4connector_dc"
319
			if samba-tool domain info "$s4connector_dc.$domainname"; then
318
			if samba-tool domain info "$s4connector_dc.$domainname"; then
 Lines 343-351   samba_domain_join() { Link Here 
343
342
344
		if [ -z "$success" ]; then
343
		if [ -z "$success" ]; then
345
			# try again with --server
344
			# try again with --server
346
			cn=($(ldapsearch -x -ZZ -LLL -D "$ldap_hostdn" -y /etc/machine.secret \
345
			cn=($(ldapsearch -x -ZZ -LLLo ldif-wrap=no -D "$ldap_hostdn" -y /etc/machine.secret \
347
						"(&(univentionService=Samba 4)(objectClass=univentionDomainController))" cn \
346
						"(&(univentionService=Samba 4)(objectClass=univentionDomainController))" cn \
348
										| ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p' ))
347
						| sed -n 's/^cn: //p' ))
349
			for name in "${cn[@]}"; do
348
			for name in "${cn[@]}"; do
350
				if samba-tool domain info "$name.$domainname"; then
349
				if samba-tool domain info "$name.$domainname"; then
351
					samba-tool domain join "$domainname" "$samba4_role" --server "$name.$domainname" "${samba_join_options[@]}"
350
					samba-tool domain join "$domainname" "$samba4_role" --server "$name.$domainname" "${samba_join_options[@]}"
 Lines 392-398   disable_slapd_on_standard_port() { Link Here 
392
}
391
}
393
392
394
backup_samba4_keytab() {
393
backup_samba4_keytab() {
395
	pre_join_kvno=$(ldbsearch -H /var/lib/samba/private/sam.ldb sAMAccountName="$hostname\$" msDS-KeyVersionNumber | sed -n 's/^msDS-KeyVersionNumber: \(.*\)/\1/p')
394
	pre_join_kvno=$(ldbsearch -H /var/lib/samba/private/sam.ldb sAMAccountName="$hostname\$" msDS-KeyVersionNumber | sed -n 's/^msDS-KeyVersionNumber: //p')
396
	if [ -n "$pre_join_kvno" ]; then
395
	if [ -n "$pre_join_kvno" ]; then
397
		if ! [ -f /etc/krb5.keytab ]; then
396
		if ! [ -f /etc/krb5.keytab ]; then
398
			## usually the keytab is removed during 03univention-directory-listener.inst
397
			## usually the keytab is removed during 03univention-directory-listener.inst
 Lines 416-422   backup_samba4_keytab() { Link Here 
416
415
417
merge_backup_samba4_keytab() {
416
merge_backup_samba4_keytab() {
418
	if [ -n "$pre_join_kvno" ] && [ -f "$backup_dir/krb5.keytab" ]; then
417
	if [ -n "$pre_join_kvno" ] && [ -f "$backup_dir/krb5.keytab" ]; then
419
		post_join_kvno=$(ldbsearch -H /var/lib/samba/private/sam.ldb sAMAccountName="$hostname\$" msDS-KeyVersionNumber | sed -n 's/^msDS-KeyVersionNumber: \(.*\)/\1/p')
418
		post_join_kvno=$(ldbsearch -H /var/lib/samba/private/sam.ldb sAMAccountName="$hostname\$" msDS-KeyVersionNumber | sed -n 's/^msDS-KeyVersionNumber: //p')
420
		if [ "$post_join_kvno" -gt "$pre_join_kvno" ]; then
419
		if [ "$post_join_kvno" -gt "$pre_join_kvno" ]; then
421
			tmp_krb5_keytab=$(mktemp)
420
			tmp_krb5_keytab=$(mktemp)
422
			cp "$backup_dir/krb5.keytab" "$tmp_krb5_keytab"
421
			cp "$backup_dir/krb5.keytab" "$tmp_krb5_keytab"
 Lines 461-468   set_default_fACL() { Link Here 
461
register_server_ips_with_domain() {
460
register_server_ips_with_domain() {
462
	zone="$(udm dns/forward_zone list "$@" --filter zoneName="$domainname" | sed -ne 's|^DN: ||p')"
461
	zone="$(udm dns/forward_zone list "$@" --filter zoneName="$domainname" | sed -ne 's|^DN: ||p')"
463
	if [ -n "$zone" ]; then
462
	if [ -n "$zone" ]; then
464
		IPs=$(univention-ldapsearch "(&(relativeDomainname=$hostname)(zoneName=$domainname))" aRecord aAAARecord \
463
		IPs=$(univention-ldapsearch -LLLo ldif-wrap=no "(&(relativeDomainname=$hostname)(zoneName=$domainname))" aRecord aAAARecord \
465
		      | ldapsearch-wrapper | sed -ne 's|^aRecord: ||p;s|^aAAARecord: ||p')
464
		      | sed -ne 's|^aRecord: ||p;s|^aAAARecord: ||p')
466
		for ip in $IPs; do
465
		for ip in $IPs; do
467
			udm dns/forward_zone modify "$@" --ignore_exists --dn "$zone" --append a="$ip"
466
			udm dns/forward_zone modify "$@" --ignore_exists --dn "$zone" --append a="$ip"
468
		done
467
		done
 Lines 472-480   register_server_ips_with_domain() { Link Here 
472
set_samba4_sysvol_sync_host() {
471
set_samba4_sysvol_sync_host() {
473
	## determine default sysvol parent for this host from univentionService="S4 Connector"
472
	## determine default sysvol parent for this host from univentionService="S4 Connector"
474
	if [ -z "$samba4_sysvol_sync_host" ]; then
473
	if [ -z "$samba4_sysvol_sync_host" ]; then
475
		s4connectorservicedcs=$(ldapsearch -x -ZZ -LLL -D "$ldap_hostdn" -y /etc/machine.secret \
474
		s4connectorservicedcs=$(ldapsearch -x -ZZ -LLLo ldif-wrap=no -D "$ldap_hostdn" -y /etc/machine.secret \
476
			"(&(univentionService=S4 Connector)(objectClass=univentionDomainController)(!(univentionService=S4 SlavePDC)))" cn \
475
			"(&(univentionService=S4 Connector)(objectClass=univentionDomainController)(!(univentionService=S4 SlavePDC)))" cn \
477
								| ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p')      ## currently there is no u-d-m module computers/dc
476
								| sed -n 's/^cn: //p')      ## currently there is no u-d-m module computers/dc
478
		if [ -n "$s4connectorservicedcs" ]; then
477
		if [ -n "$s4connectorservicedcs" ]; then
479
			univention-config-registry set samba4/sysvol/sync/host="$s4connectorservicedcs"
478
			univention-config-registry set samba4/sysvol/sync/host="$s4connectorservicedcs"
480
		fi
479
		fi
 Lines 521-527   get_available_s4connector_dc() { Link Here 
521
	local s4connector_dc
520
	local s4connector_dc
522
	local s4connector_dc_candidates
521
	local s4connector_dc_candidates
523
	s4connector_dc=()
522
	s4connector_dc=()
524
	s4connector_dc_candidates=$(univention-ldapsearch "(&(univentionService=S4 Connector)(objectClass=univentionDomainController))" cn | ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p')
523
	s4connector_dc_candidates=$(univention-ldapsearch -LLLo ldif-wrap=no "(&(univentionService=S4 Connector)(objectClass=univentionDomainController))" cn | sed -n 's/^cn: //p')
525
	if univention-ldapsearch -LLL univentionservice=UCS@school dn | grep -q ^dn; then
524
	if univention-ldapsearch -LLL univentionservice=UCS@school dn | grep -q ^dn; then
526
		for dc in "${s4connector_dc_candidates[@]}"; do
525
		for dc in "${s4connector_dc_candidates[@]}"; do
527
			if samba-tool drs showrepl "$dc" >/dev/null 2>&1; then
526
			if samba-tool drs showrepl "$dc" >/dev/null 2>&1; then
 Lines 547-553   wait_until_dc_was_replicated_to_connector_dc() { Link Here 
547
546
548
	echo -n "Waiting for DRS replication: "
547
	echo -n "Waiting for DRS replication: "
549
	for((i=0;i<300;i++)); do
548
	for((i=0;i<300;i++)); do
550
		search_result="$(ldbsearch -H "ldap://$s4connector_dc" -U"${hostname}$"%"$(</etc/machine.secret)" "(&(objectClass=computer)(cn=${hostname}))" cn 2>/dev/null| sed -n 's/^cn: \(.*\)/\1/p')"
549
		search_result="$(ldbsearch -H "ldap://$s4connector_dc" -U"${hostname}$"%"$(</etc/machine.secret)" "(&(objectClass=computer)(cn=${hostname}))" cn 2>/dev/null| sed -n 's/^cn: //p')"
551
		test -n "$search_result" && break
550
		test -n "$search_result" && break
552
		echo -n "."
551
		echo -n "."
553
		sleep 1
552
		sleep 1
 Lines 645-652   _create_group_with_special_sid() Link Here 
645
	local ldif
644
	local ldif
646
645
647
	shift 3
646
	shift 3
648
	
647
649
	group_dn="$(univention-ldapsearch "(&(objectClass=univentionGroup)(cn=$name))" | ldapsearch-wrapper | sed -ne 's|dn: ||p')"
648
	group_dn="$(univention-ldapsearch -LLLo ldif-wrap=no "(&(objectClass=univentionGroup)(cn=$name))" dn | sed -ne 's|^dn: ||p')"
650
649
651
	if [ -z "$group_dn" ]; then
650
	if [ -z "$group_dn" ]; then
652
651
 Lines 683-690   univentionSamba4SID: $sid Link Here 
683
"
682
"
684
		fi
683
		fi
685
684
686
		echo "$ldif" | ldapmodify -x -h "$ldap_master" -p "${ldap_master_port:-7389}" -D "$binddn" -w "$bindpwd" 
685
		echo "$ldif" | ldapmodify -x -h "$ldap_master" -p "${ldap_master_port:-7389}" -D "$binddn" -w "$bindpwd"
687
		
686
688
		if [ "$name" = "Authenticated Users" ]; then
687
		if [ "$name" = "Authenticated Users" ]; then
689
			udm groups/group modify "$@" --dn "cn=$name,$position,$ldap_base" \
688
			udm groups/group modify "$@" --dn "cn=$name,$position,$ldap_base" \
690
				--append nestedGroup="cn=DC Slave Hosts,cn=groups,$ldap_base" \
689
				--append nestedGroup="cn=DC Slave Hosts,cn=groups,$ldap_base" \
 Lines 742-749   _update_pseudo_group() Link Here 
742
	local name="$1"
741
	local name="$1"
743
742
744
	shift 1
743
	shift 1
745
	
744
746
	group_dn="$(univention-ldapsearch "(&(objectClass=univentionGroup)(cn=$name)(!(univentionGroupType=-2147483643)))" | ldapsearch-wrapper | sed -ne 's|dn: ||p')"
745
	group_dn="$(univention-ldapsearch -LLLo ldif-wrap=no "(&(objectClass=univentionGroup)(cn=$name)(!(univentionGroupType=-2147483643)))" | sed -ne 's|^dn: ||p')"
747
746
748
	if [ -n "$group_dn" ]; then
747
	if [ -n "$group_dn" ]; then
749
		extract_binddn_and_bindpwd_from_args "$@"
748
		extract_binddn_and_bindpwd_from_args "$@"
 Lines 759-765   add: univentionGroupType Link Here 
759
univentionGroupType: -2147483643
758
univentionGroupType: -2147483643
760
-
759
-
761
replace: sambaGroupType
760
replace: sambaGroupType
762
sambaGroupType: 5" | ldapmodify -x -h "$ldap_master" -p "${ldap_master_port:-7389}" -D "$binddn" -w "$bindpwd" 
761
sambaGroupType: 5" | ldapmodify -x -h "$ldap_master" -p "${ldap_master_port:-7389}" -D "$binddn" -w "$bindpwd"
763
	fi
762
	fi
764
}
763
}
765
764
 Lines 784-792   exit_on_slave_if_no_s4_connector_on_master_or_backup() Link Here 
784
	if [ "$server_role" != "domaincontroller_slave" ]; then
783
	if [ "$server_role" != "domaincontroller_slave" ]; then
785
		return
784
		return
786
	fi
785
	fi
787
	s4connectorservicedcs=$(ldapsearch -x -ZZ -LLL -D "$ldap_hostdn" -y /etc/machine.secret \
786
	s4connectorservicedcs=$(ldapsearch -x -ZZ -LLLo ldif-wrap=no -D "$ldap_hostdn" -y /etc/machine.secret \
788
		"(&(univentionService=S4 Connector)(|(univentionServerRole=master)(univentionServerRole=backup)))" cn \
787
		"(&(univentionService=S4 Connector)(|(univentionServerRole=master)(univentionServerRole=backup)))" cn \
789
		| ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p')
788
		| sed -n 's/^cn: //p')
790
	if [ -z "$s4connectorservicedcs" ]; then
789
	if [ -z "$s4connectorservicedcs" ]; then
791
		echo "ERROR: No S4 Connector installed yet on DC Master or DC Backup."
790
		echo "ERROR: No S4 Connector installed yet on DC Master or DC Backup."
792
		exit 1
791
		exit 1
 Lines 802-809   exit_on_slave_if_no_s4_connector_on_master_or_backup Link Here 
802
801
803
extract_binddn_and_bindpwd_from_args "$@"
802
extract_binddn_and_bindpwd_from_args "$@"
804
if [ -n "$binddn" ]; then
803
if [ -n "$binddn" ]; then
805
	dcaccount=$(ldapsearch -xLLL -ZZ -D "$ldap_hostdn" -y /etc/machine.secret \
804
	dcaccount=$(ldapsearch -xLLLo ldif-wrap=no -ZZ -D "$ldap_hostdn" -y /etc/machine.secret \
806
	             -s base -b "$binddn" uid | ldapsearch-wrapper | sed -n 's/^uid: //p')
805
	             -s base -b "$binddn" uid | sed -n 's/^uid: //p')
807
fi
806
fi
808
807
809
configure_samba_role
808
configure_samba_role
 Lines 864-876   if [ "$samba4_role" = 'DC' ]; then Link Here 
864
	fi
863
	fi
865
864
866
	## check if we there already is a **domaincontroller** providing the service "Samba 4"
865
	## check if we there already is a **domaincontroller** providing the service "Samba 4"
867
	samba4servicedcs=$(ldapsearch -x -ZZ -LLL -D "$ldap_hostdn" -y /etc/machine.secret \
866
	samba4servicedcs=$(ldapsearch -x -ZZ -LLLo ldif-wrap=no -D "$ldap_hostdn" -y /etc/machine.secret \
868
	                   "(&(univentionService=${NAME})(objectClass=univentionDomainController))" cn \
867
	                   "(&(univentionService=${NAME})(objectClass=univentionDomainController))" cn \
869
					   | ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p')	## currently there is no u-d-m module computers/dc
868
					   | sed -n 's/^cn: //p')	## currently there is no u-d-m module computers/dc
870
869
871
	s4connector_is_used=$(ldapsearch -x -ZZ -LLL -D "$ldap_hostdn" -y /etc/machine.secret \
870
	s4connector_is_used=$(ldapsearch -x -ZZ -LLLo ldif-wrap=no -D "$ldap_hostdn" -y /etc/machine.secret \
872
	                   "(&(univentionService=S4 Connector)(objectClass=univentionDomainController)(cn=$hostname))" cn \
871
	                   "(&(univentionService=S4 Connector)(objectClass=univentionDomainController)(cn=$hostname))" cn \
873
					   | ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p')
872
					   | sed -n 's/^cn: //p')
874
873
875
	/etc/init.d/samba stop
874
	/etc/init.d/samba stop
876
875
 Lines 1149-1155   fi Link Here 
1149
1148
1150
/etc/init.d/samba restart
1149
/etc/init.d/samba restart
1151
1150
1152
# To prevent a DRS replication conflict: 
1151
# To prevent a DRS replication conflict:
1153
#  https://forge.univention.org/bugzilla/show_bug.cgi?id=32257
1152
#  https://forge.univention.org/bugzilla/show_bug.cgi?id=32257
1154
wait_until_dc_was_replicated_to_connector_dc
1153
wait_until_dc_was_replicated_to_connector_dc
1155
1154
(-)a/services/univention-samba4/98univention-samba4-dns.inst (-1 / +1 lines)
 Lines 74-80   if [ $JS_LAST_EXECUTED_VERSION -lt 1 ]; then Link Here 
74
fi
74
fi
75
75
76
# Change the dns/backend to samba4 only whether a S4 Connector is installed in our domain
76
# Change the dns/backend to samba4 only whether a S4 Connector is installed in our domain
77
s4connectorservicedcs="$(ldapsearch -x -ZZ -LLL -D "$ldap_hostdn" -y /etc/machine.secret "(&(univentionService=S4 Connector)(objectClass=univentionDomainController))" cn | ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p')"
77
s4connectorservicedcs="$(ldapsearch -x -ZZ -LLLo ldif-wrap=no -D "$ldap_hostdn" -y /etc/machine.secret "(&(univentionService=S4 Connector)(objectClass=univentionDomainController))" cn | sed -n 's/^cn: //p')"
78
78
79
if [ $JS_LAST_EXECUTED_VERSION = 0 ] && [ "$dns_backend" != "samba4" ] && [ -n "$s4connectorservicedcs" ]; then
79
if [ $JS_LAST_EXECUTED_VERSION = 0 ] && [ "$dns_backend" != "samba4" ] && [ -n "$s4connectorservicedcs" ]; then
80
	univention-config-registry set dns/backend=samba4
80
	univention-config-registry set dns/backend=samba4
(-)a/services/univention-samba4/debian/univention-samba4.postinst (-10 / +9 lines)
 Lines 187-202   divert_univention_heimdal_service_cfg() { Link Here 
187
187
188
if [ "$1" = "configure" ]; then
188
if [ "$1" = "configure" ]; then
189
189
190
191
	if [ -z "$2" ]; then
190
	if [ -z "$2" ]; then
192
    		univention-config-registry set samba4/autostart="no"
191
		univention-config-registry set samba4/autostart="no"
193
192
194
		# only set this for new installations
193
		# only set this for new installations
195
		if [ "$server_role" = "domaincontroller_master" ]; then
194
		if [ "$server_role" = "domaincontroller_master" ]; then
196
			univention-config-registry set samba/domain/master?yes
195
			univention-config-registry set samba/domain/master?yes
197
		fi
196
		fi
198
197
199
		## New installation, remove leftover samba3.x rc?.d links 
198
		## New installation, remove leftover samba3.x rc?.d links
200
		update-rc.d -f samba remove > /dev/null
199
		update-rc.d -f samba remove > /dev/null
201
200
202
		divert_univention_heimdal_service_cfg
201
		divert_univention_heimdal_service_cfg
 Lines 248-261   secret: $machine_secret Link Here 
248
				fi
247
				fi
249
			fi
248
			fi
250
		fi
249
		fi
251
		
250
252
		### The following block of code may be removed after ucs_3.2-0
251
		### The following block of code may be removed after ucs_3.2-0
253
		if dpkg --compare-versions "$2" lt-nl "2.0.44-24"; then
252
		if dpkg --compare-versions "$2" lt-nl "2.0.44-24"; then
254
			default_domain_gpo_dir="/var/lib/samba/sysvol/$domainname/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}"
253
			default_domain_gpo_dir="/var/lib/samba/sysvol/$domainname/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}"
255
			if [ -d "$default_domain_gpo_dir" ]; then
254
			if [ -d "$default_domain_gpo_dir" ]; then
256
				gpo_dir_owner=$(stat --printf '%U' "$default_domain_gpo_dir" 2>&1)
255
				gpo_dir_owner=$(stat --printf '%U' "$default_domain_gpo_dir" 2>&1)
257
				if [ "$gpo_dir_owner" = "UNKNOWN" ]; then
256
				if [ "$gpo_dir_owner" = "UNKNOWN" ]; then
258
					samba-tool ntacl sysvolreset 
257
					samba-tool ntacl sysvolreset
259
				fi
258
				fi
260
			fi
259
			fi
261
		fi
260
		fi
 Lines 284-294   secret: $machine_secret Link Here 
284
				backup_dir="/var/backups/samba4.$backup_id"
283
				backup_dir="/var/backups/samba4.$backup_id"
285
				if [ -d "$backup_dir" ]; then
284
				if [ -d "$backup_dir" ]; then
286
					rm -rf "$backup_dir"
285
					rm -rf "$backup_dir"
287
 				fi
286
				fi
288
				mkdir "$backup_dir" && \
287
				mkdir "$backup_dir" && \
289
				cp -a /var/lib/samba/private "$backup_dir" && \
288
				cp -a /var/lib/samba/private "$backup_dir" && \
290
				samba-tool dbcheck --cross-ncs --fix --yes
289
				samba-tool dbcheck --cross-ncs --fix --yes
291
 			fi
290
			fi
292
291
293
			if ! [ -r "/etc/krb5.keytab" ]; then
292
			if ! [ -r "/etc/krb5.keytab" ]; then
294
				echo "/etc/krb5.keytab does not exist yet."
293
				echo "/etc/krb5.keytab does not exist yet."
 Lines 321-333   secret: $machine_secret Link Here 
321
				backup_dir="/var/backups/samba4_update_to_ucs4.1-4.$backup_id"
320
				backup_dir="/var/backups/samba4_update_to_ucs4.1-4.$backup_id"
322
				if [ -d "$backup_dir" ]; then
321
				if [ -d "$backup_dir" ]; then
323
					rm -rf "$backup_dir"
322
					rm -rf "$backup_dir"
324
 				fi
323
				fi
325
				service samba stop
324
				service samba stop
326
				mkdir "$backup_dir" && \
325
				mkdir "$backup_dir" && \
327
				cp -a /var/lib/samba/private "$backup_dir" && \
326
				cp -a /var/lib/samba/private "$backup_dir" && \
328
				samba-tool dbcheck --cross-ncs --fix --yes
327
				samba-tool dbcheck --cross-ncs --fix --yes
329
				service samba start
328
				service samba start
330
 			fi
329
			fi
331
		fi
330
		fi
332
	fi
331
	fi
333
332
 Lines 376-382   call_joinscript 96univention-samba4.inst Link Here 
376
375
377
# Run a samba-tool ntacl sysvolreset, this is required for the rc6 upgrade
376
# Run a samba-tool ntacl sysvolreset, this is required for the rc6 upgrade
378
if [ "$1" = "configure" -a -n "$2" ] && dpkg --compare-versions "$2" lt-nl 2.0.28; then
377
if [ "$1" = "configure" -a -n "$2" ] && dpkg --compare-versions "$2" lt-nl 2.0.28; then
379
	samba-tool ntacl sysvolreset 
378
	samba-tool ntacl sysvolreset
380
fi
379
fi
381
380
382
exit 0
381
exit 0
(-)a/services/univention-samba4/debian/univention-samba4.prerm (-2 / +1 lines)
 Lines 82-92   if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then Link Here 
82
82
83
	ucr unset kerberos/autostart
83
	ucr unset kerberos/autostart
84
	test -x /etc/init.d/heimdal-kdc && invoke-rc.d heimdal-kdc start
84
	test -x /etc/init.d/heimdal-kdc && invoke-rc.d heimdal-kdc start
85
		
85
86
	divert_univention_heimdal_service_cfg
86
	divert_univention_heimdal_service_cfg
87
87
88
	cp /usr/lib/univention-uninstall/04univention-samba4.uinst /usr/lib/univention-install/
88
	cp /usr/lib/univention-uninstall/04univention-samba4.uinst /usr/lib/univention-install/
89
fi
89
fi
90
90
91
exit 0
91
exit 0
92
(-)a/services/univention-samba4/scripts/check_essential_samba4_dns_records.sh (-4 / +4 lines)
 Lines 29-35    Link Here 
29
29
30
eval "$(univention-config-registry shell windows/domain samba4/ldap/base ldap/hostdn)"
30
eval "$(univention-config-registry shell windows/domain samba4/ldap/base ldap/hostdn)"
31
31
32
Domain_GUID="$(ldbsearch -H /var/lib/samba/private/sam.ldb -s base objectGUID | sed -n 's/^objectGUID: \(.*\)/\1/p')"
32
Domain_GUID="$(ldbsearch -H /var/lib/samba/private/sam.ldb -s base objectGUID | sed -n 's/^objectGUID: //p')"
33
33
34
## Now lookup DNS entries
34
## Now lookup DNS entries
35
host gc._msdcs
35
host gc._msdcs
 Lines 51-66   kpasswd udp Link Here 
51
## retrive DC specific GUID
51
## retrive DC specific GUID
52
NTDS_objectGUIDs=()
52
NTDS_objectGUIDs=()
53
sites=()
53
sites=()
54
samba4servicedcs=$(ldapsearch -ZZ -LLL -D "$ldap_hostdn" -y /etc/machine.secret "(&(univentionService=Samba 4)(objectClass=univentionDomainController))" cn | ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p')      ## currently there is no u-d-m module computers/dc
54
samba4servicedcs=$(ldapsearch -ZZ -LLLo ldif-wrap=no -D "$ldap_hostdn" -y /etc/machine.secret "(&(univentionService=Samba 4)(objectClass=univentionDomainController))" cn | sed -n 's/^cn: //p')      ## currently there is no u-d-m module computers/dc
55
55
56
for s4dc in $samba4servicedcs; do
56
for s4dc in $samba4servicedcs; do
57
	server_object_dn=$(ldbsearch -H /var/lib/samba/private/sam.ldb samAccountName="${s4dc}\$" \
57
	server_object_dn=$(ldbsearch -H /var/lib/samba/private/sam.ldb samAccountName="${s4dc}\$" \
58
							serverReferenceBL | ldapsearch-wrapper | sed -n 's/^serverReferenceBL: \(.*\)/\1/p')
58
							serverReferenceBL | ldapsearch-wrapper | sed -n 's/^serverReferenceBL: //p')
59
	if [ -z "$server_object_dn" ]; then
59
	if [ -z "$server_object_dn" ]; then
60
		continue
60
		continue
61
	fi
61
	fi
62
	NTDS_objectGUID=$(ldbsearch -H /var/lib/samba/private/sam.ldb -b "$server_object_dn" \
62
	NTDS_objectGUID=$(ldbsearch -H /var/lib/samba/private/sam.ldb -b "$server_object_dn" \
63
							"CN=NTDS Settings" objectGUID | ldapsearch-wrapper | sed -n 's/^objectGUID: \(.*\)/\1/p')
63
							"CN=NTDS Settings" objectGUID | ldapsearch-wrapper | sed -n 's/^objectGUID: //p')
64
	NTDS_objectGUIDs+=($NTDS_objectGUID)
64
	NTDS_objectGUIDs+=($NTDS_objectGUID)
65
65
66
	## Determine sitename
66
	## Determine sitename
(-)a/services/univention-samba4/scripts/create_spn_account.sh (-1 / +1 lines)
 Lines 160-166   create_spn_account() { Link Here 
160
160
161
	# get msDS-KeyVersionNumber
161
	# get msDS-KeyVersionNumber
162
	msdsKeyVersion=$(ldbsearch -H /var/lib/samba/private/sam.ldb  samAccountName="$spn_account_name" msDS-KeyVersionNumber \
162
	msdsKeyVersion=$(ldbsearch -H /var/lib/samba/private/sam.ldb  samAccountName="$spn_account_name" msDS-KeyVersionNumber \
163
					| sed -n 's/^msDS-KeyVersionNumber: \(.*\)/\1/p')
163
					| sed -n 's/^msDS-KeyVersionNumber: //p')
164
	if [ -z "$msdsKeyVersion" ]; then
164
	if [ -z "$msdsKeyVersion" ]; then
165
		echo "ERROR: Could not determine msDS-KeyVersionNumber of $spn_account_name account!"
165
		echo "ERROR: Could not determine msDS-KeyVersionNumber of $spn_account_name account!"
166
		exit 1
166
		exit 1
(-)a/services/univention-samba4/scripts/setup-s4.sh (-14 / +13 lines)
 Lines 84-90   while getopts "h-:W:" option; do Link Here 
84
	esac
84
	esac
85
done
85
done
86
86
87
DOMAIN_SID="$(univention-ldapsearch "(&(objectclass=sambadomain)(sambaDomainName=$windows_domain))" sambaSID | ldapsearch-wrapper | sed -n 's/sambaSID: \(.*\)/\1/p')"
87
DOMAIN_SID="$(univention-ldapsearch -LLLo ldif-wrap=no "(&(objectclass=sambadomain)(sambaDomainName=$windows_domain))" sambaSID | sed -n 's/sambaSID: //p')"
88
88
89
## helper function
89
## helper function
90
stop_conflicting_services() {
90
stop_conflicting_services() {
 Lines 105-129   stop_conflicting_services() { Link Here 
105
		fi
105
		fi
106
	fi
106
	fi
107
107
108
	tmp_ucr_key_value_list=()
108
	declare -a tmp_ucr_key_value_list=()
109
	if [ "$samba_autostart" != "no" ]; then
109
	if [ "$samba_autostart" != "no" ]; then
110
			tmp_ucr_key_value_list[0]="samba/autostart=no"
110
		tmp_ucr_key_value_list+=("samba/autostart=no")
111
	fi
111
	fi
112
	if [ "$winbind_autostart" != "no" ]; then
112
	if [ "$winbind_autostart" != "no" ]; then
113
			tmp_ucr_key_value_list[${#tmp_ucr_key_value_list[@]}]="winbind/autostart=no"
113
		tmp_ucr_key_value_list+=("winbind/autostart=no")
114
	fi
114
	fi
115
	if [ "$kerberos_autostart" != "no" ]; then
115
	if [ "$kerberos_autostart" != "no" ]; then
116
			tmp_ucr_key_value_list[${#tmp_ucr_key_value_list[@]}]="kerberos/autostart=no"
116
		tmp_ucr_key_value_list+=("kerberos/autostart=no")
117
	fi
117
	fi
118
	if [ -n "$tmp_ucr_key_value_list" ]; then
118
	if [ -n "$tmp_ucr_key_value_list" ]; then
119
		univention-config-registry set "${tmp_ucr_key_value_list[@]}" 2>&1 | tee -a "$LOGFILE"
119
		univention-config-registry set "${tmp_ucr_key_value_list[@]}" 2>&1 | tee -a "$LOGFILE"
120
	fi
120
	fi
121
	unset tmp_ucr_key_value_list
122
}
121
}
123
122
124
set_machine_secret() {
123
set_machine_secret() {
125
	## 1. store password locally in secrets.ldb
124
	## 1. store password locally in secrets.ldb
126
	old_kvno=$(ldbsearch -H "$samba_sam" samAccountName="${hostname}\$" msDS-KeyVersionNumber | sed -n 's/msDS-KeyVersionNumber: \(.*\)/\1/p')
125
	old_kvno=$(ldbsearch -H "$samba_sam" samAccountName="${hostname}\$" msDS-KeyVersionNumber | sed -n 's/msDS-KeyVersionNumber: //p')
127
	new_kvno=$(($old_kvno + 1))
126
	new_kvno=$(($old_kvno + 1))
128
127
129
	ldbmodify -H "$samba_secrets" <<-%EOF
128
	ldbmodify -H "$samba_secrets" <<-%EOF
 Lines 142-148   set_machine_secret() { Link Here 
142
}
141
}
143
142
144
# Search for Samba 3 DCs
143
# Search for Samba 3 DCs
145
S3_DCS="$(univention-ldapsearch "(&(objectclass=univentionDomainController)(univentionService=Samba 3))" cn | ldapsearch-wrapper | sed -n 's/cn: \(.*\)/\1/p')"
144
S3_DCS="$(univention-ldapsearch -LLLo ldif-wrap=no "(&(objectclass=univentionDomainController)(univentionService=Samba 3))" cn | sed -n 's/^cn: //p')"
146
if [ -n "$S3_DCS" ]; then
145
if [ -n "$S3_DCS" ]; then
147
	## safty belt
146
	## safty belt
148
	if is_ucr_true samba4/ignore/mixsetup; then
147
	if is_ucr_true samba4/ignore/mixsetup; then
 Lines 226-232   if [ -z "$S3_DCS" ] || [ -z "$DOMAIN_SID" ] || is_ucr_true samba4/provision/seco Link Here 
226
225
227
else
226
else
228
	## Before starting the upgrade check for Samba accounts that are not POSIX accounts:
227
	## Before starting the upgrade check for Samba accounts that are not POSIX accounts:
229
	non_posix_sambaSamAccount_dns=$(univention-ldapsearch -LLL "(&(objectClass=sambaSamAccount)(!(objectClass=posixAccount)))" dn | ldapsearch-wrapper | sed -n 's/^dn: \(.*\)/\1/p')
228
	non_posix_sambaSamAccount_dns=$(univention-ldapsearch -LLLo ldif-wrap=no "(&(objectClass=sambaSamAccount)(!(objectClass=posixAccount)))" dn | sed -n 's/^dn: //p')
230
	if [ -n "$non_posix_sambaSamAccount_dns" ]; then
229
	if [ -n "$non_posix_sambaSamAccount_dns" ]; then
231
		echo "ERROR: Found Samba accounts in LDAP that are not POSIX accounts, please remove these before updating to Samba 4" >&2
230
		echo "ERROR: Found Samba accounts in LDAP that are not POSIX accounts, please remove these before updating to Samba 4" >&2
232
		echo "$non_posix_sambaSamAccount_dns" | while read dn; do
231
		echo "$non_posix_sambaSamAccount_dns" | while read dn; do
 Lines 238-244   else Link Here 
238
	## Before starting the upgrade check for group names colliding with user names
237
	## Before starting the upgrade check for group names colliding with user names
239
	uid_ldap_check_function() {
238
	uid_ldap_check_function() {
240
		local filter="$1"
239
		local filter="$1"
241
		collision=$(univention-ldapsearch -LLL "(&(objectClass=posixAccount)(|$filter))" uid | ldapsearch-wrapper | sed -n 's/^uid: \(.*\)/\1/p')
240
		collision=$(univention-ldapsearch -LLLo ldif-wrap=no "(&(objectClass=posixAccount)(|$filter))" uid | sed -n 's/^uid: //p')
242
		if [ -n "$collision" ]; then
241
		if [ -n "$collision" ]; then
243
			echo "ERROR: Group names and user names must be unique, please rename these before updating to Samba 4" >&2
242
			echo "ERROR: Group names and user names must be unique, please rename these before updating to Samba 4" >&2
244
			echo "The following user names are also present as group names:" >&2
243
			echo "The following user names are also present as group names:" >&2
 Lines 255-261   else Link Here 
255
			uid_ldap_check_function "$filter"
254
			uid_ldap_check_function "$filter"
256
			filter="(uid=$name)"
255
			filter="(uid=$name)"
257
		fi
256
		fi
258
	done < <(univention-ldapsearch -LLL "(objectClass=posixGroup)" cn | ldapsearch-wrapper | sed -n 's/^cn: \(.*\)/\1/p')
257
	done < <(univention-ldapsearch -LLLo ldif-wrap=no "(objectClass=posixGroup)" cn | sed -n 's/^cn: //p')
259
	if [ -n "$filter" ]; then
258
	if [ -n "$filter" ]; then
260
		uid_ldap_check_function "$filter"
259
		uid_ldap_check_function "$filter"
261
	fi
260
	fi
 Lines 264-273   else Link Here 
264
	extract_binddn_and_bindpwd_from_args "$@"
263
	extract_binddn_and_bindpwd_from_args "$@"
265
	groups=("Windows Hosts" "DC Backup Hosts" "DC Slave Hosts" "Computers" "Power Users")
264
	groups=("Windows Hosts" "DC Backup Hosts" "DC Slave Hosts" "Computers" "Power Users")
266
	for group in "${groups[@]}"; do
265
	for group in "${groups[@]}"; do
267
		record=$(univention-ldapsearch -LLL "(&(cn=$group)(objectClass=univentionGroup))" dn description | ldapsearch-wrapper)
266
		record=$(univention-ldapsearch -LLLo ldif-wrap=no "(&(cn=$group)(objectClass=univentionGroup))" dn description)
268
		description=$(echo "$record" | sed -n 's/^description: \(.*\)/\1/p')
267
		description=$(echo "$record" | sed -n 's/^description: //p')
269
		if [ -z "$description" ]; then
268
		if [ -z "$description" ]; then
270
			dn=$(echo "$record" | sed -n 's/^dn: \(.*\)/\1/p')
269
			dn=$(echo "$record" | sed -n 's/^dn: //p')
271
			univention-directory-manager groups/group modify "$@" --dn "$dn" --set description="$group"
270
			univention-directory-manager groups/group modify "$@" --dn "$dn" --set description="$group"
272
		fi
271
		fi
273
	done
272
	done
(-)a/services/univention-samba4/server_password_change.d/univention-samba4 (-1 / +1 lines)
 Lines 33-39   eval "$(univention-config-registry shell)" Link Here 
33
33
34
set_machine_secret() {
34
set_machine_secret() {
35
	## 1. store password locally in secrets.ldb
35
	## 1. store password locally in secrets.ldb
36
	old_kvno=$(ldbsearch -H /var/lib/samba/private/sam.ldb samAccountName="${hostname}\$" msDS-KeyVersionNumber | sed -n 's/msDS-KeyVersionNumber: \(.*\)/\1/p')
36
	old_kvno=$(ldbsearch -H /var/lib/samba/private/sam.ldb samAccountName="${hostname}\$" msDS-KeyVersionNumber | sed -n 's/^msDS-KeyVersionNumber: //p')
37
	new_kvno=$(($old_kvno + 1))
37
	new_kvno=$(($old_kvno + 1))
38
38
39
	ldbmodify -H /var/lib/samba/private/secrets.ldb <<-%EOF
39
	ldbmodify -H /var/lib/samba/private/secrets.ldb <<-%EOF
(-)a/services/univention-samba4/univention-s4search (-1 / +1 lines)
 Lines 59-65   if ! [ "$credentials_given" = 'true' ]; then Link Here 
59
59
60
		## currently the password in the secrets.ldb is set to machine.secret only on provision host, so we need to look it up from the secrets.ldb
60
		## currently the password in the secrets.ldb is set to machine.secret only on provision host, so we need to look it up from the secrets.ldb
61
		# sampassword=$(cat /etc/machine.secret)
61
		# sampassword=$(cat /etc/machine.secret)
62
		sampassword=$(ldbsearch -H /var/lib/samba/private/secrets.ldb samAccountName="${hostname}\$" secret | ldapsearch-wrapper | sed -n 's/secret: \(.*\)/\1/p')
62
		sampassword=$(ldbsearch -H /var/lib/samba/private/secrets.ldb samAccountName="${hostname}\$" secret | ldapsearch-wrapper | sed -n 's/^secret: //p')
63
		samaccount="${hostname}\$"
63
		samaccount="${hostname}\$"
64
64
65
	fi
65
	fi

Return to bug 43904