Changeset 988 for vendor/current/selftest/target/Samba3.pm
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/selftest/target/Samba3.pm
r919 r988 10 10 use FindBin qw($RealBin); 11 11 use POSIX; 12 13 sub binpath($$) 12 use target::Samba; 13 14 sub have_ads($) { 15 my ($self) = @_; 16 my $found_ads = 0; 17 my $smbd_build_options = Samba::bindir_path($self, "smbd") . " -b|"; 18 open(IN, $smbd_build_options) or die("Unable to run $smbd_build_options: $!"); 19 20 while (<IN>) { 21 if (/WITH_ADS/) { 22 $found_ads = 1; 23 } 24 } 25 close IN; 26 27 # If we were not built with ADS support, pretend we were never even available 28 print "smbd does not have ADS support\n" unless $found_ads; 29 return $found_ads; 30 } 31 32 # return smb.conf parameters applicable to @path, based on the underlying 33 # filesystem type 34 sub get_fs_specific_conf($$) 14 35 { 15 my ($self, $binary) = @_; 16 17 if (defined($self->{bindir})) { 18 my $path = "$self->{bindir}/$binary"; 19 -f $path or die("File $path doesn't exist"); 20 return $path; 21 } 22 23 return $binary; 36 my ($self, $path) = @_; 37 my $mods = ""; 38 my $stat_out = `stat --file-system $path` or return ""; 39 40 if ($stat_out =~ m/Type:\s+btrfs/) { 41 $mods .= "btrfs "; 42 } 43 44 if ($mods) { 45 return "vfs objects = $mods"; 46 } 47 48 return undef; 24 49 } 25 50 26 51 sub new($$) { 27 my ($classname, $bindir, $srcdir) = @_; 28 my $self = { bindir => $bindir, 29 srcdir => $srcdir 52 my ($classname, $bindir, $srcdir, $server_maxtime) = @_; 53 my $self = { vars => {}, 54 bindir => $bindir, 55 srcdir => $srcdir, 56 server_maxtime => $server_maxtime 30 57 }; 31 58 bless $self; … … 36 63 { 37 64 my ($self, $envvars) = @_; 38 39 my $smbdpid = read_pid($envvars, "smbd"); 40 my $nmbdpid = read_pid($envvars, "nmbd"); 41 my $winbinddpid = read_pid($envvars, "winbindd"); 65 my $count = 0; 66 67 # This should cause smbd to terminate gracefully 68 close($envvars->{STDIN_PIPE}); 69 70 my $smbdpid = $envvars->{SMBD_TL_PID}; 71 my $nmbdpid = $envvars->{NMBD_TL_PID}; 72 my $winbinddpid = $envvars->{WINBINDD_TL_PID}; 73 74 # This should give it time to write out the gcov data 75 until ($count > 20) { 76 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd"); 77 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd"); 78 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd"); 79 if ($smbdchild == -1 80 && $nmbdchild == -1 81 && $winbinddchild == -1) { 82 last; 83 } 84 sleep(1); 85 $count++; 86 } 87 88 if ($count <= 20 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) { 89 return; 90 } 42 91 43 92 $self->stop_sig_term($smbdpid); … … 45 94 $self->stop_sig_term($winbinddpid); 46 95 47 sleep(2); 48 96 $count = 0; 97 until ($count > 10) { 98 my $smbdchild = Samba::cleanup_child($smbdpid, "smbd"); 99 my $nmbdchild = Samba::cleanup_child($nmbdpid, "nmbd"); 100 my $winbinddchild = Samba::cleanup_child($winbinddpid, "winbindd"); 101 if ($smbdchild == -1 102 && $nmbdchild == -1 103 && $winbinddchild == -1) { 104 last; 105 } 106 sleep(1); 107 $count++; 108 } 109 110 if ($count <= 10 && kill(0, $smbdpid, $nmbdpid, $winbinddpid) == 0) { 111 return; 112 } 113 114 warn("timelimit process did not quit on SIGTERM, sending SIGKILL"); 49 115 $self->stop_sig_kill($smbdpid); 50 116 $self->stop_sig_kill($nmbdpid); … … 91 157 my ($self, $envvars) = @_; 92 158 159 my $childpid = waitpid(-1, WNOHANG); 160 93 161 # TODO ... 94 162 return 1; … … 98 166 { 99 167 my ($self, $envname, $path) = @_; 100 101 if ($envname eq "s3dc") { 102 return $self->setup_dc("$path/s3dc"); 103 } elsif ($envname eq "secshare") { 104 return $self->setup_secshare("$path/secshare"); 105 } elsif ($envname eq "secserver") { 106 if (not defined($self->{vars}->{s3dc})) { 107 $self->setup_dc("$path/s3dc"); 108 } 109 return $self->setup_secserver("$path/secserver", $self->{vars}->{s3dc}); 110 } elsif ($envname eq "member") { 111 if (not defined($self->{vars}->{s3dc})) { 112 $self->setup_dc("$path/s3dc"); 113 } 114 return $self->setup_member("$path/member", $self->{vars}->{s3dc}); 168 169 $ENV{ENVNAME} = $envname; 170 171 if (defined($self->{vars}->{$envname})) { 172 return $self->{vars}->{$envname}; 173 } 174 175 # 176 # Avoid hitting system krb5.conf - 177 # An env that needs Kerberos will reset this to the real 178 # value. 179 # 180 $ENV{KRB5_CONFIG} = "$path/no_krb5.conf"; 181 182 if ($envname eq "nt4_dc") { 183 return $self->setup_nt4_dc("$path/nt4_dc"); 184 } elsif ($envname eq "nt4_dc_schannel") { 185 return $self->setup_nt4_dc_schannel("$path/nt4_dc_schannel"); 186 } elsif ($envname eq "simpleserver") { 187 return $self->setup_simpleserver("$path/simpleserver"); 188 } elsif ($envname eq "fileserver") { 189 return $self->setup_fileserver("$path/fileserver"); 190 } elsif ($envname eq "maptoguest") { 191 return $self->setup_maptoguest("$path/maptoguest"); 192 } elsif ($envname eq "ktest") { 193 return $self->setup_ktest("$path/ktest"); 194 } elsif ($envname eq "nt4_member") { 195 if (not defined($self->{vars}->{nt4_dc})) { 196 if (not defined($self->setup_nt4_dc("$path/nt4_dc"))) { 197 return undef; 198 } 199 } 200 return $self->setup_nt4_member("$path/nt4_member", $self->{vars}->{nt4_dc}); 115 201 } else { 116 return undef;117 } 118 } 119 120 sub setup_ dc($$)202 return "UNKNOWN"; 203 } 204 } 205 206 sub setup_nt4_dc($$) 121 207 { 122 208 my ($self, $path) = @_; 123 209 124 print "PROVISIONING S3DC...";125 126 my $ s3dc_options = "210 print "PROVISIONING NT4 DC..."; 211 212 my $nt4_dc_options = " 127 213 domain master = yes 128 214 domain logons = yes 129 215 lanman auth = yes 130 216 raw NTLMv2 auth = yes 217 218 rpc_server:epmapper = external 219 rpc_server:spoolss = external 220 rpc_server:lsarpc = external 221 rpc_server:samr = external 222 rpc_server:netlogon = external 223 rpc_server:register_embedded_np = yes 224 rpc_server:FssagentRpc = external 225 226 rpc_daemon:epmd = fork 227 rpc_daemon:spoolssd = fork 228 rpc_daemon:lsasd = fork 229 rpc_daemon:fssd = fork 230 fss: sequence timeout = 1 131 231 "; 132 232 133 233 my $vars = $self->provision($path, 134 "LOCALS3DC2", 135 2, 136 "locals3dc2pass", 137 $s3dc_options); 138 139 $self->check_or_start($vars, 140 ($ENV{SMBD_MAXTIME} or 2700), 141 "yes", "yes", "yes"); 142 143 $self->wait_for_start($vars); 234 "LOCALNT4DC2", 235 "localntdc2pass", 236 $nt4_dc_options); 237 238 $vars or return undef; 239 240 if (not $self->check_or_start($vars, "yes", "yes", "yes")) { 241 return undef; 242 } 144 243 145 244 $vars->{DC_SERVER} = $vars->{SERVER}; 146 245 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP}; 246 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6}; 147 247 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME}; 148 248 $vars->{DC_USERNAME} = $vars->{USERNAME}; 149 249 $vars->{DC_PASSWORD} = $vars->{PASSWORD}; 150 250 151 $self->{vars}->{ s3dc} = $vars;251 $self->{vars}->{nt4_dc} = $vars; 152 252 153 253 return $vars; 154 254 } 155 255 156 sub setup_ member($$$)256 sub setup_nt4_dc_schannel($$) 157 257 { 158 my ($self, $prefix, $s3dcvars) = @_; 258 my ($self, $path) = @_; 259 260 print "PROVISIONING NT4 DC WITH SERVER SCHANNEL ..."; 261 262 my $pdc_options = " 263 domain master = yes 264 domain logons = yes 265 lanman auth = yes 266 267 rpc_server:epmapper = external 268 rpc_server:spoolss = external 269 rpc_server:lsarpc = external 270 rpc_server:samr = external 271 rpc_server:netlogon = external 272 rpc_server:register_embedded_np = yes 273 274 rpc_daemon:epmd = fork 275 rpc_daemon:spoolssd = fork 276 rpc_daemon:lsasd = fork 277 278 server schannel = yes 279 "; 280 281 my $vars = $self->provision($path, 282 "LOCALNT4DC9", 283 "localntdc9pass", 284 $pdc_options); 285 286 $vars or return undef; 287 288 if (not $self->check_or_start($vars, "yes", "yes", "yes")) { 289 return undef; 290 } 291 292 $vars->{DC_SERVER} = $vars->{SERVER}; 293 $vars->{DC_SERVER_IP} = $vars->{SERVER_IP}; 294 $vars->{DC_SERVER_IPV6} = $vars->{SERVER_IPV6}; 295 $vars->{DC_NETBIOSNAME} = $vars->{NETBIOSNAME}; 296 $vars->{DC_USERNAME} = $vars->{USERNAME}; 297 $vars->{DC_PASSWORD} = $vars->{PASSWORD}; 298 299 $self->{vars}->{nt4_dc_schannel} = $vars; 300 301 return $vars; 302 } 303 304 sub setup_nt4_member($$$) 305 { 306 my ($self, $prefix, $nt4_dc_vars) = @_; 307 my $count = 0; 308 my $rc; 159 309 160 310 print "PROVISIONING MEMBER..."; … … 163 313 security = domain 164 314 server signing = on 315 dbwrap_tdb_mutexes:* = yes 165 316 "; 166 317 my $ret = $self->provision($prefix, 167 "LOCALMEMBER3", 168 3, 169 "localmember3pass", 318 "LOCALNT4MEMBER3", 319 "localnt4member3pass", 170 320 $member_options); 171 321 172 $ret or die("Unable to provision"); 173 174 my $net = $self->binpath("net"); 322 $ret or return undef; 323 324 my $nmblookup = Samba::bindir_path($self, "nmblookup"); 325 do { 326 print "Waiting for the LOGON SERVER registration ...\n"; 327 $rc = system("$nmblookup $ret->{CONFIGURATION} $ret->{DOMAIN}\#1c"); 328 if ($rc != 0) { 329 sleep(1); 330 } 331 $count++; 332 } while ($rc != 0 && $count < 10); 333 if ($count == 10) { 334 print "NMBD not reachable after 10 retries\n"; 335 teardown_env($self, $ret); 336 return 0; 337 } 338 339 my $net = Samba::bindir_path($self, "net"); 175 340 my $cmd = ""; 176 341 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; 177 $cmd .= "$net join $ret->{CONFIGURATION} $s3dcvars->{DOMAIN} member"; 178 $cmd .= " -U$s3dcvars->{USERNAME}\%$s3dcvars->{PASSWORD}"; 179 180 system($cmd) == 0 or die("Join failed\n$cmd"); 181 182 $self->check_or_start($ret, 183 ($ENV{SMBD_MAXTIME} or 2700), 184 "yes", "yes", "yes"); 185 186 $self->wait_for_start($ret); 187 188 $ret->{DC_SERVER} = $s3dcvars->{SERVER}; 189 $ret->{DC_SERVER_IP} = $s3dcvars->{SERVER_IP}; 190 $ret->{DC_NETBIOSNAME} = $s3dcvars->{NETBIOSNAME}; 191 $ret->{DC_USERNAME} = $s3dcvars->{USERNAME}; 192 $ret->{DC_PASSWORD} = $s3dcvars->{PASSWORD}; 342 $cmd .= "$net join $ret->{CONFIGURATION} $nt4_dc_vars->{DOMAIN} member"; 343 $cmd .= " -U$nt4_dc_vars->{USERNAME}\%$nt4_dc_vars->{PASSWORD}"; 344 345 if (system($cmd) != 0) { 346 warn("Join failed\n$cmd"); 347 return undef; 348 } 349 350 if (not $self->check_or_start($ret, "yes", "yes", "yes")) { 351 return undef; 352 } 353 354 $ret->{DC_SERVER} = $nt4_dc_vars->{SERVER}; 355 $ret->{DC_SERVER_IP} = $nt4_dc_vars->{SERVER_IP}; 356 $ret->{DC_SERVER_IPV6} = $nt4_dc_vars->{SERVER_IPV6}; 357 $ret->{DC_NETBIOSNAME} = $nt4_dc_vars->{NETBIOSNAME}; 358 $ret->{DC_USERNAME} = $nt4_dc_vars->{USERNAME}; 359 $ret->{DC_PASSWORD} = $nt4_dc_vars->{PASSWORD}; 193 360 194 361 return $ret; 195 362 } 196 363 197 sub setup_secshare($$) 364 sub setup_admember($$$$) 365 { 366 my ($self, $prefix, $dcvars) = @_; 367 368 # If we didn't build with ADS, pretend this env was never available 369 if (not $self->have_ads()) { 370 return "UNKNOWN"; 371 } 372 373 print "PROVISIONING S3 AD MEMBER..."; 374 375 my $member_options = " 376 security = ads 377 server signing = on 378 workgroup = $dcvars->{DOMAIN} 379 realm = $dcvars->{REALM} 380 "; 381 382 my $ret = $self->provision($prefix, 383 "LOCALADMEMBER", 384 "loCalMemberPass", 385 $member_options, 386 $dcvars->{SERVER_IP}, 387 $dcvars->{SERVER_IPV6}); 388 389 $ret or return undef; 390 391 close(USERMAP); 392 $ret->{DOMAIN} = $dcvars->{DOMAIN}; 393 $ret->{REALM} = $dcvars->{REALM}; 394 395 my $ctx; 396 my $prefix_abs = abs_path($prefix); 397 $ctx = {}; 398 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf"; 399 $ctx->{domain} = $dcvars->{DOMAIN}; 400 $ctx->{realm} = $dcvars->{REALM}; 401 $ctx->{dnsname} = lc($dcvars->{REALM}); 402 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP}; 403 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6}; 404 Samba::mk_krb5_conf($ctx, ""); 405 406 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf}; 407 408 my $net = Samba::bindir_path($self, "net"); 409 my $cmd = ""; 410 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; 411 if (defined($ret->{RESOLV_WRAPPER_CONF})) { 412 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" "; 413 } else { 414 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" "; 415 } 416 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; 417 $cmd .= "$net join $ret->{CONFIGURATION}"; 418 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}"; 419 420 if (system($cmd) != 0) { 421 warn("Join failed\n$cmd"); 422 return undef; 423 } 424 425 # We need world access to this share, as otherwise the domain 426 # administrator from the AD domain provided by Samba4 can't 427 # access the share for tests. 428 chmod 0777, "$prefix/share"; 429 430 if (not $self->check_or_start($ret, "yes", "yes", "yes")) { 431 return undef; 432 } 433 434 $ret->{DC_SERVER} = $dcvars->{SERVER}; 435 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP}; 436 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6}; 437 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME}; 438 $ret->{DC_USERNAME} = $dcvars->{USERNAME}; 439 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD}; 440 441 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env 442 $ret->{target} = $self; 443 444 return $ret; 445 } 446 447 sub setup_admember_rfc2307($$$$) 448 { 449 my ($self, $prefix, $dcvars) = @_; 450 451 # If we didn't build with ADS, pretend this env was never available 452 if (not $self->have_ads()) { 453 return "UNKNOWN"; 454 } 455 456 print "PROVISIONING S3 AD MEMBER WITH idmap_rfc2307 config..."; 457 458 my $member_options = " 459 security = ads 460 server signing = on 461 workgroup = $dcvars->{DOMAIN} 462 realm = $dcvars->{REALM} 463 idmap config $dcvars->{DOMAIN} : backend = rfc2307 464 idmap config $dcvars->{DOMAIN} : range = 2000000-2999999 465 idmap config $dcvars->{DOMAIN} : ldap_server = ad 466 idmap config $dcvars->{DOMAIN} : bind_path_user = ou=idmap,dc=samba,dc=example,dc=com 467 idmap config $dcvars->{DOMAIN} : bind_path_group = ou=idmap,dc=samba,dc=example,dc=com 468 "; 469 470 my $ret = $self->provision($prefix, 471 "RFC2307MEMBER", 472 "loCalMemberPass", 473 $member_options, 474 $dcvars->{SERVER_IP}, 475 $dcvars->{SERVER_IPV6}); 476 477 $ret or return undef; 478 479 close(USERMAP); 480 $ret->{DOMAIN} = $dcvars->{DOMAIN}; 481 $ret->{REALM} = $dcvars->{REALM}; 482 483 my $ctx; 484 my $prefix_abs = abs_path($prefix); 485 $ctx = {}; 486 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf"; 487 $ctx->{domain} = $dcvars->{DOMAIN}; 488 $ctx->{realm} = $dcvars->{REALM}; 489 $ctx->{dnsname} = lc($dcvars->{REALM}); 490 $ctx->{kdc_ipv4} = $dcvars->{SERVER_IP}; 491 $ctx->{kdc_ipv6} = $dcvars->{SERVER_IPV6}; 492 Samba::mk_krb5_conf($ctx, ""); 493 494 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf}; 495 496 my $net = Samba::bindir_path($self, "net"); 497 my $cmd = ""; 498 $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" "; 499 if (defined($ret->{RESOLV_WRAPPER_CONF})) { 500 $cmd .= "RESOLV_WRAPPER_CONF=\"$ret->{RESOLV_WRAPPER_CONF}\" "; 501 } else { 502 $cmd .= "RESOLV_WRAPPER_HOSTS=\"$ret->{RESOLV_WRAPPER_HOSTS}\" "; 503 } 504 $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" "; 505 $cmd .= "$net join $ret->{CONFIGURATION}"; 506 $cmd .= " -U$dcvars->{USERNAME}\%$dcvars->{PASSWORD}"; 507 508 if (system($cmd) != 0) { 509 warn("Join failed\n$cmd"); 510 return undef; 511 } 512 513 # We need world access to this share, as otherwise the domain 514 # administrator from the AD domain provided by Samba4 can't 515 # access the share for tests. 516 chmod 0777, "$prefix/share"; 517 518 if (not $self->check_or_start($ret, "yes", "yes", "yes")) { 519 return undef; 520 } 521 522 $ret->{DC_SERVER} = $dcvars->{SERVER}; 523 $ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP}; 524 $ret->{DC_SERVER_IPV6} = $dcvars->{SERVER_IPV6}; 525 $ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME}; 526 $ret->{DC_USERNAME} = $dcvars->{USERNAME}; 527 $ret->{DC_PASSWORD} = $dcvars->{PASSWORD}; 528 529 # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env 530 $ret->{target} = $self; 531 532 return $ret; 533 } 534 535 sub setup_simpleserver($$) 198 536 { 199 537 my ($self, $path) = @_; 200 538 201 print "PROVISIONING server with security=share..."; 202 203 my $secshare_options = " 204 security = share 539 print "PROVISIONING simple server..."; 540 541 my $prefix_abs = abs_path($path); 542 543 my $simpleserver_options = " 205 544 lanman auth = yes 545 vfs objects = xattr_tdb streams_depot 546 change notify = no 547 548 [vfs_aio_fork] 549 path = $prefix_abs/share 550 vfs objects = aio_fork 551 read only = no 552 vfs_aio_fork:erratic_testing_mode=yes 206 553 "; 207 554 208 555 my $vars = $self->provision($path, 209 556 "LOCALSHARE4", 210 4,211 557 "local4pass", 212 $s ecshare_options);213 214 $ self->check_or_start($vars,215 ($ENV{SMBD_MAXTIME} or 2700), 216 "yes", "no", "yes");217 218 $self->wait_for_start($vars);219 220 $self->{vars}->{s ecshare} = $vars;558 $simpleserver_options); 559 560 $vars or return undef; 561 562 if (not $self->check_or_start($vars, "yes", "no", "yes")) { 563 return undef; 564 } 565 566 $self->{vars}->{simpleserver} = $vars; 221 567 222 568 return $vars; 223 569 } 224 570 225 sub setup_ secserver($$$)571 sub setup_fileserver($$) 226 572 { 227 my ($self, $prefix, $s3dcvars) = @_; 228 229 print "PROVISIONING server with security=server..."; 230 231 my $secserver_options = " 232 security = server 233 password server = $s3dcvars->{SERVER_IP} 234 client ntlmv2 auth = no 573 my ($self, $path) = @_; 574 my $prefix_abs = abs_path($path); 575 my $srcdir_abs = abs_path($self->{srcdir}); 576 577 print "PROVISIONING file server ...\n"; 578 579 my @dirs = (); 580 581 mkdir($prefix_abs, 0777); 582 583 my $share_dir="$prefix_abs/share"; 584 585 # Create share directory structure 586 my $lower_case_share_dir="$share_dir/lower-case"; 587 push(@dirs, $lower_case_share_dir); 588 589 my $lower_case_share_dir_30000="$share_dir/lower-case-30000"; 590 push(@dirs, $lower_case_share_dir_30000); 591 592 my $dfree_share_dir="$share_dir/dfree"; 593 push(@dirs, $dfree_share_dir); 594 push(@dirs, "$dfree_share_dir/subdir1"); 595 push(@dirs, "$dfree_share_dir/subdir2"); 596 597 my $valid_users_sharedir="$share_dir/valid_users"; 598 push(@dirs,$valid_users_sharedir); 599 600 my $offline_sharedir="$share_dir/offline"; 601 push(@dirs,$offline_sharedir); 602 603 my $force_user_valid_users_dir = "$share_dir/force_user_valid_users"; 604 push(@dirs, $force_user_valid_users_dir); 605 606 my $smbget_sharedir="$share_dir/smbget"; 607 push(@dirs,$smbget_sharedir); 608 609 my $fileserver_options = " 610 [lowercase] 611 path = $lower_case_share_dir 612 comment = smb username is [%U] 613 case sensitive = True 614 default case = lower 615 preserve case = no 616 short preserve case = no 617 [lowercase-30000] 618 path = $lower_case_share_dir_30000 619 comment = smb username is [%U] 620 case sensitive = True 621 default case = lower 622 preserve case = no 623 short preserve case = no 624 [dfree] 625 path = $dfree_share_dir 626 comment = smb username is [%U] 627 dfree command = $srcdir_abs/testprogs/blackbox/dfree.sh 628 [valid-users-access] 629 path = $valid_users_sharedir 630 valid users = +userdup 631 [offline] 632 path = $offline_sharedir 633 vfs objects = offline 634 635 # BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878 636 # RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651 637 [force_user_valid_users] 638 path = $force_user_valid_users_dir 639 comment = force user with valid users combination test share 640 valid users = +force_user 641 force user = force_user 642 force group = everyone 643 write list = force_user 644 645 [smbget] 646 path = $smbget_sharedir 647 comment = smb username is [%U] 648 guest ok = yes 235 649 "; 236 650 651 my $vars = $self->provision($path, 652 "FILESERVER", 653 "fileserver", 654 $fileserver_options, 655 undef, 656 undef, 657 1); 658 659 $vars or return undef; 660 661 if (not $self->check_or_start($vars, "yes", "no", "yes")) { 662 return undef; 663 } 664 665 $self->{vars}->{fileserver} = $vars; 666 667 mkdir($_, 0777) foreach(@dirs); 668 669 ## Create case sensitive lower case share dir 670 foreach my $file ('a'..'z') { 671 my $full_path = $lower_case_share_dir . '/' . $file; 672 open my $fh, '>', $full_path; 673 # Add some content to file 674 print $fh $full_path; 675 close $fh; 676 } 677 678 for (my $file = 1; $file < 51; ++$file) { 679 my $full_path = $lower_case_share_dir . '/' . $file; 680 open my $fh, '>', $full_path; 681 # Add some content to file 682 print $fh $full_path; 683 close $fh; 684 } 685 686 # Create content for 30000 share 687 foreach my $file ('a'..'z') { 688 my $full_path = $lower_case_share_dir_30000 . '/' . $file; 689 open my $fh, '>', $full_path; 690 # Add some content to file 691 print $fh $full_path; 692 close $fh; 693 } 694 695 for (my $file = 1; $file < 30001; ++$file) { 696 my $full_path = $lower_case_share_dir_30000 . '/' . $file; 697 open my $fh, '>', $full_path; 698 # Add some content to file 699 print $fh $full_path; 700 close $fh; 701 } 702 703 ## 704 ## create a listable file in valid_users_share 705 ## 706 my $valid_users_target = "$valid_users_sharedir/foo"; 707 unless (open(VALID_USERS_TARGET, ">$valid_users_target")) { 708 warn("Unable to open $valid_users_target"); 709 return undef; 710 } 711 close(VALID_USERS_TARGET); 712 chmod 0644, $valid_users_target; 713 714 return $vars; 715 } 716 717 sub setup_ktest($$$) 718 { 719 my ($self, $prefix) = @_; 720 721 # If we didn't build with ADS, pretend this env was never available 722 if (not $self->have_ads()) { 723 return "UNKNOWN"; 724 } 725 726 print "PROVISIONING server with security=ads..."; 727 728 my $ktest_options = " 729 workgroup = KTEST 730 realm = ktest.samba.example.com 731 security = ads 732 username map = $prefix/lib/username.map 733 server signing = required 734 "; 735 237 736 my $ret = $self->provision($prefix, 238 "LOCALSERVER5", 239 5, 240 "localserver5pass", 241 $secserver_options); 242 243 $ret or die("Unable to provision"); 244 245 $self->check_or_start($ret, 246 ($ENV{SMBD_MAXTIME} or 2700), 247 "yes", "no", "yes"); 248 249 $self->wait_for_start($ret); 250 251 $ret->{DC_SERVER} = $s3dcvars->{SERVER}; 252 $ret->{DC_SERVER_IP} = $s3dcvars->{SERVER_IP}; 253 $ret->{DC_NETBIOSNAME} = $s3dcvars->{NETBIOSNAME}; 254 $ret->{DC_USERNAME} = $s3dcvars->{USERNAME}; 255 $ret->{DC_PASSWORD} = $s3dcvars->{PASSWORD}; 256 737 "LOCALKTEST6", 738 "localktest6pass", 739 $ktest_options); 740 741 $ret or return undef; 742 743 my $ctx; 744 my $prefix_abs = abs_path($prefix); 745 $ctx = {}; 746 $ctx->{krb5_conf} = "$prefix_abs/lib/krb5.conf"; 747 $ctx->{domain} = "KTEST"; 748 $ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM"; 749 $ctx->{dnsname} = lc($ctx->{realm}); 750 $ctx->{kdc_ipv4} = "0.0.0.0"; 751 $ctx->{kdc_ipv6} = "::"; 752 Samba::mk_krb5_conf($ctx, ""); 753 754 $ret->{KRB5_CONFIG} = $ctx->{krb5_conf}; 755 756 open(USERMAP, ">$prefix/lib/username.map") or die("Unable to open $prefix/lib/username.map"); 757 print USERMAP " 758 $ret->{USERNAME} = KTEST\\Administrator 759 "; 760 close(USERMAP); 761 762 #This is the secrets.tdb created by 'net ads join' from Samba3 to a 763 #Samba4 DC with the same parameters as are being used here. The 764 #domain SID is S-1-5-21-1071277805-689288055-3486227160 765 766 system("cp $self->{srcdir}/source3/selftest/ktest-secrets.tdb $prefix/private/secrets.tdb"); 767 chmod 0600, "$prefix/private/secrets.tdb"; 768 769 #Make sure there's no old ntdb file. 770 system("rm -f $prefix/private/secrets.ntdb"); 771 772 #This uses a pre-calculated krb5 credentials cache, obtained by running Samba4 with: 773 # "--option=kdc:service ticket lifetime=239232" "--option=kdc:user ticket lifetime=239232" "--option=kdc:renewal lifetime=239232" 774 # 775 #and having in krb5.conf: 776 # ticket_lifetime = 799718400 777 # renew_lifetime = 799718400 778 # 779 # The commands for the -2 keytab where were: 780 # kinit administrator@KTEST.SAMBA.EXAMPLE.COM 781 # kvno host/localktest6@KTEST.SAMBA.EXAMPLE.COM 782 # kvno cifs/localktest6@KTEST.SAMBA.EXAMPLE.COM 783 # kvno host/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM 784 # kvno cifs/LOCALKTEST6@KTEST.SAMBA.EXAMPLE.COM 785 # 786 # and then for the -3 keytab, I did 787 # 788 # net changetrustpw; kdestroy and the same again. 789 # 790 # This creates a credential cache with a very long lifetime (2036 at 791 # at 2011-04), and shows that running 'net changetrustpw' does not 792 # break existing logins (for the secrets.tdb method at least). 793 # 794 795 $ret->{KRB5_CCACHE}="FILE:$prefix/krb5_ccache"; 796 797 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-2 $prefix/krb5_ccache-2"); 798 chmod 0600, "$prefix/krb5_ccache-2"; 799 800 system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3"); 801 chmod 0600, "$prefix/krb5_ccache-3"; 802 803 # We need world access to this share, as otherwise the domain 804 # administrator from the AD domain provided by ktest can't 805 # access the share for tests. 806 chmod 0777, "$prefix/share"; 807 808 if (not $self->check_or_start($ret, "yes", "no", "yes")) { 809 return undef; 810 } 257 811 return $ret; 812 } 813 814 sub setup_maptoguest($$) 815 { 816 my ($self, $path) = @_; 817 818 print "PROVISIONING maptoguest..."; 819 820 my $options = " 821 map to guest = bad user 822 "; 823 824 my $vars = $self->provision($path, 825 "maptoguest", 826 "maptoguestpass", 827 $options); 828 829 $vars or return undef; 830 831 if (not $self->check_or_start($vars, "yes", "no", "yes")) { 832 return undef; 833 } 834 835 $self->{vars}->{s3maptoguest} = $vars; 836 837 return $vars; 258 838 } 259 839 … … 288 868 289 869 sub check_or_start($$$$$) { 290 my ($self, $env_vars, $maxtime, $nmbd, $winbindd, $smbd) = @_; 870 my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_; 871 872 # use a pipe for stdin in the child processes. This allows 873 # those processes to monitor the pipe for EOF to ensure they 874 # exit when the test script exits 875 pipe(STDIN_READER, $env_vars->{STDIN_PIPE}); 291 876 292 877 unlink($env_vars->{NMBD_TEST_LOG}); … … 299 884 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); 300 885 301 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; 886 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG}; 887 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR}; 302 888 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR}; 303 889 304 890 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; 305 891 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; 306 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH}; 892 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS}; 893 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME}; 894 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH}; 895 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX}; 896 $ENV{UID_WRAPPER_ROOT} = "1"; 897 898 $ENV{ENVNAME} = "$ENV{ENVNAME}.nmbd"; 307 899 308 900 if ($nmbd ne "yes") { … … 312 904 exit 0; 313 905 }; 314 sleep($ maxtime);906 sleep($self->{server_maxtime}); 315 907 exit 0; 316 908 } 317 909 910 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd"); 318 911 my @optargs = ("-d0"); 319 912 if (defined($ENV{NMBD_OPTIONS})) { 320 913 @optargs = split(/ /, $ENV{NMBD_OPTIONS}); 321 914 } 322 323 $ENV{MAKE_TEST_BINARY} = $self->binpath("nmbd"); 324 325 my @preargs = ($self->binpath("timelimit"), $maxtime); 915 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime}); 326 916 if(defined($ENV{NMBD_VALGRIND})) { 327 917 @preargs = split(/ /, $ENV{NMBD_VALGRIND}); 328 918 } 329 330 exec(@preargs, $self->binpath("nmbd"), "-F", "--no-process-group", "-S", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!"); 331 } 919 my @args = ("-F", "--no-process-group", 920 "-s", $env_vars->{SERVERCONFFILE}, 921 "-l", $env_vars->{LOGDIR}); 922 if (not defined($ENV{NMBD_DONT_LOG_STDOUT})) { 923 push(@args, "--log-stdout"); 924 } 925 926 close($env_vars->{STDIN_PIPE}); 927 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; 928 929 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs) 930 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!"); 931 } 932 $env_vars->{NMBD_TL_PID} = $pid; 332 933 write_pid($env_vars, "nmbd", $pid); 333 934 print "DONE\n"; … … 342 943 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); 343 944 344 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; 945 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG}; 946 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR}; 345 947 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR}; 346 948 347 949 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; 348 950 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; 349 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH}; 951 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS}; 952 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME}; 953 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH}; 954 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX}; 955 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) { 956 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF}; 957 } else { 958 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS}; 959 } 960 $ENV{UID_WRAPPER_ROOT} = "1"; 961 962 $ENV{ENVNAME} = "$ENV{ENVNAME}.winbindd"; 350 963 351 964 if ($winbindd ne "yes") { … … 355 968 exit 0; 356 969 }; 357 sleep($ maxtime);970 sleep($self->{server_maxtime}); 358 971 exit 0; 359 972 } 360 973 974 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd"); 361 975 my @optargs = ("-d0"); 362 976 if (defined($ENV{WINBINDD_OPTIONS})) { 363 977 @optargs = split(/ /, $ENV{WINBINDD_OPTIONS}); 364 978 } 365 366 $ENV{MAKE_TEST_BINARY} = $self->binpath("winbindd"); 367 368 my @preargs = ($self->binpath("timelimit"), $maxtime); 979 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime}); 369 980 if(defined($ENV{WINBINDD_VALGRIND})) { 370 981 @preargs = split(/ /, $ENV{WINBINDD_VALGRIND}); 371 982 } 372 373 exec(@preargs, $self->binpath("winbindd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!"); 374 } 983 my @args = ("-F", "--no-process-group", 984 "-s", $env_vars->{SERVERCONFFILE}, 985 "-l", $env_vars->{LOGDIR}); 986 if (not defined($ENV{WINBINDD_DONT_LOG_STDOUT})) { 987 push(@args, "--stdout"); 988 } 989 990 close($env_vars->{STDIN_PIPE}); 991 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; 992 993 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs) 994 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!"); 995 } 996 $env_vars->{WINBINDD_TL_PID} = $pid; 375 997 write_pid($env_vars, "winbindd", $pid); 376 998 print "DONE\n"; … … 385 1007 SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE}); 386 1008 387 $ENV{WINBINDD_SOCKET_DIR} = $env_vars->{WINBINDD_SOCKET_DIR}; 1009 $ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG}; 1010 $ENV{SELFTEST_WINBINDD_SOCKET_DIR} = $env_vars->{SELFTEST_WINBINDD_SOCKET_DIR}; 388 1011 $ENV{NMBD_SOCKET_DIR} = $env_vars->{NMBD_SOCKET_DIR}; 389 1012 390 1013 $ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD}; 391 1014 $ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP}; 392 $ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH}; 1015 $ENV{NSS_WRAPPER_HOSTS} = $env_vars->{NSS_WRAPPER_HOSTS}; 1016 $ENV{NSS_WRAPPER_HOSTNAME} = $env_vars->{NSS_WRAPPER_HOSTNAME}; 1017 $ENV{NSS_WRAPPER_MODULE_SO_PATH} = $env_vars->{NSS_WRAPPER_MODULE_SO_PATH}; 1018 $ENV{NSS_WRAPPER_MODULE_FN_PREFIX} = $env_vars->{NSS_WRAPPER_MODULE_FN_PREFIX}; 1019 if (defined($env_vars->{RESOLV_WRAPPER_CONF})) { 1020 $ENV{RESOLV_WRAPPER_CONF} = $env_vars->{RESOLV_WRAPPER_CONF}; 1021 } else { 1022 $ENV{RESOLV_WRAPPER_HOSTS} = $env_vars->{RESOLV_WRAPPER_HOSTS}; 1023 } 1024 $ENV{UID_WRAPPER_ROOT} = "1"; 1025 1026 $ENV{ENVNAME} = "$ENV{ENVNAME}.smbd"; 393 1027 394 1028 if ($smbd ne "yes") { … … 398 1032 exit 0; 399 1033 }; 400 sleep($ maxtime);1034 sleep($self->{server_maxtime}); 401 1035 exit 0; 402 1036 } 403 1037 404 $ENV{MAKE_TEST_BINARY} = $self->binpath("smbd");1038 $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd"); 405 1039 my @optargs = ("-d0"); 406 1040 if (defined($ENV{SMBD_OPTIONS})) { 407 1041 @optargs = split(/ /, $ENV{SMBD_OPTIONS}); 408 1042 } 409 my @preargs = ( $self->binpath("timelimit"), $maxtime);1043 my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime}); 410 1044 if(defined($ENV{SMBD_VALGRIND})) { 411 1045 @preargs = split(/ /,$ENV{SMBD_VALGRIND}); 412 1046 } 413 exec(@preargs, $self->binpath("smbd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!"); 414 } 1047 my @args = ("-F", "--no-process-group", 1048 "-s", $env_vars->{SERVERCONFFILE}, 1049 "-l", $env_vars->{LOGDIR}); 1050 if (not defined($ENV{SMBD_DONT_LOG_STDOUT})) { 1051 push(@args, "--log-stdout"); 1052 } 1053 1054 close($env_vars->{STDIN_PIPE}); 1055 open STDIN, ">&", \*STDIN_READER or die "can't dup STDIN_READER to STDIN: $!"; 1056 1057 exec(@preargs, $ENV{MAKE_TEST_BINARY}, @args, @optargs) 1058 or die("Unable to start $ENV{MAKE_TEST_BINARY}: $!"); 1059 } 1060 $env_vars->{SMBD_TL_PID} = $pid; 415 1061 write_pid($env_vars, "smbd", $pid); 416 1062 print "DONE\n"; 417 1063 418 return 0; 419 } 420 421 sub provision($$$$$$) 1064 close(STDIN_READER); 1065 1066 return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd); 1067 } 1068 1069 sub createuser($$$$) 422 1070 { 423 my ($self, $prefix, $server, $swiface, $password, $extra_options) = @_; 1071 my ($self, $username, $password, $conffile) = @_; 1072 my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null"; 1073 unless (open(PWD, "|$cmd")) { 1074 warn("Unable to set password for $username account\n$cmd"); 1075 return undef; 1076 } 1077 print PWD "$password\n$password\n"; 1078 unless (close(PWD)) { 1079 warn("Unable to set password for $username account\n$cmd"); 1080 return undef; 1081 } 1082 print "DONE\n"; 1083 } 1084 1085 sub provision($$$$$$$$) 1086 { 1087 my ($self, $prefix, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_; 424 1088 425 1089 ## … … 427 1091 ## 428 1092 1093 my $swiface = Samba::get_interface($server); 429 1094 my %ret = (); 430 1095 my $server_ip = "127.0.0.$swiface"; 1096 my $server_ipv6 = sprintf("fd00:0000:0000:0000:0000:0000:5357:5f%02x", $swiface); 431 1097 my $domain = "SAMBA-TEST"; 432 1098 … … 439 1105 my $prefix_abs = abs_path($prefix); 440 1106 my $bindir_abs = abs_path($self->{bindir}); 441 my $vfs_modulesdir_abs = ($ENV{VFSLIBDIR} or $bindir_abs);442 1107 443 1108 my @dirs = (); … … 481 1146 my $msdfs_deeppath="$msdfs_shrdir/deeppath"; 482 1147 push(@dirs,$msdfs_deeppath); 1148 1149 my $badnames_shrdir="$shrdir/badnames"; 1150 push(@dirs,$badnames_shrdir); 1151 1152 my $lease1_shrdir="$shrdir/SMB2_10"; 1153 push(@dirs,$lease1_shrdir); 1154 1155 my $lease2_shrdir="$shrdir/SMB3_00"; 1156 push(@dirs,$lease2_shrdir); 1157 1158 my $manglenames_shrdir="$shrdir/manglenames"; 1159 push(@dirs,$manglenames_shrdir); 1160 1161 my $widelinks_shrdir="$shrdir/widelinks"; 1162 push(@dirs,$widelinks_shrdir); 1163 1164 my $widelinks_linkdir="$shrdir/widelinks_foo"; 1165 push(@dirs,$widelinks_linkdir); 1166 1167 my $shadow_tstdir="$shrdir/shadow"; 1168 push(@dirs,$shadow_tstdir); 1169 my $shadow_mntdir="$shadow_tstdir/mount"; 1170 push(@dirs,$shadow_mntdir); 1171 my $shadow_basedir="$shadow_mntdir/base"; 1172 push(@dirs,$shadow_basedir); 1173 my $shadow_shrdir="$shadow_basedir/share"; 1174 push(@dirs,$shadow_shrdir); 483 1175 484 1176 # this gets autocreated by winbindd … … 497 1189 mkdir($prefix_abs, 0777); 498 1190 print "CREATE TEST ENVIRONMENT IN '$prefix'..."; 499 system("rm -rf $prefix_abs/*"); 1191 if (not defined($no_delete_prefix) or not $no_delete_prefix) { 1192 system("rm -rf $prefix_abs/*"); 1193 } 500 1194 mkdir($_, 0777) foreach(@dirs); 1195 1196 my $fs_specific_conf = $self->get_fs_specific_conf($shrdir); 1197 1198 ## 1199 ## lockdir and piddir must be 0755 1200 ## 1201 chmod 0755, $lockdir; 1202 chmod 0755, $piddir; 1203 501 1204 502 1205 ## … … 506 1209 chmod 0755, $ro_shrdir; 507 1210 my $unreadable_file = "$ro_shrdir/unreadable_file"; 508 open(UNREADABLE_FILE, ">$unreadable_file") or die("Unable to open $unreadable_file"); 1211 unless (open(UNREADABLE_FILE, ">$unreadable_file")) { 1212 warn("Unable to open $unreadable_file"); 1213 return undef; 1214 } 509 1215 close(UNREADABLE_FILE); 510 1216 chmod 0600, $unreadable_file; 511 1217 512 1218 my $msdfs_target = "$ro_shrdir/msdfs-target"; 513 open(MSDFS_TARGET, ">$msdfs_target") or die("Unable to open $msdfs_target"); 1219 unless (open(MSDFS_TARGET, ">$msdfs_target")) { 1220 warn("Unable to open $msdfs_target"); 1221 return undef; 1222 } 514 1223 close(MSDFS_TARGET); 515 1224 chmod 0666, $msdfs_target; 516 symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/msdfs-src1"; 517 symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2"; 1225 symlink "msdfs:$server_ip\\ro-tmp,$server_ipv6\\ro-tmp", 1226 "$msdfs_shrdir/msdfs-src1"; 1227 symlink "msdfs:$server_ipv6\\ro-tmp", "$msdfs_shrdir/deeppath/msdfs-src2"; 1228 1229 ## 1230 ## create bad names in $badnames_shrdir 1231 ## 1232 ## (An invalid name, would be mangled to 8.3). 1233 my $badname_target = "$badnames_shrdir/\340|\231\216\377\177"; 1234 unless (open(BADNAME_TARGET, ">$badname_target")) { 1235 warn("Unable to open $badname_target"); 1236 return undef; 1237 } 1238 close(BADNAME_TARGET); 1239 chmod 0666, $badname_target; 1240 1241 ## (A bad name, would not be mangled to 8.3). 1242 my $badname_target = "$badnames_shrdir/\240\276\346\327\377\177"; 1243 unless (open(BADNAME_TARGET, ">$badname_target")) { 1244 warn("Unable to open $badname_target"); 1245 return undef; 1246 } 1247 close(BADNAME_TARGET); 1248 chmod 0666, $badname_target; 1249 1250 ## (A bad good name). 1251 my $badname_target = "$badnames_shrdir/blank.txt"; 1252 unless (open(BADNAME_TARGET, ">$badname_target")) { 1253 warn("Unable to open $badname_target"); 1254 return undef; 1255 } 1256 close(BADNAME_TARGET); 1257 chmod 0666, $badname_target; 1258 1259 ## 1260 ## create mangleable directory names in $manglenames_shrdir 1261 ## 1262 my $manglename_target = "$manglenames_shrdir/foo:bar"; 1263 mkdir($manglename_target, 0777); 1264 1265 ## 1266 ## create symlinks for widelinks tests. 1267 ## 1268 my $widelinks_target = "$widelinks_linkdir/target"; 1269 unless (open(WIDELINKS_TARGET, ">$widelinks_target")) { 1270 warn("Unable to open $widelinks_target"); 1271 return undef; 1272 } 1273 close(WIDELINKS_TARGET); 1274 chmod 0666, $widelinks_target; 1275 ## 1276 ## This link should get ACCESS_DENIED 1277 ## 1278 symlink "$widelinks_target", "$widelinks_shrdir/source"; 1279 ## 1280 ## This link should be allowed 1281 ## 1282 symlink "$widelinks_shrdir", "$widelinks_shrdir/dot"; 518 1283 519 1284 my $conffile="$libdir/server.conf"; 1285 my $dfqconffile="$libdir/dfq.conf"; 520 1286 521 1287 my $nss_wrapper_pl = "$ENV{PERL} $self->{srcdir}/lib/nss_wrapper/nss_wrapper.pl"; 522 1288 my $nss_wrapper_passwd = "$privatedir/passwd"; 523 1289 my $nss_wrapper_group = "$privatedir/group"; 1290 my $nss_wrapper_hosts = "$ENV{SELFTEST_PREFIX}/hosts"; 1291 my $resolv_conf = "$privatedir/resolv.conf"; 1292 my $dns_host_file = "$ENV{SELFTEST_PREFIX}/dns_host_file"; 524 1293 525 1294 my $mod_printer_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/printing/modprinter.pl"; 526 1295 1296 my $fake_snap_pl = "$ENV{PERL} $self->{srcdir}/source3/script/tests/fake_snap.pl"; 1297 527 1298 my @eventlog_list = ("dns server", "application"); 528 1299 … … 532 1303 533 1304 my ($max_uid, $max_gid); 534 my ($uid_nobody, $uid_root); 535 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers); 536 537 if ($unix_uid < 0xffff - 2) { 1305 my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup); 1306 my ($uid_pdbtest_wkn); 1307 my ($uid_smbget); 1308 my ($uid_force_user); 1309 my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins); 1310 my ($gid_userdup, $gid_everyone); 1311 my ($gid_force_user); 1312 1313 if ($unix_uid < 0xffff - 7) { 538 1314 $max_uid = 0xffff; 539 1315 } else { … … 543 1319 $uid_root = $max_uid - 1; 544 1320 $uid_nobody = $max_uid - 2; 545 546 if ($unix_gids[0] < 0xffff - 3) { 1321 $uid_pdbtest = $max_uid - 3; 1322 $uid_pdbtest2 = $max_uid - 4; 1323 $uid_userdup = $max_uid - 5; 1324 $uid_pdbtest_wkn = $max_uid - 6; 1325 $uid_force_user = $max_uid - 7; 1326 $uid_smbget = $max_uid - 8; 1327 1328 if ($unix_gids[0] < 0xffff - 8) { 547 1329 $max_gid = 0xffff; 548 1330 } else { … … 554 1336 $gid_root = $max_gid - 3; 555 1337 $gid_domusers = $max_gid - 4; 1338 $gid_domadmins = $max_gid - 5; 1339 $gid_userdup = $max_gid - 6; 1340 $gid_everyone = $max_gid - 7; 1341 $gid_force_user = $max_gid - 8; 556 1342 557 1343 ## … … 559 1345 ## 560 1346 561 open(CONF, ">$conffile") or die("Unable to open $conffile"); 1347 unless (open(CONF, ">$conffile")) { 1348 warn("Unable to open $conffile"); 1349 return undef; 1350 } 562 1351 print CONF " 563 1352 [global] 564 1353 netbios name = $server 565 interfaces = $server_ip/8 1354 interfaces = $server_ip/8 $server_ipv6/64 566 1355 bind interfaces only = yes 567 panic action = $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY) 1356 panic action = cd $self->{srcdir} && $self->{srcdir}/selftest/gdb_backtrace %d %\$(MAKE_TEST_BINARY) 1357 smbd:suicide mode = yes 568 1358 569 1359 workgroup = $domain … … 573 1363 lock directory = $lockdir 574 1364 log file = $logdir/log.\%m 575 log level = 01365 log level = 1 576 1366 debug pid = yes 577 578 name resolve order = bcast 1367 max log size = 0 579 1368 580 1369 state directory = $lockdir … … 600 1389 kernel oplocks = no 601 1390 kernel change notify = no 602 603 syslog = no 1391 smb2 leases = yes 1392 1393 logging = file 604 1394 printing = bsd 605 1395 printcap name = /dev/null 606 1396 607 winbindd :socket dir= $wbsockdir1397 winbindd socket directory = $wbsockdir 608 1398 nmbd:socket dir = $nmbdsockdir 609 1399 idmap config * : range = 100000-200000 610 1400 winbind enum users = yes 611 1401 winbind enum groups = yes 1402 winbind separator = / 612 1403 613 1404 # min receivefile size = 4000 614 1405 615 max protocol = SMB2616 1406 read only = no 617 1407 server signing = auto 618 1408 619 1409 smbd:sharedelay = 100000 620 #smbd:writetimeupdatedelay = 5000001410 smbd:writetimeupdatedelay = 500000 621 1411 map hidden = no 622 1412 map system = no … … 624 1414 store dos attributes = yes 625 1415 create mask = 755 626 vfs objects = $vfs_modulesdir_abs/xattr_tdb.so $vfs_modulesdir_abs/streams_depot.so 1416 dos filemode = yes 1417 strict rename = yes 1418 strict sync = yes 1419 vfs objects = acl_xattr fake_acls xattr_tdb streams_depot 627 1420 628 1421 printing = vlp … … 635 1428 queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p 636 1429 lpq cache time = 0 637 638 ncalrpc dir = $lockdir/ncalrpc 639 rpc_server:epmapper = embedded 1430 print notify backchannel = yes 1431 1432 ncalrpc dir = $prefix_abs/ncalrpc 1433 1434 # The samba3.blackbox.smbclient_s3 test uses this to test that 1435 # sending messages works, and that the %m sub works. 1436 message command = mv %s $shrdir/message.%m 1437 1438 # fsrvp server requires registry shares 1439 registry shares = yes 1440 1441 # Used by RPC SRVSVC tests 1442 add share command = $bindir_abs/smbaddshare 1443 change share command = $bindir_abs/smbchangeshare 1444 delete share command = $bindir_abs/smbdeleteshare 1445 1446 # fruit:copyfile is a global option 1447 fruit:copyfile = yes 1448 1449 #this does not mean that we use non-secure test env, 1450 #it just means we ALLOW one to be configured. 1451 allow insecure wide links = yes 640 1452 641 1453 # Begin extra options … … 653 1465 [tmp] 654 1466 path = $shrdir 655 comment = smb username is [%U] 656 vfs objects = $vfs_modulesdir_abs/dirsort.so 1467 comment = smb username is [%U] 1468 [tmpsort] 1469 path = $shrdir 1470 comment = Load dirsort module 1471 vfs objects = dirsort acl_xattr fake_acls xattr_tdb streams_depot 1472 [tmpenc] 1473 path = $shrdir 1474 comment = encrypt smb username is [%U] 1475 smb encrypt = required 1476 vfs objects = dirsort 657 1477 [tmpguest] 658 1478 path = $shrdir … … 666 1486 force user = $unix_name 667 1487 guest ok = yes 1488 [forceuser_unixonly] 1489 comment = force a user with unix user SID and group SID 1490 path = $shrdir 1491 force user = pdbtest 1492 guest ok = yes 1493 [forceuser_wkngroup] 1494 comment = force a user with well-known group SID 1495 path = $shrdir 1496 force user = pdbtest_wkn 1497 guest ok = yes 668 1498 [forcegroup] 669 1499 path = $shrdir … … 673 1503 path = $ro_shrdir 674 1504 guest ok = yes 1505 [write-list-tmp] 1506 path = $shrdir 1507 read only = yes 1508 write list = $unix_name 1509 [valid-users-tmp] 1510 path = $shrdir 1511 valid users = $unix_name 675 1512 [msdfs-share] 676 1513 path = $msdfs_shrdir 677 1514 msdfs root = yes 1515 msdfs shuffle referrals = yes 678 1516 guest ok = yes 679 1517 [hideunread] … … 686 1524 copy = tmp 687 1525 hide unwriteable files = yes 1526 [durable] 1527 copy = tmp 1528 kernel share modes = no 1529 kernel oplocks = no 1530 posix locking = no 1531 [fs_specific] 1532 copy = tmp 1533 $fs_specific_conf 688 1534 [print1] 689 1535 copy = tmp … … 694 1540 [print3] 695 1541 copy = print1 1542 default devmode = no 696 1543 [lp] 697 1544 copy = print1 1545 1546 [nfs4acl_simple] 1547 path = $shrdir 1548 comment = smb username is [%U] 1549 nfs4:mode = simple 1550 vfs objects = nfs4acl_xattr xattr_tdb 1551 1552 [nfs4acl_special] 1553 path = $shrdir 1554 comment = smb username is [%U] 1555 nfs4:mode = special 1556 vfs objects = nfs4acl_xattr xattr_tdb 1557 1558 [xcopy_share] 1559 path = $shrdir 1560 comment = smb username is [%U] 1561 create mask = 777 1562 force create mode = 777 1563 [posix_share] 1564 path = $shrdir 1565 comment = smb username is [%U] 1566 create mask = 0777 1567 force create mode = 0 1568 directory mask = 0777 1569 force directory mode = 0 1570 vfs objects = xattr_tdb 1571 [aio] 1572 copy = tmp 1573 aio read size = 1 1574 aio write size = 1 1575 698 1576 [print\$] 699 1577 copy = tmp 1578 1579 [vfs_fruit] 1580 path = $shrdir 1581 vfs objects = catia fruit streams_xattr acl_xattr 1582 ea support = yes 1583 fruit:ressource = file 1584 fruit:metadata = netatalk 1585 fruit:locking = netatalk 1586 fruit:encoding = native 1587 1588 [badname-tmp] 1589 path = $badnames_shrdir 1590 guest ok = yes 1591 1592 [manglenames_share] 1593 path = $manglenames_shrdir 1594 guest ok = yes 1595 1596 [dynamic_share] 1597 path = $shrdir/%R 1598 guest ok = yes 1599 1600 [widelinks_share] 1601 path = $widelinks_shrdir 1602 wide links = no 1603 guest ok = yes 1604 1605 [fsrvp_share] 1606 path = $shrdir 1607 comment = fake shapshots using rsync 1608 vfs objects = shell_snap shadow_copy2 1609 shell_snap:check path command = $fake_snap_pl --check 1610 shell_snap:create command = $fake_snap_pl --create 1611 shell_snap:delete command = $fake_snap_pl --delete 1612 # a relative path here fails, the snapshot dir is no longer found 1613 shadow:snapdir = $shrdir/.snapshots 1614 1615 [shadow1] 1616 path = $shadow_shrdir 1617 comment = previous versions snapshots under mount point 1618 vfs objects = shadow_copy2 1619 shadow:mountpoint = $shadow_mntdir 1620 1621 [shadow2] 1622 path = $shadow_shrdir 1623 comment = previous versions snapshots outside mount point 1624 vfs objects = shadow_copy2 1625 shadow:mountpoint = $shadow_mntdir 1626 shadow:snapdir = $shadow_tstdir/.snapshots 1627 1628 [shadow3] 1629 path = $shadow_shrdir 1630 comment = previous versions with subvolume snapshots, snapshots under base dir 1631 vfs objects = shadow_copy2 1632 shadow:mountpoint = $shadow_mntdir 1633 shadow:basedir = $shadow_basedir 1634 shadow:snapdir = $shadow_basedir/.snapshots 1635 1636 [shadow4] 1637 path = $shadow_shrdir 1638 comment = previous versions with subvolume snapshots, snapshots outside mount point 1639 vfs objects = shadow_copy2 1640 shadow:mountpoint = $shadow_mntdir 1641 shadow:basedir = $shadow_basedir 1642 shadow:snapdir = $shadow_tstdir/.snapshots 1643 1644 [shadow5] 1645 path = $shadow_shrdir 1646 comment = previous versions at volume root snapshots under mount point 1647 vfs objects = shadow_copy2 1648 shadow:mountpoint = $shadow_shrdir 1649 1650 [shadow6] 1651 path = $shadow_shrdir 1652 comment = previous versions at volume root snapshots outside mount point 1653 vfs objects = shadow_copy2 1654 shadow:mountpoint = $shadow_shrdir 1655 shadow:snapdir = $shadow_tstdir/.snapshots 1656 1657 [shadow7] 1658 path = $shadow_shrdir 1659 comment = previous versions snapshots everywhere 1660 vfs objects = shadow_copy2 1661 shadow:mountpoint = $shadow_mntdir 1662 shadow:snapdirseverywhere = yes 1663 1664 [shadow8] 1665 path = $shadow_shrdir 1666 comment = previous versions using snapsharepath 1667 vfs objects = shadow_copy2 1668 shadow:mountpoint = $shadow_mntdir 1669 shadow:snapdir = $shadow_tstdir/.snapshots 1670 shadow:snapsharepath = share 1671 1672 [shadow_wl] 1673 path = $shadow_shrdir 1674 comment = previous versions with wide links allowed 1675 vfs objects = shadow_copy2 1676 shadow:mountpoint = $shadow_mntdir 1677 wide links = yes 1678 [dfq] 1679 path = $shrdir/dfree 1680 vfs objects = fake_dfq 1681 admin users = $unix_name 1682 include = $dfqconffile 700 1683 "; 701 1684 close(CONF); 702 1685 1686 unless (open(DFQCONF, ">$dfqconffile")) { 1687 warn("Unable to open $dfqconffile"); 1688 return undef; 1689 } 1690 close(DFQCONF); 1691 703 1692 ## 704 1693 ## create a test account 705 1694 ## 706 1695 707 open(PASSWD, ">$nss_wrapper_passwd") or die("Unable to open $nss_wrapper_passwd"); 1696 unless (open(PASSWD, ">$nss_wrapper_passwd")) { 1697 warn("Unable to open $nss_wrapper_passwd"); 1698 return undef; 1699 } 708 1700 print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false 709 1701 $unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false 1702 pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false 1703 pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false 1704 userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false 1705 pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false 1706 force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false 1707 smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false 710 1708 "; 711 1709 if ($unix_uid != 0) { 712 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false"; 1710 print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false 1711 "; 713 1712 } 714 1713 close(PASSWD); 715 1714 716 open(GROUP, ">$nss_wrapper_group") or die("Unable to open $nss_wrapper_group"); 1715 unless (open(GROUP, ">$nss_wrapper_group")) { 1716 warn("Unable to open $nss_wrapper_group"); 1717 return undef; 1718 } 717 1719 print GROUP "nobody:x:$gid_nobody: 718 1720 nogroup:x:$gid_nogroup:nobody 719 1721 $unix_name-group:x:$unix_gids[0]: 720 1722 domusers:X:$gid_domusers: 1723 domadmins:X:$gid_domadmins: 1724 userdup:x:$gid_userdup:$unix_name 1725 everyone:x:$gid_everyone: 1726 force_user:x:$gid_force_user: 721 1727 "; 722 1728 if ($unix_gids[0] != 0) { 723 print GROUP "root:x:$gid_root:"; 1729 print GROUP "root:x:$gid_root: 1730 "; 724 1731 } 725 1732 726 1733 close(GROUP); 1734 1735 ## hosts 1736 my $hostname = lc($server); 1737 unless (open(HOSTS, ">>$nss_wrapper_hosts")) { 1738 warn("Unable to open $nss_wrapper_hosts"); 1739 return undef; 1740 } 1741 print HOSTS "${server_ip} ${hostname}.samba.example.com ${hostname}\n"; 1742 print HOSTS "${server_ipv6} ${hostname}.samba.example.com ${hostname}\n"; 1743 close(HOSTS); 1744 1745 ## hosts 1746 unless (open(RESOLV_CONF, ">$resolv_conf")) { 1747 warn("Unable to open $resolv_conf"); 1748 return undef; 1749 } 1750 if (defined($dc_server_ip) or defined($dc_server_ipv6)) { 1751 if (defined($dc_server_ip)) { 1752 print RESOLV_CONF "nameserver $dc_server_ip\n"; 1753 } 1754 if (defined($dc_server_ipv6)) { 1755 print RESOLV_CONF "nameserver $dc_server_ipv6\n"; 1756 } 1757 } else { 1758 print RESOLV_CONF "nameserver ${server_ip}\n"; 1759 print RESOLV_CONF "nameserver ${server_ipv6}\n"; 1760 } 1761 close(RESOLV_CONF); 727 1762 728 1763 foreach my $evlog (@eventlog_list) { … … 734 1769 $ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd; 735 1770 $ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group; 736 737 open(PWD, "|".$self->binpath("smbpasswd")." -c $conffile -L -s -a $unix_name >/dev/null"); 738 print PWD "$password\n$password\n"; 739 close(PWD) or die("Unable to set password for test account"); 740 741 print "DONE\n"; 1771 $ENV{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts; 1772 $ENV{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com"; 1773 if ($ENV{SAMBA_DNS_FAKING}) { 1774 $ENV{RESOLV_WRAPPER_CONF} = $resolv_conf; 1775 } else { 1776 $ENV{RESOLV_WRAPPER_HOSTS} = $dns_host_file; 1777 } 1778 1779 createuser($self, $unix_name, $password, $conffile) || die("Unable to create user"); 1780 createuser($self, "force_user", $password, $conffile) || die("Unable to create force_user"); 1781 createuser($self, "smbget_user", $password, $conffile) || die("Unable to create smbget_user"); 1782 1783 open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list"); 1784 print DNS_UPDATE_LIST "A $server. $server_ip\n"; 1785 print DNS_UPDATE_LIST "AAAA $server. $server_ipv6\n"; 1786 close(DNS_UPDATE_LIST); 742 1787 743 1788 $ret{SERVER_IP} = $server_ip; 1789 $ret{SERVER_IPV6} = $server_ipv6; 744 1790 $ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log"; 745 1791 $ret{NMBD_TEST_LOG_POS} = 0; … … 757 1803 $ret{PASSWORD} = $password; 758 1804 $ret{PIDDIR} = $piddir; 759 $ret{ WINBINDD_SOCKET_DIR} = $wbsockdir;1805 $ret{SELFTEST_WINBINDD_SOCKET_DIR} = $wbsockdir; 760 1806 $ret{WINBINDD_PRIV_PIPE_DIR} = $wbsockprivdir; 761 1807 $ret{NMBD_SOCKET_DIR} = $nmbdsockdir; … … 763 1809 $ret{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd; 764 1810 $ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group; 765 $ret{NSS_WRAPPER_WINBIND_SO_PATH} = $ENV{NSS_WRAPPER_WINBIND_SO_PATH}; 1811 $ret{NSS_WRAPPER_HOSTS} = $nss_wrapper_hosts; 1812 $ret{NSS_WRAPPER_HOSTNAME} = "${hostname}.samba.example.com"; 1813 $ret{NSS_WRAPPER_MODULE_SO_PATH} = Samba::nss_wrapper_winbind_so_path($self); 1814 $ret{NSS_WRAPPER_MODULE_FN_PREFIX} = "winbind"; 1815 if ($ENV{SAMBA_DNS_FAKING}) { 1816 $ret{RESOLV_WRAPPER_HOSTS} = $dns_host_file; 1817 } else { 1818 $ret{RESOLV_WRAPPER_CONF} = $resolv_conf; 1819 } 766 1820 $ret{LOCAL_PATH} = "$shrdir"; 1821 $ret{LOGDIR} = $logdir; 1822 1823 # 1824 # Avoid hitting system krb5.conf - 1825 # An env that needs Kerberos will reset this to the real 1826 # value. 1827 # 1828 $ret{KRB5_CONFIG} = abs_path($prefix) . "/no_krb5.conf"; 767 1829 768 1830 return \%ret; 769 1831 } 770 1832 771 sub wait_for_start($$ )1833 sub wait_for_start($$$$$) 772 1834 { 773 my ($self, $envvars) = @_; 774 775 # give time for nbt server to register its names 776 print "delaying for nbt name registration\n"; 777 sleep(10); 778 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init 779 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__"); 780 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} __SAMBA__"); 781 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__"); 782 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}"); 783 system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} $envvars->{SERVER}"); 784 # make sure smbd is also up set 785 print "wait for smbd\n"; 786 system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2"); 787 system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER_IP} -U% -p 139 | head -2"); 1835 my ($self, $envvars, $nmbd, $winbindd, $smbd) = @_; 1836 my $ret; 1837 1838 if ($nmbd eq "yes") { 1839 my $count = 0; 1840 1841 # give time for nbt server to register its names 1842 print "checking for nmbd\n"; 1843 1844 # This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init 1845 my $nmblookup = Samba::bindir_path($self, "nmblookup"); 1846 1847 do { 1848 $ret = system("$nmblookup $envvars->{CONFIGURATION} $envvars->{SERVER}"); 1849 if ($ret != 0) { 1850 sleep(1); 1851 } else { 1852 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__"); 1853 system("$nmblookup $envvars->{CONFIGURATION} __SAMBA__"); 1854 system("$nmblookup $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__"); 1855 system("$nmblookup $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}"); 1856 } 1857 $count++; 1858 } while ($ret != 0 && $count < 10); 1859 if ($count == 10) { 1860 print "NMBD not reachable after 10 retries\n"; 1861 teardown_env($self, $envvars); 1862 return 0; 1863 } 1864 } 1865 1866 if ($winbindd eq "yes") { 1867 print "checking for winbindd\n"; 1868 my $count = 0; 1869 do { 1870 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --ping-dc"); 1871 if ($ret != 0) { 1872 sleep(2); 1873 } 1874 $count++; 1875 } while ($ret != 0 && $count < 10); 1876 if ($count == 10) { 1877 print "WINBINDD not reachable after 20 seconds\n"; 1878 teardown_env($self, $envvars); 1879 return 0; 1880 } 1881 } 1882 1883 if ($smbd eq "yes") { 1884 # make sure smbd is also up set 1885 print "wait for smbd\n"; 1886 1887 my $count = 0; 1888 do { 1889 $ret = system(Samba::bindir_path($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139"); 1890 if ($ret != 0) { 1891 sleep(2); 1892 } 1893 $count++ 1894 } while ($ret != 0 && $count < 10); 1895 if ($count == 10) { 1896 print "SMBD failed to start up in a reasonable time (20sec)\n"; 1897 teardown_env($self, $envvars); 1898 return 0; 1899 } 1900 } 788 1901 789 1902 # Ensure we have domain users mapped. 790 system($self->binpath("net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain"); 1903 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain"); 1904 if ($ret != 0) { 1905 return 1; 1906 } 1907 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=512 unixgroup=domadmins type=domain"); 1908 if ($ret != 0) { 1909 return 1; 1910 } 1911 $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add sid=S-1-1-0 unixgroup=everyone type=builtin"); 1912 if ($ret != 0) { 1913 return 1; 1914 } 1915 1916 if ($winbindd eq "yes") { 1917 # note: creating builtin groups requires winbindd for the 1918 # unix id allocator 1919 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} sam createbuiltingroup Users"); 1920 if ($ret != 0) { 1921 print "Failed to create BUILTIN\\Users group\n"; 1922 return 0; 1923 } 1924 my $count = 0; 1925 do { 1926 system(Samba::bindir_path($self, "net") . " $envvars->{CONFIGURATION} cache flush"); 1927 $ret = system("SELFTEST_WINBINDD_SOCKET_DIR=" . $envvars->{SELFTEST_WINBINDD_SOCKET_DIR} . " " . Samba::bindir_path($self, "wbinfo") . " --sid-to-gid=S-1-5-32-545"); 1928 if ($ret != 0) { 1929 sleep(2); 1930 } 1931 $count++; 1932 } while ($ret != 0 && $count < 10); 1933 if ($count == 10) { 1934 print "WINBINDD not reachable after 20 seconds\n"; 1935 teardown_env($self, $envvars); 1936 return 0; 1937 } 1938 } 791 1939 792 1940 print $self->getlog_env($envvars); 1941 1942 return 1; 793 1943 } 794 1944
Note:
See TracChangeset
for help on using the changeset viewer.