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

(-)96univention-samba4.inst (+62 lines)
 Lines 272-277    Link Here 
272
	if ! [ -r "/etc/krb5.keytab" ]; then
272
	if ! [ -r "/etc/krb5.keytab" ]; then
273
		echo "WARNING: /etc/krb5.keytab not created."
273
		echo "WARNING: /etc/krb5.keytab not created."
274
	fi
274
	fi
275
	restore_rid_pool
275
}
276
}
276
277
277
samba_domain_join() {
278
samba_domain_join() {
 Lines 488-493    Link Here 
488
	test -n "$search_result" && echo " done" || echo " failed"
489
	test -n "$search_result" && echo " done" || echo " failed"
489
}
490
}
490
491
492
extract_rid_pool() {
493
	local test_output
494
	local ridset_dn
495
	## Workaround for Bug #34754
496
	if [ -r /var/lib/samba/private/sam.ldb ]; then
497
		ridset_dn=$(ldbsearch -H /var/lib/samba/private/sam.ldb sAMAccountName="$hostname$" rIDSetReferences  | ldapsearch-wrapper | sed -n 's/^rIDSetReferences: //p')
498
		if [ -n "$ridset_dn" ]; then
499
			test_output=$(ldbsearch -H /var/lib/samba/private/sam.ldb -s base -b "$ridset_dn" | ldapsearch-wrapper)
500
			old_rIDAllocationPool=$(sed -n 's/^rIDAllocationPool: //p' <<<"$test_output")
501
			old_rIDPreviousAllocationPool=$(sed -n 's/^rIDPreviousAllocationPool: //p' <<<"$test_output")
502
			old_rIDNextRID=$(sed -n 's/^rIDNextRID: //p' <<<"$test_output")
503
		fi
504
	fi
505
}
506
507
restore_rid_pool() {
508
	local test_output
509
	local ridset_dn
510
	## Workaround for Bug #34754
511
	if [ -r /var/lib/samba/private/sam.ldb ]; then
512
		ridset_dn=$(ldbsearch -H /var/lib/samba/private/sam.ldb sAMAccountName="$hostname$" rIDSetReferences  | ldapsearch-wrapper | sed -n 's/^rIDSetReferences: //p')
513
		if [ -n "$ridset_dn" ]; then
514
			test_output=$(ldbsearch -H /var/lib/samba/private/sam.ldb -s base -b "$ridset_dn" | ldapsearch-wrapper)
515
			new_rIDAllocationPool=$(sed -n 's/^rIDAllocationPool: //p' <<<"$test_output")
516
			new_rIDPreviousAllocationPool=$(sed -n 's/^rIDPreviousAllocationPool: //p' <<<"$test_output")
517
			new_rIDNextRID=$(sed -n 's/^rIDNextRID: //p' <<<"$test_output")
518
		fi
519
	fi
520
	if [ -n "$new_rIDAllocationPool" ] && [ -z "$new_rIDNextRID" ]; then
521
		if [ "$new_rIDAllocationPool" = "$old_rIDAllocationPool" ] && [ -n "$old_rIDNextRID" ]; then
522
			{
523
			cat <<-%EOF
524
			dn: $ridset_dn
525
			changetype: modify
526
			add: rIDNextRID
527
			rIDNextRID: $old_rIDNextRID
528
			%EOF
529
530
			if [ -z "$new_rIDPreviousAllocationPool" ]; then
531
				if [ -n "$old_rIDPreviousAllocationPool" ]; then
532
					cat <<-%EOF
533
					-
534
					add: rIDPreviousAllocationPool
535
					rIDPreviousAllocationPool: $old_rIDPreviousAllocationPool
536
					%EOF
537
				else
538
					cat <<-%EOF
539
					-
540
					add: rIDPreviousAllocationPool
541
					rIDPreviousAllocationPool: $new_rIDAllocationPool
542
					%EOF
543
				fi
544
			fi
545
			} | ldbmodify -H /var/lib/samba/private/sam.ldb
546
		fi
547
	fi
548
}
549
550
491
var_lib_samba_is_s4 ()
551
var_lib_samba_is_s4 ()
492
{
552
{
493
	test -e /var/lib/samba/private/sam.ldb
553
	test -e /var/lib/samba/private/sam.ldb
 Lines 498-503    Link Here 
498
	local backup_folder
558
	local backup_folder
499
	backup_folder="/var/lib/samba_backup_$(date +%Y%m%d%H%M%S)"
559
	backup_folder="/var/lib/samba_backup_$(date +%Y%m%d%H%M%S)"
500
	if var_lib_samba_is_s4; then
560
	if var_lib_samba_is_s4; then
561
		extract_rid_pool
501
		mv /var/lib/samba "$backup_folder"
562
		mv /var/lib/samba "$backup_folder"
502
		## and copy everything back except private/*
563
		## and copy everything back except private/*
503
		rsync -a --exclude /private/* "$backup_folder/" /var/lib/samba
564
		rsync -a --exclude /private/* "$backup_folder/" /var/lib/samba
 Lines 788-793    Link Here 
788
849
789
				## if the key version number increased, merge the old keys into the new keytab
850
				## if the key version number increased, merge the old keys into the new keytab
790
				merge_backup_samba4_keytab
851
				merge_backup_samba4_keytab
852
				restore_rid_pool
791
853
792
			fi
854
			fi
793
855

Return to bug 34754