From 0f5b1bd9e2d16702a7be674fcd4ba4328d6befc1 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 8 Jan 2018 18:38:08 +0100 Subject: [PATCH] selftest: fix creation of builtin users in wait_for_start If "BUILTIN\Users" already exists, attempting to create it would fail, so we should check for the existence prior to the creation. It is unclear *why* the mapping sometimes already exist and sometime not. There are two places where they would have been created: 1. libnet_join_add_dom_rids_to_builtins tries to add the mapping when joining a domain, but at that point winbindd isn't running 2. when a user is authenticated in smbd, which clearly can't have happended when in the function wait_for_start Go figure... Signed-off-by: Ralph Boehme Reviewed-by: Andreas Schneider --- selftest/target/Samba3.pm | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 851460c502b..0f41b0ea1c0 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -2333,6 +2333,7 @@ force_user:x:$gid_force_user: sub wait_for_start($$$$$) { my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_; + my $cmd; my $ret; if ($nmbd eq "yes") { @@ -2366,8 +2367,7 @@ sub wait_for_start($$$$$) if ($winbindd eq "yes") { print "checking for winbindd\n"; my $count = 0; - my $cmd = ""; - $cmd .= "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' "; + $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' "; $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' "; $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' "; $cmd .= Samba::bindir_path($self, "wbinfo") . " --ping-dc"; @@ -2419,9 +2419,28 @@ sub wait_for_start($$$$$) return 1; } + # note: creating builtin groups requires winbindd for the + # unix id allocator + my $create_builtin_users = "no"; if ($winbindd eq "yes") { - # note: creating builtin groups requires winbindd for the - # unix id allocator + $cmd = "SELFTEST_WINBINDD_SOCKET_DIR='$envvars->{SELFTEST_WINBINDD_SOCKET_DIR}' "; + $cmd .= "NSS_WRAPPER_PASSWD='$envvars->{NSS_WRAPPER_PASSWD}' "; + $cmd .= "NSS_WRAPPER_GROUP='$envvars->{NSS_WRAPPER_GROUP}' "; + $cmd .= Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545"; + my $wbinfo_out = qx($cmd 2>&1); + if ($? != 0) { + # wbinfo doesn't give us a better error code then + # WBC_ERR_DOMAIN_NOT_FOUND, but at least that's + # different then WBC_ERR_WINBIND_NOT_AVAILABLE + if ($wbinfo_out !~ /WBC_ERR_DOMAIN_NOT_FOUND/) { + print("Failed to run \"wbinfo --sid-to-gid=S-1-5-32-545\": $wbinfo_out"); + teardown_env($self, $envvars); + return 0; + } + $create_builtin_users = "yes"; + } + } + if ($create_builtin_users eq "yes") { $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Users"); if ($ret != 0) { print "Failed to create BUILTIN\\Users group\n"; -- 2.11.4.GIT