diff options
Diffstat (limited to 'samba_wizard/Sambashare.pm')
-rwxr-xr-x | samba_wizard/Sambashare.pm | 88 |
1 files changed, 71 insertions, 17 deletions
diff --git a/samba_wizard/Sambashare.pm b/samba_wizard/Sambashare.pm index 68a9b94e..90d968ed 100755 --- a/samba_wizard/Sambashare.pm +++ b/samba_wizard/Sambashare.pm @@ -130,7 +130,7 @@ $o->{pages} = { }, manage_share => { name => N("What do you want todo with your share?") . "\n\n" . N("add/remove/modify a share"), - pre => sub { $o->{var}{manage_share} = 0; }, + pre => sub { $o->{var}{manage_share} = 0 }, data => [ { label => '', val => \$o->{var}{manage_share}, type => 'list', list => [ keys %menu_manage ], format => sub { $menu_manage{$_[0]} } }, ], @@ -140,13 +140,13 @@ $o->{pages} = { elsif ($o->{var}{manage_share} == 2) { return 'choose_share_to_delete' } elsif ($o->{var}{manage_share} == 3) { - return 'understanding' } + return 'choose_share_to_modify' } }, no_back => 1, }, special_share => { name => N("Create a special share, what kind?"), - pre => sub { $o->{var}{special_share} = 1; }, + pre => sub { $o->{var}{special_share} = 1 }, data => [ { label => '', val => \$o->{var}{special_share}, type => 'list', list => [ keys %menu_special_share ], format => sub { $menu_special_share{$_[0]} } }, ], @@ -166,7 +166,7 @@ $o->{pages} = { data => [ { label => N("What kind of user are you:"), val => \$o->{var}{wiz_understanding}, list => [ keys %understanding ], format => sub { $understanding{$_[0]} } }, ], - next => 'choose_share_to_modify', + next => 'modify_share', }, choose_share_to_delete => { name => N("Delete which share?") . "\n\n" . N("Please choose the share you want to remove."), @@ -182,8 +182,37 @@ $o->{pages} = { data => [ { label => '', type => 'list', val => \$o->{var}{wiz_selected_share}, fixed_list => \@listshare_tomodify }, ], - next => 'modify_share', + post => sub { if ($o->{var}{wiz_selected_share} eq 'homes') { return 'modify_homes_share' } + }, + next => 'understanding', }, + modify_homes_share => { + name => N("Modify Homes share"), + pre => sub { + exists $samba->{homes}{comment} and $o->{var}{wiz_homes_commment} = $samba->{homes}{comment}; + exists $samba->{homes}{writable} and $o->{var}{wiz_homes_writable} = $samba->{homes}{writable}; + exists $samba->{homes}{browseable} and $o->{var}{wiz_homes_browseable} = $samba->{homes}{browseable}; + exists $samba->{homes}{'create mode'} and $o->{var}{wiz_homes_create_mode} = $samba->{homes}{'create mode'}; + exists $samba->{homes}{'create mask'} and $o->{var}{wiz_homes_create_mask} = $samba->{homes}{'create mask'}; + exists $samba->{homes}{'directory mask'} and $o->{var}{wiz_homes_directory_mask} = $samba->{homes}{'directory mask'}; + }, + data => [ + { label => N("Comment:"), val => \$o->{var}{wiz_homes_comment}, help => N("This is a text field that is seen next to a share when a client does a queries the server") }, + { label => N("Writable:"), val => \$o->{var}{wiz_homes_writable}, fixed_list => \@yesorno }, + { label => N("Browseable:"), val => \$o->{var}{wiz_homes_browseable}, fixed_list => \@yesorno }, + { label => N("Create mode:"), val => \$o->{var}{wiz_homes_create_mode} }, + { label => N("Create mask:"), val => \$o->{var}{wiz_homes_create_mask} }, + { label => N("Directory mask:"), val => \$o->{var}{wiz_homes_directory_mask} }, + ], + complete => sub { + map { + if ($_ and !/^\d+$/) { + $::in->ask_warn(N("Error"), N("Create mask, create mode and directory mask should be numeric. ie: 0755.")) and return 1; + } + } $o->{var}{wiz_homes_create_mask}, $o->{var}{wiz_homes_directory_mask}, $o->{var}{wiz_homes_create_mode}; + }, + next => 'summary_modify_homes_share', + }, modify_share => { name => N("Modify a share"), pre => sub { @@ -197,7 +226,7 @@ $o->{pages} = { exists $samba->{$share}{browseable} and $o->{var}{wiz_share_browseable} = $samba->{$share}{browseable}; exists $samba->{$share}{path} and $o->{var}{wiz_share_path} = $samba->{$share}{path}; exists $samba->{$share}{public} and $o->{var}{wiz_share_public} = $samba->{$share}{public}; - } + } }, complete => sub { if (!($o->{var}{wiz_share_comment})) { @@ -572,10 +601,21 @@ $o->{pages} = { next => 'end_delete_share', no_back => 1, }, + summary_modify_homes_share => { + name => N("Summary of modify homes share"), + data => [ + { label => N("Comment:"), fixed_val => \$o->{var}{wiz_homes_comment} }, + { label => N("Writable:"), fixed_val => \$o->{var}{wiz_homes_writable} }, + { label => N("Browseable:"), fixed_val => \$o->{var}{wiz_homes_browseable} }, + { label => N("Create mode:"), fixed_val => \$o->{var}{wiz_homes_create_mode} }, + { label => N("Create mask:"), fixed_val => \$o->{var}{wiz_homes_create_mask} }, + { label => N("Directory mask:"), fixed_val => \$o->{var}{wiz_homes_directory_mask} }, + ], + post => \&do_it_modify_homes_share, + next => 'end_add_user_share', + }, summary_add_user_share => { name => N("Summary of add a user share") . "\n\n" . N("If you really want to add this share, click the Next button or use the Back button."), - pre => sub { - }, data => [ { label => N("Name of the share:"), fixed_val => \$o->{var}{wiz_add_user_share_name} }, { label => N("Comment:"), fixed_val => \$o->{var}{wiz_add_user_share_comment} }, @@ -587,8 +627,6 @@ $o->{pages} = { }, summary_add_public_share => { name => N("Summary of add a public share") . "\n\n" . N("If you really want to add this share, click the Next button or use the Back button."), - pre => sub { - }, data => [ { label => N("Name of the share:"), val => \$o->{var}{wiz_add_public_share_name} }, { label => N("Comment:"), val => \$o->{var}{wiz_add_public_share_comment} }, @@ -654,16 +692,16 @@ sub new { sub check() { $> and return 1; - $wiz->{net}->is_dhcp() and return 2; + $wiz->{net}->is_dhcp and return 2; 0; } -sub list_all_shares_to_modify() { +sub list_all_shares_to_modify { undef @listshare_tomodify; foreach my $clef (keys %$samba) { if ($samba->{$clef}{printable} =~ /yes/i) { print "$clef is a printer\n"; - } elsif ($clef =~ /global/ or $clef =~ /print\$/ or $clef =~ /cdrom/ or $clef =~ /homes/ or $clef =~ /profiles/) { + } elsif ($clef =~ /global/ or $clef =~ /print\$/ or $clef =~ /cdrom/ or $clef =~ /profiles/) { print "unwanted\n"; } else { push @listshare_tomodify, $clef; @@ -707,10 +745,10 @@ sub do_it_remove_share { } sub create_smbuser { - my ($list)= @_; + my ($list) = @_; my @users = split(" ", $list); foreach my $user (@users) { - if (!any { /^$user:/ } cat_("/etc/samba/smbpasswd") ) { + if (!any { /^$user:/ } cat_("/etc/samba/smbpasswd")) { system("smbpasswd -a $user -n"); } } @@ -723,7 +761,7 @@ sub do_it_modify_share { $samba->{$share}; $samba->{$share}{path} = $o->{var}{wiz_share_path}; if (!-d $samba->{$share}{path}) { - system("mkdir $samba->{$share}{path}"); + 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})); } @@ -776,7 +814,7 @@ sub do_it_add_profiles { $samba->{global}{'logon home'} = "\\\\%L\\Profiles\\%u"; $samba->{Profiles}{browseable} = $o->{var}{wiz_profiles_browseable}; $samba->{Profiles}{'guest ok'} = $o->{var}{wiz_profiles_guest_ok}; - $samba->{Profiles}{'comment'} = $o->{var}{wiz_profiles_comment}; + $samba->{Profiles}{comment} = $o->{var}{wiz_profiles_comment}; $samba->{Profiles}{writable} = $o->{var}{wiz_profiles_writable}; $samba->{Profiles}{'root preexec'} = "PROFILE='/var/lib/samba/profiles/\%u'; if [ ! -e \$PROFILE ]; then mkdir -pm700 \$PROFILE; chown '\%u':'\%g' \$PROFILE;fi"; @@ -785,6 +823,22 @@ sub do_it_add_profiles { check_started('smbd'); } +sub do_it_modify_homes_share { + $::testing and return; + my $in = 'interactive'->vnew('su', 'Samba'); + my $w = $in->wait_message(N("Samba homes share"), N("Configuring your Samba server...")); + + $o->{var}{wiz_homes_commment} and $samba->{homes}{comment} = $o->{var}{wiz_homes_commment}; + $o->{var}{wiz_homes_writable} and $samba->{homes}{writable} = $o->{var}{wiz_homes_writable}; + $o->{var}{wiz_homes_browseable} and $samba->{homes}{browseable} = $o->{var}{wiz_homes_browseable}; + $o->{var}{wiz_homes_create_mode} and $samba->{homes}{'create mode'} = $o->{var}{wiz_homes_create_mode}; + $o->{var}{wiz_homes_create_mask} and $samba->{homes}{'create mask'} = $o->{var}{wiz_homes_create_mask}; + $o->{var}{wiz_homes_directory_mask} and $samba->{homes}{'directory mask'} = $o->{var}{wiz_homes_directory_mask}; + + write_conf_restart_smb(); + undef $w; + check_started('smbd'); +} sub do_it_add_cdromshare { $::testing and return; |