use target::Samba;
sub new($$) {
- my ($classname, $bindir, $binary_mapping, $srcdir, $exeext, $server_maxtime) = @_;
- $exeext = "" unless defined($exeext);
+ my ($classname, $bindir, $binary_mapping, $srcdir, $server_maxtime) = @_;
my $self = { vars => {},
bindir => $bindir,
binary_mapping => $binary_mapping,
srcdir => $srcdir,
- exeext => $exeext,
server_maxtime => $server_maxtime
};
bless $self;
{
my ($self, $envname, $path) = @_;
+ if (defined($self->{vars}->{$envname})) {
+ return $self->{vars}->{$envname};
+ }
+
if ($envname eq "s3dc") {
return $self->setup_s3dc("$path/s3dc");
} elsif ($envname eq "secshare") {
return $self->setup_secshare("$path/secshare");
+ } elsif ($envname eq "maptoguest") {
+ return $self->setup_maptoguest("$path/maptoguest");
} elsif ($envname eq "ktest") {
return $self->setup_ktest("$path/ktest");
} elsif ($envname eq "secserver") {
}
return $self->setup_member("$path/member", $self->{vars}->{s3dc});
} else {
- return undef;
+ return "UNKNOWN";
}
}
$ctx->{realm} = $dcvars->{REALM};
$ctx->{dnsname} = lc($dcvars->{REALM});
$ctx->{kdc_ipv4} = $dcvars->{SERVER_IP};
- Samba::mk_krb5_conf($ctx);
+ Samba::mk_krb5_conf($ctx, "");
$ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
return undef;
}
+ # We need world access to this share, as otherwise the domain
+ # administrator from the AD domain provided by Samba4 can't
+ # access the share for tests.
+ chmod 0777, "$prefix/share";
+
$self->check_or_start($ret,
"yes", "yes", "yes");
$self->wait_for_start($ret);
- my $smbcacls = Samba::bindir_path($self, "smbcacls");
- #Allow domain users to manipulate the share
- $cmd = "";
- $cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
- $cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
- $cmd .= "$smbcacls $ret->{CONFIGURATION} //127.0.0.29/tmp / -U$ret->{USERNAME}%$ret->{PASSWORD} ";
- $cmd .= "-S ACL:$dcvars->{DOMAIN}\\\\Domain\\ Users:ALLOWED/0x0/FULL";
-
- if (system($cmd) != 0) {
- warn("smbcacls failed, your filesystem may not support ACLs. Try mount $prefix_abs -oremount,acl\nThis support is required for S3 member in S4 tests\n$cmd");
- return undef;
- }
-
$ret->{DC_SERVER} = $dcvars->{SERVER};
$ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
$ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
return $ret;
}
+sub setup_plugin_s4_dc($$$$)
+{
+ my ($self, $prefix, $dcvars, $iface) = @_;
+
+ print "PROVISIONING S4 PLUGIN AD DC$iface...";
+
+ my $plugin_s4_dc_options = "
+ workgroup = $dcvars->{DOMAIN}
+ realm = $dcvars->{REALM}
+
+ security = ads
+ domain logons = yes
+ passdb backend = samba4
+ auth methods = guest samba4
+ server signing = on
+
+ rpc_server:epmapper = disabled
+ rpc_server:rpcecho = disabled
+ rpc_server:dssetup = disabled
+ rpc_server:svctl = disabled
+ rpc_server:ntsvcs = disabled
+ rpc_server:eventlog = disabled
+ rpc_server:initshutdown = disabled
+
+ rpc_server:winreg = embedded
+ rpc_server:srvsvc = embedded
+ rpc_server:netdfs = embedded
+ rpc_server:wkssvc = embedded
+ rpc_server:spoolss = embedded
+
+ rpc_server:lsarpc = external
+ rpc_server:netlogon = external
+ rpc_server:samr = external
+
+ rpc_daemon:epmd = disabled
+ rpc_daemon:lsasd = disabled
+ rpc_daemon:spoolssd = disabled
+
+ rpc_server:tcpip = no
+
+[IPC\$]
+ vfs objects = dfs_samba4
+";
+
+ my $ret = $self->provision($prefix,
+ "plugindc",
+ $iface,
+ "pluGin${iface}Pass",
+ $plugin_s4_dc_options, 1);
+
+ $ret or return undef;
+
+ close(USERMAP);
+ $ret->{DOMAIN} = $dcvars->{DOMAIN};
+ $ret->{REALM} = $dcvars->{REALM};
+ $ret->{KRB5_CONFIG} = $dcvars->{KRB5_CONFIG};
+
+ # We need world access to this share, as otherwise the domain
+ # administrator from the AD domain provided by Samba4 can't
+ # access the share for tests.
+ chmod 0777, "$prefix/share";
+
+ $self->check_or_start($ret,
+ "no", "no", "yes");
+
+ $self->wait_for_start($ret);
+
+ # Special case, this is called from Samba4.pm but needs to use the Samba3 check_env and get_log_env
+ $ret->{target} = $self;
+
+ return $ret;
+}
+
sub setup_secshare($$)
{
my ($self, $path) = @_;
realm = ktest.samba.example.com
security = ads
username map = $prefix/lib/username.map
+ server signing = required
";
my $ret = $self->provision($prefix,
$ctx->{realm} = "KTEST.SAMBA.EXAMPLE.COM";
$ctx->{dnsname} = lc($ctx->{realm});
$ctx->{kdc_ipv4} = "0.0.0.0";
- Samba::mk_krb5_conf($ctx);
+ Samba::mk_krb5_conf($ctx, "");
$ret->{KRB5_CONFIG} = $ctx->{krb5_conf};
system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
chmod 0600, "$prefix/krb5_ccache-3";
+ # We need world access to this share, as otherwise the domain
+ # administrator from the AD domain provided by ktest can't
+ # access the share for tests.
+ chmod 0777, "$prefix/share";
+
$self->check_or_start($ret, "yes", "no", "yes");
if (not $self->wait_for_start($ret)) {
return $ret;
}
+sub setup_maptoguest($$)
+{
+ my ($self, $path) = @_;
+
+ print "PROVISIONING maptoguest...";
+
+ my $options = "
+map to guest = bad user
+";
+
+ my $vars = $self->provision($path,
+ "maptoguest",
+ 7,
+ "maptoguestpass",
+ $options);
+
+ $vars or return undef;
+
+ $self->check_or_start($vars,
+ "yes", "no", "yes");
+
+ if (not $self->wait_for_start($vars)) {
+ return undef;
+ }
+
+ $self->{vars}->{s3maptoguest} = $vars;
+
+ return $vars;
+}
+
sub stop_sig_term($$) {
my ($self, $pid) = @_;
kill("USR1", $pid) or kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
return $pid;
}
-sub check_or_start($$$$) {
+sub check_or_start($$$$$) {
my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
unlink($env_vars->{NMBD_TEST_LOG});
$ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
$ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
+ $ENV{UID_WRAPPER} = "1";
+
if ($nmbd ne "yes") {
$SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
my $signame = shift;
$ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
$ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
+ $ENV{UID_WRAPPER} = "1";
+
if ($winbindd ne "yes") {
$SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
my $signame = shift;
@preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
}
- print "Starting winbindd with config $env_vars->{SERVERCONFFILE})\n";
+ print "Starting winbindd with config $env_vars->{SERVERCONFFILE}\n";
exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "--stdout", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
}
$ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
$ENV{NSS_WRAPPER_WINBIND_SO_PATH} = $env_vars->{NSS_WRAPPER_WINBIND_SO_PATH};
+ $ENV{UID_WRAPPER} = "1";
+
if ($smbd ne "yes") {
$SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
my $signame = shift;
return 0;
}
-sub provision($$$$$$)
+sub provision($$$$$$$)
{
- my ($self, $prefix, $server, $swiface, $password, $extra_options) = @_;
+ my ($self, $prefix, $server, $swiface, $password, $extra_options, $no_delete_prefix) = @_;
##
## setup the various environment variables we need
mkdir($prefix_abs, 0777);
print "CREATE TEST ENVIRONMENT IN '$prefix'...";
- system("rm -rf $prefix_abs/*");
+ if (not defined($no_delete_prefix) or not $no_delete_prefix) {
+ system("rm -rf $prefix_abs/*");
+ }
mkdir($_, 0777) foreach(@dirs);
##
chmod 0755, $ro_shrdir;
my $unreadable_file = "$ro_shrdir/unreadable_file";
- open(UNREADABLE_FILE, ">$unreadable_file") or die("Unable to open $unreadable_file");
+ unless (open(UNREADABLE_FILE, ">$unreadable_file")) {
+ warn("Unable to open $unreadable_file");
+ return undef;
+ }
close(UNREADABLE_FILE);
chmod 0600, $unreadable_file;
my $msdfs_target = "$ro_shrdir/msdfs-target";
- open(MSDFS_TARGET, ">$msdfs_target") or die("Unable to open $msdfs_target");
+ unless (open(MSDFS_TARGET, ">$msdfs_target")) {
+ warn("Unable to open $msdfs_target");
+ return undef;
+ }
close(MSDFS_TARGET);
chmod 0666, $msdfs_target;
symlink "msdfs:$server_ip\\ro-tmp", "$msdfs_shrdir/msdfs-src1";
## create conffile
##
- open(CONF, ">$conffile") or die("Unable to open $conffile");
+ unless (open(CONF, ">$conffile")) {
+ warn("Unable to open $conffile");
+ return undef;
+ }
print CONF "
[global]
netbios name = $server
map readonly = no
store dos attributes = yes
create mask = 755
+ dos filemode = yes
vfs objects = $vfs_modulesdir_abs/xattr_tdb.so $vfs_modulesdir_abs/streams_depot.so
printing = vlp
queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
lpq cache time = 0
- ncalrpc dir = $lockdir/ncalrpc
- rpc_server:epmapper = embedded
+ ncalrpc dir = $prefix_abs/ncalrpc
+ rpc_server:epmapper = external
+ rpc_server:spoolss = external
+ rpc_server:lsarpc = external
+ rpc_server:samr = external
+ rpc_server:netlogon = external
+ rpc_server:tcpip = yes
+
+ rpc_daemon:epmd = fork
+ rpc_daemon:spoolssd = fork
+ rpc_daemon:lsasd = fork
resolv:host file = $dns_host_file
+ # The samba3.blackbox.smbclient_s3 test uses this to test that
+ # sending messages works, and that the %m sub works.
+ message command = mv %s $shrdir/message.%m
+
# Begin extra options
$extra_options
# End extra options
print CONF "
[tmp]
path = $shrdir
+ comment = smb username is [%U]
[tmpguest]
path = $shrdir
guest ok = yes
copy = print1
[lp]
copy = print1
+[xcopy_share]
+ path = $shrdir
+ comment = smb username is [%U]
+ create mask = 777
+ force create mode = 777
[print\$]
copy = tmp
";
## create a test account
##
- open(PASSWD, ">$nss_wrapper_passwd") or die("Unable to open $nss_wrapper_passwd");
+ unless (open(PASSWD, ">$nss_wrapper_passwd")) {
+ warn("Unable to open $nss_wrapper_passwd");
+ return undef;
+ }
print PASSWD "nobody:x:$uid_nobody:$gid_nobody:nobody gecos:$prefix_abs:/bin/false
$unix_name:x:$unix_uid:$unix_gids[0]:$unix_name gecos:$prefix_abs:/bin/false
";
}
close(PASSWD);
- open(GROUP, ">$nss_wrapper_group") or die("Unable to open $nss_wrapper_group");
+ unless (open(GROUP, ">$nss_wrapper_group")) {
+ warn("Unable to open $nss_wrapper_group");
+ return undef;
+ }
print GROUP "nobody:x:$gid_nobody:
nogroup:x:$gid_nogroup:nobody
$unix_name-group:x:$unix_gids[0]:
$ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
$ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
- open(PWD, "|".Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $unix_name >/dev/null");
+ my $cmd = Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $unix_name > /dev/null";
+ unless (open(PWD, "|$cmd")) {
+ warn("Unable to set password for test account\n$cmd");
+ return undef;
+ }
print PWD "$password\n$password\n";
- close(PWD) or die("Unable to set password for test account");
-
+ unless (close(PWD)) {
+ warn("Unable to set password for test account\n$cmd");
+ return undef;
+ }
print "DONE\n";
open(HOSTS, ">>$ENV{SELFTEST_PREFIX}/dns_host_file") or die("Unable to open $ENV{SELFTEST_PREFIX}/dns_host_file");