From 20d73f768d002faf62f760f99c608f139b229491 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 19 Mar 2010 10:23:39 +0100 Subject: s3-selftest: rearrange uid/gid calculation to achieve correct membership. Guenther --- selftest/target/Samba3.pm | 58 +++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'selftest/target') diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 18e3483d32..94c2f95135 100644 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -443,6 +443,37 @@ sub provision($$$$$$) my @eventlog_list = ("dns server", "application"); + ## + ## calculate uids and gids + ## + + my ($max_uid, $max_gid); + my ($uid_nobody, $uid_root); + my ($gid_nobody, $gid_nogroup, $gid_root); + + if ($unix_uid < 0xffff - 2) { + $max_uid = 0xffff; + } else { + $max_uid = $unix_uid; + } + + $uid_root = $max_uid - 1; + $uid_nobody = $max_uid - 2; + + if ($unix_gids[0] < 0xffff - 3) { + $max_gid = 0xffff; + } else { + $max_gid = $unix_gids[0]; + } + + $gid_nobody = $max_gid - 1; + $gid_nogroup = $max_gid - 2; + $gid_root = $max_gid - 3; + + ## + ## create conffile + ## + open(CONF, ">$conffile") or die("Unable to open $conffile"); print CONF " [global] @@ -468,9 +499,9 @@ sub provision($$$$$$) time server = yes - add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u + add user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup add group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action add --name %g - add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u + add machine script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action add --name %u --gid $gid_nogroup add user to group script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type member --action add --member %u --name %g --group_path $nss_wrapper_group delete user script = $nss_wrapper_pl --passwd_path $nss_wrapper_passwd --type passwd --action delete --name %u delete group script = $nss_wrapper_pl --group_path $nss_wrapper_group --type group --action delete --name %g @@ -549,29 +580,6 @@ sub provision($$$$$$) ## create a test account ## - my ($max_uid, $max_gid); - my ($uid_nobody, $uid_root); - my ($gid_nobody, $gid_nogroup, $gid_root); - - if ($unix_uid < 0xffff - 2) { - $max_uid = 0xffff; - } else { - $max_uid = $unix_uid; - } - - $uid_root = $max_uid - 1; - $uid_nobody = $max_uid - 2; - - if ($unix_gids[0] < 0xffff - 3) { - $max_gid = 0xffff; - } else { - $max_gid = $unix_gids[0]; - } - - $gid_nobody = $max_gid - 1; - $gid_nogroup = $max_gid - 2; - $gid_root = $max_gid - 3; - open(PASSWD, ">$nss_wrapper_passwd") or die("Unable to open $nss_wrapper_passwd"); 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 -- cgit