summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2005-06-28 07:09:13 +0000
committerAntoine Ginies <aginies@mandriva.com>2005-06-28 07:09:13 +0000
commit505d88195467cdc82835d2dcd15ce474523366da (patch)
tree057450388362e93f9a1b94c011c12ecee3ed1f16
parent066a1543df0bab33316606b0cf136c29e4d991d5 (diff)
downloaddrakwizard-505d88195467cdc82835d2dcd15ce474523366da.tar
drakwizard-505d88195467cdc82835d2dcd15ce474523366da.tar.gz
drakwizard-505d88195467cdc82835d2dcd15ce474523366da.tar.bz2
drakwizard-505d88195467cdc82835d2dcd15ce474523366da.tar.xz
drakwizard-505d88195467cdc82835d2dcd15ce474523366da.zip
re-enable valid|read|writel list, now more than one user supported
-rwxr-xr-xsamba_wizard/Sambashare.pm88
1 files changed, 51 insertions, 37 deletions
diff --git a/samba_wizard/Sambashare.pm b/samba_wizard/Sambashare.pm
index 84b76a75..932db9a1 100755
--- a/samba_wizard/Sambashare.pm
+++ b/samba_wizard/Sambashare.pm
@@ -178,35 +178,33 @@ $o->{pages} = {
name => N('Advanced options, step 1') . "\n\n" . N('Advanced options, use them if you know what you are doing.') . "\n" . N('If you choose "Write list" wizard will create the samba user without password. Use: smbpasswd [username] to redefine samba user password.'),
pre => sub {
my $share = $o->{var}{wiz_selected_share};
-# exists $samba->{$share}{'read list'} and $o->{var}{wiz_share_readlist} = $samba->{$share}{'read list'};
+ exists $samba->{$share}{'read list'} and $o->{var}{wiz_share_readlist} = $samba->{$share}{'read list'};
exists $samba->{$share}{'write list'} and $o->{var}{wiz_share_writelist} = $samba->{$share}{'write list'};
exists $samba->{$share}{'hide dot files'} and $o->{var}{wiz_share_dotfiles} = $samba->{$share}{'hide dot files'};
exists $samba->{$share}{'hide files'} and $o->{var}{wiz_share_hidefiles} = $samba->{$share}{'hide files'};
$o->{var}{wiz_owner} = 1;
-# exists $samba->{$share}{'valid users'} and $o->{var}{wiz_share_valid_users} = $samba->{$share}{'valid users'};
-# exists $samba->{$share}{'admin users'} and $o->{var}{wiz_share_admin_users} = $samba->{$share}{'admin users'};
+ exists $samba->{$share}{'valid users'} and $o->{var}{wiz_share_valid_users} = $samba->{$share}{'valid users'};
+ exists $samba->{$share}{'admin users'} and $o->{var}{wiz_share_admin_users} = $samba->{$share}{'admin users'};
},
data => [
-# { label => N('Read list:'), val => \$o->{var}{wiz_share_readlist}, help => N('Specifies a list of user that have read-only access to a writable share. ie: anne') },
+ { label => N('Read list:'), val => \$o->{var}{wiz_share_readlist}, help => N('Specifies a list of user that have read-only access to a writable share. ie: anne') },
{ label => N('Write list:'), val => \$o->{var}{wiz_share_writelist}, help => N('Specifies a user that have read-write access to a share. ie: fred') },
{ label => N('User own directory:'), type => 'bool', val => \$o->{var}{wiz_owner} },
-# { label => N('valid user'), val => \$o->{var}{wiz_share_valid_users}, help => N('To restrict the share to a particular user. If this is empty (the default) then any user can login. ie: guibo') },
-# { label => N('admin users'), val => \$o->{var}{wiz_share_admin_users}, help => N('This is a list of users who will be granted administrative privileges on the share. This means that they will do all file operations as the super-user (root). You should use this option very carefully, as any user in this list will be able to do anything they like on the share, irrespective of file permissions.') },
+ { label => N('valid user'), val => \$o->{var}{wiz_share_valid_users}, help => N('To restrict the share to a particular user. If this is empty (the default) then any user can login. ie: guibo') },
+ { label => N('admin users'), val => \$o->{var}{wiz_share_admin_users}, help => N('This is a list of users who will be granted administrative privileges on the share. This means that they will do all file operations as the super-user (root). You should use this option very carefully, as any user in this list will be able to do anything they like on the share, irrespective of file permissions.') },
{ label => N('Hide files:'), val => \$o->{var}{wiz_share_hidefiles}, help => N("The hide files option provides one or more directory or filename patterns to Samba. Any file matching this pattern will be treated as a hidden file from the perspective of the client. ie: /.icewm/") },
{ label => N('Show dot files:'), val => \$o->{var}{wiz_share_dotfiles}, fixed_list => \@yesorno, help => N("The hide dot files option hides any files on the server that begin with a dot (.)") },
],
- complete => sub {
- map { my $user = $_;
- if ($user and !any { /^$user:/ } cat_("/etc/passwd") ) {
- $::in->ask_warn(N('Error'), N('Please provide a system user, %s not present.', $user));
- return 1; $_
- }
- } $o->{var}{wiz_share_writelist}, $o->{var}{wiz_share_readlist}, $o->{var}{wiz_share_valid_users};
- if ($o->{var}{wiz_share_writelist} !~ /^\w+$/ and $o->{var}{wiz_share_writelist}) {
-# or $o->{var}{wiz_share_readlist} !~ /^\w+$/ and $o->{var}{wiz_share_readlist} or
-# $o->{var}{wiz_share_valid_users} !~ /^\w+$/ and $o->{var}{wiz_share_valid_users}) {
- $::in->ask_warn(N('Error'), N('Please enter a unique user name for: \"write list\".'));
- return 1; }
+ complete => sub {
+ map { my @users = split(" ", $_);
+ foreach my $user (@users) {
+ print "$user\n";
+ if ($user and !any { /^$user:/ } cat_("/etc/passwd") ) {
+ $::in->ask_warn(N('Error'), N('Please provide a system user, %s not present.', $user));
+ return 1; $_
+ }
+ }
+ } $o->{var}{wiz_share_writelist}, $o->{var}{wiz_share_readlist}, $o->{var}{wiz_share_valid_users};
},
next => 'modify_share_options2',
},
@@ -299,25 +297,22 @@ $o->{pages} = {
data => [
{ label => N('Writable:'), val => \$o->{var}{wiz_addshare_writable}, fixed_list => \@yesorno },
{ label => N('Create mask:'), val => \$o->{var}{wiz_addshare_createmask} },
-# { label => N('Read list:'), val => \$o->{var}{wiz_addshare_readlist}, help => N('Specifies a list \of users that have read-only access to a writable share. ie: aginies') },
+ { label => N('Read list:'), val => \$o->{var}{wiz_addshare_readlist}, help => N('Specifies a list \of users that have read-only access to a writable share. ie: aginies') },
{ label => N('Write list:'), val => \$o->{var}{wiz_addshare_writelist}, help => N('Specifie a user that have read-write access to a share. ie: guibo') },
{ label => N('User own directory:'), type => 'bool', val => \$o->{var}{wiz_owner} },
{ label => N('Show dot files:'), val => \$o->{var}{wiz_addshare_dotfiles}, fixed_list => \@yesorno, help => N("The hide dot files option hides any files on the server that begin with a dot (.)") },
{ label => N('Hide files:'), val => \$o->{var}{wiz_addshare_hidefiles}, help => N("The hide files option provides one or more directory or filename patterns to Samba. Any file matching this pattern will be treated as a hidden file from the perspective of the client. ie: /.icewm/") },
],
complete => sub {
- map { my $user = $_;
- if ($user and !any { /^$user:/ } cat_("/etc/passwd") ) {
- $::in->ask_warn(N('Error'), N('Please provide a system user, %s not present.', $user));
- return 1; $_
+ map { my @users = split(" ", $_);
+ foreach my $user (@users) {
+ if ($user and !any { /^$user:/ } cat_("/etc/passwd") ) {
+ $::in->ask_warn(N('Error'), N('Please provide a system user, %s not present.', $user));
+ return 1; $_
+ }
}
- } $o->{var}{wiz_addshare_writelist}; #, $o->{var}{wiz_addshare_readlist};
- if ($o->{var}{wiz_share_writelist} !~ /^\w+$/ and $o->{var}{wiz_share_writelist}) {
- #or $o->{var}{wiz_share_readlist} !~ /^\w+$/ and $o->{var}{wiz_share_readlist}) {
- $::in->ask_warn(N('Error'), N('Please enter a unique user name for: \"write list\" and \"valid user\".'));
- return 1; }
- },
-
+ } $o->{var}{wiz_addshare_writelist}, $o->{var}{wiz_addshare_readlist};
+ },
next => 'summary_addshare',
},
add_homes => {
@@ -390,7 +385,7 @@ $o->{pages} = {
{ label => N('Create mask:'), fixed_val => \$o->{var}{wiz_addshare_createmask} },
{ label => N('Writable:'), fixed_val => \$o->{var}{wiz_addshare_writable} },
{ label => N('Public:'), fixed_val => \$o->{var}{wiz_addshare_public} },
-# { label => N('Read list:'), fixed_val => \$o->{var}{wiz_addshare_readlist} },
+ { label => N('Read list:'), fixed_val => \$o->{var}{wiz_addshare_readlist} },
{ label => N('Write list:'), fixed_val => \$o->{var}{wiz_addshare_writelist} },
{ label => N('Show dot files:'), fixed_val => \$o->{var}{wiz_addshare_dotfiles} },
],
@@ -501,6 +496,14 @@ sub do_it_remove_share {
check_started('smbd');
}
+sub create_smbuser {
+ my ($list)= @_;
+ my @users = split(" ", $list);
+ foreach my $user (@users) {
+ system("smbpasswd -a $user -n");
+ }
+}
+
sub do_it_modify_share {
$::testing and return;
my $in = 'interactive'->vnew('su', 'Samba');
@@ -520,18 +523,25 @@ sub do_it_modify_share {
$o->{var}{wiz_share_public} and $samba->{$share}{public} = $o->{var}{wiz_share_public};
# master level
if ($o->{var}{wiz_understanding} == 2) {
- # $o->{var}{wiz_share_readlist} and $samba->{$share}{'read list'} = $o->{var}{wiz_share_readlist};
+ $o->{var}{wiz_share_readlist} and $samba->{$share}{'read list'} = $o->{var}{wiz_share_readlist};
if ($o->{var}{wiz_share_writelist}) {
$samba->{$share}{'write list'} = $o->{var}{wiz_share_writelist};
if ($o->{var}{wiz_owner}) {
system("chown -R $o->{var}{wiz_share_writelist}.users $o->{var}{wiz_share_path}");
}
- system("smbpasswd -a $o->{var}{wiz_share_writelist} -n");
+ create_smbuser($o->{var}{wiz_share_writelist});
}
+ if ($o->{var}{wiz_share_valid_users}) {
+ $samba->{$share}{'valid users'} = $o->{var}{wiz_share_valid_users};
+ create_smbuser($o->{var}{wiz_share_valid_users});
+ }
+ if ($o->{var}{wiz_share_admin_users}) {
+ $samba->{$share}{'admin users'} = $o->{var}{wiz_share_admin_users};
+ create_smbuser($o->{var}{wiz_share_admin_users});
+ }
+
$o->{var}{wiz_share_dotfiles} and $samba->{$share}{'hide dot files'} = $o->{var}{wiz_share_dotfiles};
$o->{var}{wiz_share_hidefiles} and $samba->{$share}{'hide files'} = $o->{var}{wiz_share_hidefiles};
-# $o->{var}{wiz_share_valid_users} and $samba->{$share}{'valid users'} = $o->{var}{wiz_share_valid_users};
-# $o->{var}{wiz_share_admin_users} and $samba->{$share}{'admin users'} = $o->{var}{wiz_share_admin_users};
$o->{var}{wiz_share_preserve_case} and $samba->{$share}{'preserve case'} = $o->{var}{wiz_share_preserve_case};
$o->{var}{wiz_share_short_preserve_case} and $samba->{$share}{'short preserve case'} = $o->{var}{wiz_share_short_preserve_case};
$o->{var}{wiz_share_create_mask} and $samba->{$share}{'create mask'} = $o->{var}{wiz_share_create_mask};
@@ -597,13 +607,17 @@ sub do_it_add_share {
$o->{var}{wiz_addshare_public} and $samba->{$share}{public} = $o->{var}{wiz_addshare_public};
$o->{var}{wiz_addshare_dotfiles} and $samba->{$share}{'hide dot files'} = $o->{var}{wiz_addshare_dotfiles};
$o->{var}{wiz_addshare_hidefiles} and $samba->{$share}{'hide files'} = $o->{var}{wiz_addshare_hidefiles};
-# $o->{var}{wiz_addshare_readlist} and $samba->{$share}{'read list'} = $o->{var}{wiz_addshare_readlist};
+ if ($o->{var}{wiz_addshare_readlist}) {
+ $samba->{$share}{'read list'} = $o->{var}{wiz_addshare_readlist};
+ create_smbuser($o->{var}{wiz_addshare_readlist});
+ }
+
if ($o->{var}{wiz_addshare_writelist}) {
$samba->{$share}{'write list'} = $o->{var}{wiz_addshare_writelist};
if ($o->{var}{wiz_owner}) {
system("chown -R $o->{var}{wiz_addshare_writelist}.users $o->{var}{wiz_addshare_path}");
}
- system("smbpasswd -a $o->{var}{wiz_share_writelist} -n");
+ create_smbuser($o->{var}{wiz_addshare_writelist});
}
$o->{var}{wiz_addshare_create_mask} and $samba->{$share}{'create mask'} = $o->{var}{wiz_addshare_create_mask};