summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakperm
diff options
context:
space:
mode:
authorJonathan Gotti <jgotti@mandriva.com>2002-09-02 14:00:57 +0000
committerJonathan Gotti <jgotti@mandriva.com>2002-09-02 14:00:57 +0000
commit52554c4382b5b30ad9dd89dbb438528c5485479e (patch)
tree8e054b59d881953ed775d40ea343c433ad53909e /perl-install/standalone/drakperm
parentf195c0a8c2c554384a6843886f14931a5d129140 (diff)
downloaddrakx-backup-do-not-use-52554c4382b5b30ad9dd89dbb438528c5485479e.tar
drakx-backup-do-not-use-52554c4382b5b30ad9dd89dbb438528c5485479e.tar.gz
drakx-backup-do-not-use-52554c4382b5b30ad9dd89dbb438528c5485479e.tar.bz2
drakx-backup-do-not-use-52554c4382b5b30ad9dd89dbb438528c5485479e.tar.xz
drakx-backup-do-not-use-52554c4382b5b30ad9dd89dbb438528c5485479e.zip
solving bugs on add and save functions
Diffstat (limited to 'perl-install/standalone/drakperm')
-rwxr-xr-xperl-install/standalone/drakperm55
1 files changed, 45 insertions, 10 deletions
diff --git a/perl-install/standalone/drakperm b/perl-install/standalone/drakperm
index cb9076383..10eb67b08 100755
--- a/perl-install/standalone/drakperm
+++ b/perl-install/standalone/drakperm
@@ -10,6 +10,23 @@ init Gtk;
use interactive;
+#- this part is embedded management
+$::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~/--embedded (\S*) (\S*)/;
+if ($::isEmbedded) {
+ print "EMBED\n";
+ print "XID : $::XID\n";
+ print "CCPID : $::CCPID\n";
+}
+
+my $in = 'interactive'->vnew('su', 'default');
+local $_ = join '', @ARGV;
+
+/-h/ and die _("no help implemented yet.\n");
+/-version/ and die 'version: $Id$'."\n";
+
+my $window = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window ("toplevel");
+$window->signal_connect(delete_event => sub { $::isEmbedded ? kill(USR1, $::CCPID) : &killapp });
+
#- vars declaration
my ($default_perm_level) = "level ".chomp_(`cat /etc/sysconfig/msec | grep SECURE_LEVEL= |cut -d= -f2`);
my %CURENT;
@@ -24,7 +41,7 @@ my $perm_path= '/usr/share/msec/';
my $rows_cnt = 0;
my $editable = 0;
my $modified = 0;
-my $in = new interactive->vnew();
+my $prec_txt = $default_perm_level;
#my $bg = Gtk::Gdk::Color->parse_color('grey');
#- Widget declaration
my $W = new Gtk::Window('toplevel');
@@ -35,11 +52,11 @@ my $select_box= new Gtk::HBox(0,5);
my $action_box= new Gtk::HBox(0,5);
my $up_down_box=new Gtk::HBox(0,5);
my $B_quit = new Gtk::Button('cancel');
-my $B_sav = new Gtk::Button('Ok');
-my $B_up = new Gtk::Button(_("UP"));
+my $B_sav = new Gtk::Button('save');
+my $B_up = new Gtk::Button(_("Up"));
my $B_del = new Gtk::Button(_("delete"));
my $B_edit = new Gtk::Button(_("edit"));
-my $B_down = new Gtk::Button(_("down"));
+my $B_down = new Gtk::Button(_("Down"));
my $B_add = new Gtk::Button(_("add a rule"));
my $label_perm= new Gtk::Label(_("select perm file to see/edit"));
my $combo_perm= new Gtk::Combo;
@@ -71,6 +88,7 @@ $B_add->signal_connect( clicked => sub{
$B_del->signal_connect( clicked => sub {
$Perm_list->remove(${$CURENT{'clicked'}}{'row'});
$rows_cnt--;
+ $modified++;
});
$B_down->signal_connect( clicked => sub {
my $row = ${$CURENT{'clicked'}}{'row'};
@@ -86,7 +104,7 @@ $B_up->signal_connect( clicked => sub {
$Perm_list->select_row($row-1,0);
$CURENT{'clicked'}{'row'} = $row-1;
});
-$combo_perm->entry->signal_connect( changed => sub{ &display_perm($combo_perm->entry->get_text)});
+my $combo_sig = $combo_perm->entry->signal_connect( changed => sub{ &display_perm($combo_perm->entry->get_text , @_)});
$Perm_list->signal_connect( button_press_event => sub{
$editable or return 0;
my ($clist,$event) = @_;
@@ -112,6 +130,7 @@ $Perm_list->set_column_width( 3, 15 );
$up_down_box->add($B_up);
$up_down_box->add($B_down);
$up_down_box->add($B_add);
+$up_down_box->add($B_del);
$up_down_box->add($B_edit);
$action_box->add($B_sav);
@@ -143,16 +162,30 @@ exit 0;
#- Built in functions
sub killapp{
- $modified
- and ($in->ask_okcancel('Warning','your changed are not saved do you whish to continue?') or return 0);
+ $modified and (&check_save or return 0);
Gtk->exit(0);
return 0;
}
+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;
+ return $sav_;
+}
#- Desc => set the Perm_list CList with the appropriate value
sub display_perm{
- local $perm_level = shift @_;
+ local $perm_level = shift @_;
local $file = $perm_path.$perm{$perm_level};
+ local $sav_ = &check_save;
+ local $i=0;
+ if($modified && ! $sav_){
+ $combo_perm->entry->signal_handler_block($combo_sig);
+ $combo_perm->entry->set_text($prec_txt);
+ $combo_perm->entry->signal_handler_unblock($combo_sig);
+ return 0;
+ }
$editable = ($perm_level =~ /^level \d/)?0:1;
@@ -172,15 +205,16 @@ sub display_perm{
$up_down_box->set_sensitive($editable);
$rows_cnt = $i;
+ $prec_txt = $perm_level;
undef(%CURENT);
}
#- Desc => save the perm.local file if modification made
sub save_perm{
$modified or return 0;
- open F, '>'.$perm_path.'perm.local';
+ open F, '>'.$perm_path.'perm.local' or die("F CHIER BORDEL");
for($i = 0 ; $i <= $rows_cnt;$i++){
- $line = $Perm_list->get_text( $i , 0 )."\t".$Perm_list->get_text($i,1).(($Perm_list->get_text($i,2))?".".$Perm_list->get_text($i,2):"")."\t".$Perm_list->get_text($i,3);
+ $line = $Perm_list->get_text( $i , 0 )."\t".$Perm_list->get_text($i,1).(($Perm_list->get_text($i,2))?".".$Perm_list->get_text($i,2):"")."\t".$Perm_list->get_text($i,3)."\n";
print F $line ;
}
close F;
@@ -198,6 +232,7 @@ sub row_setting_data{
$Perm_list->get_text( $row,3),
]
);
+ #print(%{$CURENT{'clicked'}});print("\n");
}
#- Desc => Here is the complete subwindow for rule settings