From 445ed2cb538df49e619f4fa63d6372de973e0757 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 22 Aug 2003 17:16:45 +0000 Subject: renew drakperm gui (interface team feedback): - indicate if current setting is editable or not - only display current security level, editable settings or both --- perl-install/standalone/drakperm | 112 +++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'perl-install/standalone') diff --git a/perl-install/standalone/drakperm b/perl-install/standalone/drakperm index aa7c3e28b..ebc4b66e2 100755 --- a/perl-install/standalone/drakperm +++ b/perl-install/standalone/drakperm @@ -13,27 +13,18 @@ my $in = 'interactive'->vnew('su'); local $_ = join '', @ARGV; #- vars declaration -my ($default_perm_level) = "level ".chomp_(`cat /etc/sysconfig/msec | grep SECURE_LEVEL= |cut -d= -f2`); -my $perm_path = '/usr/share/msec/'; -my $local_path = '/etc/security/msec/'; -my %perm = ( - 'level 1' => $perm_path.'perm.1', - 'level 2' => $perm_path.'perm.2', - 'level 3' => $perm_path.'perm.3', - 'level 4' => $perm_path.'perm.4', - 'level 5' => $perm_path.'perm.5', - 'editable' => $local_path.'perm.local', - ); -my %perm_l10n = ('level 1' => N("Level 1"), - 'level 2' => N("Level 2"), - 'level 3' => N("Level 3"), - 'level 4' => N("Level 4"), - 'level 5' => N("Level 5"), +my ($level) = chomp_(`cat /etc/sysconfig/msec | grep SECURE_LEVEL= |cut -d= -f2`); +my ($default_perm_level) = "level " . $level; +my %perm_files = ($default_perm_level => '/usr/share/msec/perm.' . $level, + 'editable' => '/etc/security/msec/perm.local', + ); + +my %perm_l10n = ($default_perm_level => N("System settings"), 'editable' => N("Custom settings"), + 'all' => N("Custom & system settings"), ); my %rev_perm_l10n = reverse %perm_l10n; -my $editable = 0; -my $modified = 0; +my ($editable, $modified) = (0, 0); my $prec_txt = $default_perm_level; #- Widget declaration @@ -41,15 +32,18 @@ my $w = ugtk2->new('drakperm'); $w->{rwindow}->set_size_request(550, 400) unless $::isEmbedded; my $W = $w->{window}; $W->signal_connect(delete_event => sub { ugtk2->exit }); -my $treeModel = Gtk2::TreeStore->new(("Glib::String") x 4); +my $treeModel = Gtk2::TreeStore->new("Gtk2::Gdk::Pixbuf", ("Glib::String") x 4); my $permList = Gtk2::TreeView->new_with_model($treeModel); +my $pixbuf = gtkcreate_pixbuf('non-editable'); + my @column_sizes = (150, 100, 100, 15, -1); +$permList->append_column(Gtk2::TreeViewColumn->new_with_attributes(N("Editable"), Gtk2::CellRendererPixbuf->new, 'pixbuf' => 0)); each_index { - my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i); - $col->set_min_width($column_sizes[$::i]); -# $col->set_sort_column_id($::i); + my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i + 1); + $col->set_min_width($column_sizes[$::i+1]); +# $col->set_sort_column_id($::i+1); $permList->append_column($col); } (N("Path"), N("User"), N("Group"), N("Permissions")); @@ -152,7 +146,7 @@ $combo_perm->entry->set_text($perm_l10n{$default_perm_level}); $permList->get_selection->signal_connect('changed' => sub { my ($select) = @_; my (undef, $iter) = $select->get_selected; - sensitive_buttons($iter ? $editable : 0); + sensitive_buttons($iter ? $editable && !$treeModel->get($iter, 0) : 0); }); $w->main; @@ -162,15 +156,14 @@ ugtk2->exit; sub check_save() { $modified or return 0; my $sav_ = $in->ask_okcancel('Warning', 'your changed will be lost do you wish to continue?'); - $sav_ - and $modified = 0; + $sav_ and $modified = 0; return $sav_; } sub display_perm { my $perm_level = shift @_; return unless $perm_level; - my $file = $perm{$perm_level}; + my @files = $perm_level eq 'all' ? values %perm_files : $perm_files{$perm_level}; my $sav_ = &check_save; if ($modified && ! $sav_) { $combo_perm->entry->signal_handler_block($combo_sig); @@ -182,17 +175,21 @@ sub display_perm { $editable = $perm_level =~ /^level \d/ ? 0 : 1; $treeModel->clear; - local *F; - open F, $file; - local $_; - while () { - if (m/^([^#]\S+)\s+([^.\s]+)\.(\S+)?\s+(\d+)/) { - $treeModel->append_set(undef, 0 => $1, 1 => $2, 2 => $3, 3 => $4); - } elsif (m/^([^#]\S+)\s+current?\s+(\d+)/) { - $treeModel->append_set(undef, 0 => $1, 1 => 'current', 2 => '', 3 => $2); + foreach my $file (@files) { + local *F; + open F, $file; + + local $_; + my $is_uneditable = $file ne $perm_files{editable}; + while () { + if (m/^([^#]\S+)\s+([^.\s]+)\.(\S+)?\s+(\d+)/) { + $treeModel->append_set(undef, if_($is_uneditable, 0 => $pixbuf), 1 => $1, 2 => $2, 3 => $3, 4 => $4); + } elsif (m/^([^#]\S+)\s+current?\s+(\d+)/) { + $treeModel->append_set(undef, if_($is_uneditable, 0 => $pixbuf), 1 => $1, 2 => 'current', 3 => '', 4 => $2); + } } + close F; } - close F; $up_down_box->set_sensitive($editable); sensitive_buttons(0) if $editable; @@ -200,17 +197,19 @@ sub display_perm { } sub save_perm() { - $modified or return 0; my $val; - local *F; - open F, '>' . $perm{editable} or die("Impssible to process \"", $perm{editable}, "\""); - $treeModel->foreach(sub { - my ($model, $_path, $iter) = @_; - my $line = $model->get($iter, 0) . "\t" . $model->get($iter,1) . ($model->get($iter,2) ? "." . $model->get($iter,2) : "") . "\t" . $model->get($iter,3) . "\n"; - print F $line; - return 0; - }, $val); - close F; + if ($modified) { + local *F; + open F, '>' . $perm_files{editable} or die("Impossible to process \"", $perm_files{editable}, "\""); + $treeModel->foreach(sub { + my ($model, $_path, $iter) = @_; + return 0 if $model->get($iter, 0); + my $line = $model->get($iter, 1) . "\t" . $model->get($iter, 2) . ($model->get($iter, 3) ? "." . $model->get($iter, 3) : "") . "\t" . $model->get($iter, 4) . "\n"; + print F $line; + return 0; + }, $val); + close F; + } $modified = 0; ugtk2->exit; } @@ -230,7 +229,7 @@ sub row_setting_dialog { my $sticky = new Gtk2::CheckButton(N("Sticky-bit")); my $suid = new Gtk2::CheckButton(N("Set-UID")); my $gid = new Gtk2::CheckButton(N("Set-GID")); - my $rght = $treeModel->get($iter, 3) if $iter; + my $rght = $treeModel->get($iter, 4) if $iter; my $s = length($rght) == 4 ? substr($rght,0,1) : 0; my $user = $s ? substr($rght,1,1) : substr($rght,0,1); my $group = $s ? substr($rght,2,1) : substr($rght,1,1); @@ -265,17 +264,17 @@ sub row_setting_dialog { $gid->set_active($s_right{write}); $suid->set_active($s_right{read}); - $file->set_text($treeModel->get($iter, 0)) if $iter; + $file->set_text($treeModel->get($iter, 1)) if $iter; my $users = Gtk2::OptionMenu->new; $users->set_popdown_strings(&get_user_or_group('users')); - $users->entry->set_text($treeModel->get($iter, 1)) if $iter; + $users->entry->set_text($treeModel->get($iter, 2)) if $iter; my $groups = Gtk2::OptionMenu->new; $groups->set_popdown_strings(&get_user_or_group); - $groups->entry->set_text($treeModel->get($iter, 2)) if $iter; + $groups->entry->set_text($treeModel->get($iter, 3)) if $iter; - if ($iter && $treeModel->get($iter, 1) eq 'current') { + if ($iter && $treeModel->get($iter, 2) eq 'current') { $usr_check->set_active(1); $groups->set_sensitive(0); $users->set_sensitive(0); @@ -304,19 +303,20 @@ sub row_setting_dialog { unless ($iter) { $iter = $treeModel->append(undef); } - $treeModel->set($iter, 0 => $file->get_text); + #BUG + $treeModel->set($iter, 1 => $file->get_text); if ($usr_check->get_active) { - $treeModel->set($iter, 1 => 'current'); - $treeModel->set($iter, 2 => ''); + $treeModel->set($iter, 2 => 'current'); + $treeModel->set($iter, 3 => ''); } else { - $treeModel->set($iter, 1 => $users->entry->get_text); - $treeModel->set($iter, 2 => $groups->entry->get_text); + $treeModel->set($iter, 2 => $users->entry->get_text); + $treeModel->set($iter, 3 => $groups->entry->get_text); } $user = ($perms{user}{read}->get_active ? 4 : 0)+($perms{user}{write}->get_active ? 2 : 0)+($perms{user}{execute}->get_active ? 1 : 0); $group = ($perms{group}{read}->get_active ? 4 : 0)+($perms{group}{write}->get_active ? 2 : 0)+($perms{group}{execute}->get_active ? 1 : 0); $other = ($perms{other}{read}->get_active ? 4 : 0)+($perms{other}{write}->get_active ? 2 : 0)+($perms{other}{execute}->get_active ? 1 : 0); my $s = ($sticky->get_active ? 1 : 0) + ($suid->get_active ? 4 : 0) + ($gid->get_active ? 2 : 0); - $treeModel->set($iter, 3 => ($s || '') . $user . $group . $other); + $treeModel->set($iter, 4 => ($s || '') . $user . $group . $other); $dlg->destroy; $modified++; }); -- cgit v1.2.1