diff options
Diffstat (limited to 'samba_wizard/Sambashare.pm')
-rwxr-xr-x | samba_wizard/Sambashare.pm | 92 |
1 files changed, 58 insertions, 34 deletions
diff --git a/samba_wizard/Sambashare.pm b/samba_wizard/Sambashare.pm index d3394434..84b76a75 100755 --- a/samba_wizard/Sambashare.pm +++ b/samba_wizard/Sambashare.pm @@ -175,21 +175,23 @@ $o->{pages} = { next => 'modify_share_options', }, modify_share_options => { - name => N('Advanced options, step 1') . "\n\n" . N('Advanced options, use them if you know what you are doing.'), + 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'}; - 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'}; + $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'}; }, 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('Write list:'), val => \$o->{var}{wiz_share_writelist}, help => N('Specifies a user that have read-write access to a read-only share. ie: fred') }, - { 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('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('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 (.)") }, ], @@ -200,10 +202,10 @@ $o->{pages} = { 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", "read list" and "valid user".')); + 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; } }, next => 'modify_share_options2', @@ -292,12 +294,14 @@ $o->{pages} = { pre => sub { $o->{var}{wiz_addshare_createmode} = "0700"; $o->{var}{wiz_addshare_public} = "no"; + $o->{var}{wiz_owner} = 1; }, 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('Write list:'), val => \$o->{var}{wiz_addshare_writelist}, help => N('Specifies a lis\t of users that have read-write access to a read-only share. ie: fredl') }, +# { 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/") }, ], @@ -307,11 +311,11 @@ $o->{pages} = { $::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", "read list" and "valid 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; } }, next => 'summary_addshare', @@ -386,7 +390,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,22 +505,33 @@ sub do_it_modify_share { $::testing and return; my $in = 'interactive'->vnew('su', 'Samba'); my $share = $o->{var}{wiz_selected_share}; - my $w = $in->wait_message(N("Samba share"), N("Configuring your Samba server...")); $samba->{$share}; - $samba->{$share}{comment} = $o->{var}{wiz_share_comment}; $samba->{$share}{path} = $o->{var}{wiz_share_path}; + if (!-d $samba->{$share}{path}) { + system("mkdir $samba->{$share}{path}"); + if (!-d $samba->{$share}{path}) { + $::in->ask_warn(N('Error'), N('Can\'t create %s. Please check why wizard can\'t create this directory.', $samba->{$share}{path})); + } + } + my $w = $in->wait_message(N("Samba share"), N("Configuring your Samba server...")); + $samba->{$share}{comment} = $o->{var}{wiz_share_comment}; $o->{var}{wiz_share_browseable} and $samba->{$share}{browseable} = $o->{var}{wiz_share_browseable}; $o->{var}{wiz_share_writable} and $samba->{$share}{writable} = $o->{var}{wiz_share_writable}; $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_writelist} and $samba->{$share}{'write list'} = $o->{var}{wiz_share_writelist}; - system("chown -R $o->{var}{wiz_share_writelist}.users $o->{var}{wiz_share_path}"); + # $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"); + } $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_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}; @@ -537,7 +552,6 @@ sub do_it_add_cdromshare { my $w = $in->wait_message(N("Samba share"), N("Configuring your Samba server...")); $samba->{cdrom}{comment} = $o->{var}{wiz_cdrom_comment}; $samba->{cdrom}{path} = $o->{var}{wiz_cdrom_path}; - $samba->{cdrom}{path} = $o->{var}{wiz_cdrom_path}; $samba->{cdrom}{browseable} = $o->{var}{wiz_cdrom_browseable}; $samba->{cdrom}{'root preexec'} = $o->{var}{wiz_cdrom_pre}; $samba->{cdrom}{'root postexec'} = $o->{var}{wiz_cdrom_post}; @@ -567,20 +581,30 @@ sub do_it_add_homeshare { sub do_it_add_share { $::testing and return; my $in = 'interactive'->vnew('su', 'Samba'); - my $w = $in->wait_message(N("Samba share"), N("Configuring your Samba server...")); - my $share = $o->{var}{wiz_addshare_name}; $samba->{$share}; - $samba->{$share}{comment} = $o->{var}{wiz_addshare_comment}; $samba->{$share}{path} = $o->{var}{wiz_addshare_path}; + if (!-d $samba->{$share}{path}) { + system("mkdir $samba->{$share}{path}"); + if (!-d $samba->{$share}{path}) { + $::in->ask_warn(N('Error'), N('Can\'t create %s. Please check why wizard can\'t create this directory.', $samba->{$share}{path})); + } + } + my $w = $in->wait_message(N("Samba share"), N("Configuring your Samba server...")); + $samba->{$share}{comment} = $o->{var}{wiz_addshare_comment}; $o->{var}{wiz_addshare_browseable} and $samba->{$share}{browseable} = $o->{var}{wiz_addshare_browseable}; $o->{var}{wiz_addshare_writable} and $samba->{$share}{writable} = $o->{var}{wiz_addshare_writable}; $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}; - $o->{var}{wiz_addshare_writelist} and $samba->{$share}{'write list'} = $o->{var}{wiz_addshare_writelist}; - system("chown -R $o->{var}{wiz_addshare_writelist}.users $o->{var}{wiz_addshare_path}"); +# $o->{var}{wiz_addshare_readlist} and $samba->{$share}{'read list'} = $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"); + } $o->{var}{wiz_addshare_create_mask} and $samba->{$share}{'create mask'} = $o->{var}{wiz_addshare_create_mask}; write_conf_restart_smb(); |