summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-01-27 08:12:38 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-01-27 08:12:38 +0000
commit45f18adacd2637793a07bbb60283eeb2a811fc52 (patch)
tree1baceb57d652deb8f0d33c369fb820c87bbd5f32 /perl-install
parent3730934e00cf265b0d2fcd40f3b1d7d3fee7fdc8 (diff)
downloaddrakx-45f18adacd2637793a07bbb60283eeb2a811fc52.tar
drakx-45f18adacd2637793a07bbb60283eeb2a811fc52.tar.gz
drakx-45f18adacd2637793a07bbb60283eeb2a811fc52.tar.bz2
drakx-45f18adacd2637793a07bbb60283eeb2a811fc52.tar.xz
drakx-45f18adacd2637793a07bbb60283eeb2a811fc52.zip
strip authentification out of interactive->vnew into common.pm
This enable apps that still use gtk+-1.2 via my_gtk to still work when they only need interactive->vnew('su') just to get root capabilities. Indeed, interactive load ugtk if it has access to the X server, which make my_gtk and ugtk fight for the cpu forever... which is bad imho... drakfloppy and net_monitor were converted to use it and are now usuable again ("i leave ... again" commit). it would also enable to complete spec 64 by enabling rpmdrake to use kdesu under kde and consolehelper under gnome. rpmdrake is indeed the last program to not behave like the running desktop to get root capability. unless someone is against this, i'll convert the mcc and all other gtk+ pure tools to do not use anymore interactive just to get root capability. btw, i fixed the infamous SECTOR_SIZE warning...
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/common.pm21
-rw-r--r--perl-install/interactive.pm15
-rwxr-xr-xperl-install/standalone/drakfloppy5
-rwxr-xr-xperl-install/standalone/net_monitor7
4 files changed, 25 insertions, 23 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 339e0aa00..d605676a6 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -9,7 +9,7 @@ use vars qw(@ISA @EXPORT $SECTORSIZE);
@ISA = qw(Exporter);
# no need to export ``_''
-@EXPORT = qw($SECTORSIZE N N_ translate untranslate formatXiB removeXiBSuffix formatTime setVirtual makedev unmakedev salt set_permissions files_exist set_alternative mandrake_release);
+@EXPORT = qw($SECTORSIZE N N_ translate untranslate formatXiB removeXiBSuffix formatTime setVirtual makedev unmakedev salt set_permissions files_exist set_alternative mandrake_release require_root_capability);
# perl_checker: RE-EXPORT-ALL
push @EXPORT, @MDK::Common::EXPORT;
@@ -18,7 +18,7 @@ push @EXPORT, @MDK::Common::EXPORT;
#-#####################################################################################
#- Globals
#-#####################################################################################
-$SECTORSIZE = 512;
+our $SECTORSIZE = 512;
#-#####################################################################################
#- Functions
@@ -243,4 +243,21 @@ sub mandrake_release {
chomp_(cat_("/etc/mandrake-release"))
}
+sub require_root_capability {
+ return unless $>; # we're already root
+ if ($ENV{DISPLAY} && system('/usr/X11R6/bin/xtest') == 0) {
+ if (fuzzy_pidofs(qr/\bkwin\b/) > 0) {
+ exec("kdesu", "-c", "$0 @ARGV") or die N("kdesu missing");
+ } else {
+ exec { 'consolehelper' } $0, @ARGV or die N("consolehelper missing");
+
+ }
+ } else {
+ exec { 'consolehelper' } $0, @ARGV or die N("consolehelper missing");
+ }
+
+ # still not root ?
+ die "you must be root to run this program" if $>;
+}
+
1;
diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm
index 5e949b166..b62390180 100644
--- a/perl-install/interactive.pm
+++ b/perl-install/interactive.pm
@@ -93,14 +93,8 @@ sub vnew {
$ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
$su = '' if $::testing || $ENV{TESTING};
}
+ require_root_capability() if $su;
if ($ENV{DISPLAY} && system('/usr/X11R6/bin/xtest') == 0) {
- if ($su && $>) {
- if (fuzzy_pidofs(qr/\bkwin\b/) > 0) {
- exec("kdesu", "-c", "$0 @ARGV") or die N("kdesu missing");
- } else {
- exec { 'consolehelper' } $0, @ARGV or die N("consolehelper missing");
- }
- }
eval { require interactive::gtk };
if (!$@) {
my $o = interactive::gtk->new;
@@ -109,15 +103,8 @@ sub vnew {
$::need_utf8_i18n = 1;
return $o;
}
- } else {
- if ($su && $>) {
- exec { 'consolehelper' } $0, @ARGV or die N("consolehelper missing");
- }
}
- if ($su && $>) {
- die "you must be root to run this program";
- }
require 'log.pm'; #- "require log" causes some pb, perl thinking that "log" is the log() function
undef *log::l;
*log::l = sub {}; # otherwise, it will bother us :(
diff --git a/perl-install/standalone/drakfloppy b/perl-install/standalone/drakfloppy
index 082edf842..53381a12e 100755
--- a/perl-install/standalone/drakfloppy
+++ b/perl-install/standalone/drakfloppy
@@ -23,16 +23,15 @@
use strict;
+use diagnostics;
use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
-use interactive;
use common;
-use ugtk qw(:helpers);
use my_gtk qw(:helpers);
-my $in = interactive->vnew('su', 'default');
+require_root_capability();
my $expert_mode = 0;
# we have put here the list in order to do $list->clear() when we have to do
diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor
index 6dff839f8..cc10ce093 100755
--- a/perl-install/standalone/net_monitor
+++ b/perl-install/standalone/net_monitor
@@ -23,7 +23,6 @@ use lib qw(/usr/lib/libDrakX);
use strict;
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
-use interactive;
use my_gtk qw(:helpers :wrappers);
use common;
use network::netconnect;
@@ -44,8 +43,8 @@ if ($force) {
}
$quiet and exit(0);
init Gtk;
-my $in = 'interactive'->vnew('su', 'default');
+require_root_capability();
my $window1 = my_gtk->new('net_monitor');
$window1->{rwindow}->signal_connect(delete_event => sub { my_gtk->exit(0) });
@@ -82,7 +81,7 @@ MDK::Common::Globals::init(
disconnect_file => "/etc/sysconfig/network-scripts/net_cnx_down",
connect_prog => "/etc/sysconfig/network-scripts/net_cnx_pg");
-gtkadd($window1->{rwindow},
+gtkadd($window1->{window},
gtkpack_(new Gtk::VBox(0,5),
0, N("Network Monitoring"),
1, gtkpack_(new Gtk::HBox(0,5),
@@ -155,7 +154,7 @@ update();
rescan();
while ($isconnected == -2 || $isconnected == -1) {
- Gtk->main_iteration while Gtk->events_pending;
+ ugtk::gtkflush()
}
Gtk->timeout_remove($time_tag2);