summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rwxr-xr-xperl-install/standalone/draksambashare84
1 files changed, 77 insertions, 7 deletions
diff --git a/perl-install/standalone/draksambashare b/perl-install/standalone/draksambashare
index 4f14972c1..5367dbadc 100755
--- a/perl-install/standalone/draksambashare
+++ b/perl-install/standalone/draksambashare
@@ -110,7 +110,7 @@ sub sort_by_column {
my $samba = new Libconf::Glueconf::Samba::Smb_conf({ filename => '/etc/samba/smb.conf', show_commented_info => 1 });
-my (@listshare, @listprinters);
+my (@listshare, @listprinters, @listusers);
my @yesno = qw(yes no); push @yesno, "";
my @default_case = qw(upper lower); push @default_case, "";
@@ -221,6 +221,19 @@ sub get_samba_share() {
return @listshare;
}
+sub get_samba_user() {
+ undef @listusers;
+ foreach (cat_("/etc/samba/smbpasswd")) {
+ my ($user) = m!^(\w+):!;
+ print $user;
+ $user and push @listusers, {
+ user_name => $user,
+ };
+ }
+ return @listusers;
+}
+
+
sub get_samba_printers() {
undef @listprinters;
foreach my $clef (keys %$samba) {
@@ -627,7 +640,7 @@ sub modify_printers_entry {
$samba->{$share}{comment} = $comment->get_text;
$browseable->get_text and $samba->{$share}{browseable} = $browseable->get_text || delete $samba->{$share}{browseable};
$printable->get_text and $samba->{$share}{printable} = $printable->get_text || delete $samba->{$share}{printable};
- $print_command->get_text and $samba->{$share}{'print command'} = $print_command->get_text || delete $samba->{$share}{'print_command'};
+ $print_command->get_text and $samba->{$share}{'print command'} = $print_command->get_text || delete $samba->{$share}{'print command'};
$lpq_command->get_text and $samba->{$share}{'lpq command'} = $lpq_command->get_text || delete $samba->{$share}{'lpq command'};
$guest_ok->get_text and $samba->{$share}{'guest ok'} = $guest_ok->get_text || delete $samba->{$share}{'guest ok'};
$writable->get_text and $samba->{$share}{writable} = $writable->get_text || delete $samba->{$share}{writable};
@@ -853,6 +866,52 @@ sub remove_entry {
delete $samba->{$share_name};
}
+sub remove_user {
+ my ($user) = @_;
+ system("smbpasswd -x $user");
+}
+
+sub modify_user_info {
+ my ($user, $passwd, $todo) = @_;
+ my ($buser, $bpasswd);
+ my $dialog = new Gtk2::Dialog();
+ $dialog->set_title("Add Samba user");
+ $dialog->set_modal(1);
+ $dialog->set_position('center');
+ $dialog->set_resizable(0);
+ if ($todo eq "add") {
+ $buser = Gtk2::Entry->new;
+ } else {
+ $buser = Gtk2::Label->new;
+ $buser->set_text($user);
+ }
+ $bpasswd = Gtk2::Entry->new;
+ $bpasswd->set_visibility(0);
+
+ gtkpack_($dialog->vbox,
+ 0, gtkadd(Gtk2::Frame->new(N("User information")),
+ gtkpack_(gtkset_border_width(Gtk2::VBox->new, 5),
+ 0, $label_and_widgets->(N("User name:"), $buser, ""),
+ 0, $label_and_widgets->(N("Passwd:"), $bpasswd, ""),
+ ),
+ ),
+ 0, create_okcancel({
+ cancel_clicked => sub { $dialog->destroy },
+ ok_clicked => sub {
+ system("smbpasswd -a $user");
+ set_user_passwd($user, $passwd);
+ $dialog->destroy;
+ }
+ },
+ ),
+ );
+ $dialog->show_all;
+}
+
+sub set_user_passwd {
+ my ($user, $passwd) = @_;
+}
+
sub add_data_share_list {
my ($share_list) = @_;
get_samba_share();
@@ -882,9 +941,15 @@ sub add_data_share_list {
}
sub add_data_user_list {
+ my ($user_list) = @_;
+ get_samba_user();
+ foreach my $data (@listusers) {
+ push @{$user_list->{data}}, [
+ $data->{user_name},
+ ];
+ }
}
-
sub add_data_printer_list {
my ($printer_list) = @_;
get_samba_printers();
@@ -951,7 +1016,7 @@ my $menu = $factory->get_widget('<main>');
my $okcancel = create_okcancel({
cancel_clicked => sub { ugtk2->exit },
- ok_clicked => sub { write_conf; ugtk2->exit },
+ ok_clicked => sub { &write_conf; ugtk2->exit },
},
);
@@ -1029,7 +1094,8 @@ gtkappend_page($nb, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 0),
1, create_scrolled_window($user_list),
0, gtkpack_(create_vbox('start'),
0, gtksignal_connect(Gtk2::Button->new(N("Change password")), clicked => sub {
- eval { change_passwd() };
+ my ($selected) = $user_list->get_selected_indices;
+ eval { modify_user_info($user_list->{data}[$selected][0], "", "change") };
my $err = $@;
if ($err) {
err_dialog(N("Error"), N("Failed to change user password.") . "\n\n" . $err);
@@ -1037,7 +1103,7 @@ gtkappend_page($nb, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 0),
}),
0, Gtk2::HSeparator->new,
0, gtksignal_connect(Gtk2::Button->new(N("Add user")), clicked => sub {
- eval { add_user_entry() };
+ eval { modify_user_info("", "", "add") };
my $err = $@;
if ($err) {
err_dialog(N("Error"), N("Failed to add user.") . "\n\n" . $err);
@@ -1045,7 +1111,11 @@ gtkappend_page($nb, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 0),
}),
0, gtksignal_connect(Gtk2::Button->new(N("Delete user")), clicked => sub {
my ($selected) = $user_list->get_selected_indices;
- eval { delete_user_entry($selected) };
+ ask_okcancel("Remove entry ?", "Remove $user_list->{data}[$selected][0]") or return;
+ eval {
+ remove_user($user_list->{data}[$selected][0]);
+ remove_entry($selected, $user_list);
+ };
my $err = $@;
if ($err) {
err_dialog(N("Error"), N("Failed to delete user.") . "\n\n" . $err);