summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.org>2005-07-07 07:01:26 +0000
committerOlivier Blin <oblin@mandriva.org>2005-07-07 07:01:26 +0000
commitf0f54fec1e8a3c7b8e24be3de3dc12deac4998dc (patch)
treef8645f310c3bdd52746f574a51ae027af57f39ab
parentc5abf3c8716b1e731cb08a341281bff55339b99f (diff)
downloaddrakx-backup-do-not-use-f0f54fec1e8a3c7b8e24be3de3dc12deac4998dc.tar
drakx-backup-do-not-use-f0f54fec1e8a3c7b8e24be3de3dc12deac4998dc.tar.gz
drakx-backup-do-not-use-f0f54fec1e8a3c7b8e24be3de3dc12deac4998dc.tar.bz2
drakx-backup-do-not-use-f0f54fec1e8a3c7b8e24be3de3dc12deac4998dc.tar.xz
drakx-backup-do-not-use-f0f54fec1e8a3c7b8e24be3de3dc12deac4998dc.zip
remove connect/diconnect_backend
add start/stop_net_interface add detach parameter to start/stop_interface
-rw-r--r--perl-install/network/netconnect.pm8
-rw-r--r--perl-install/network/tools.pm52
-rwxr-xr-xperl-install/standalone/drakconnect4
-rw-r--r--perl-install/standalone/net_applet9
-rwxr-xr-xperl-install/standalone/net_monitor8
5 files changed, 40 insertions, 41 deletions
diff --git a/perl-install/network/netconnect.pm b/perl-install/network/netconnect.pm
index 6b1672ad3..76fd01044 100644
--- a/perl-install/network/netconnect.pm
+++ b/perl-install/network/netconnect.pm
@@ -1272,9 +1272,9 @@ It is not necessary on most networks."),
if ($a) {
# local $::isWizard = 0;
my $_w = $in->wait_message('', N("Testing your connection..."), 1);
- network::tools::disconnect_backend($net);
+ network::tools::stop_net_interface($net, 0);
sleep 1;
- network::tools::connect_backend($net);
+ network::tools::start_net_interface($net, 1);
my $s = 30;
$type =~ /modem/ and $s = 50;
$type =~ /adsl/ and $s = 35;
@@ -1361,12 +1361,12 @@ sub start_internet {
#- give a chance for module to be loaded using kernel-BOOT modules...
#- FIXME, this has nothing to do there
$::isStandalone or modules::load_category($o->{modules_conf}, 'network/*');
- network::tools::start_interface($o->{net}{net_interface});
+ network::tools::start_net_interface($o->{net}, 1);
}
sub stop_internet {
my ($o) = @_;
- network::tools::stop_interface($o->{net}{net_interface});
+ network::tools::stop_net_interface($o->{net}, 1);
}
1;
diff --git a/perl-install/network/tools.pm b/perl-install/network/tools.pm
index 1d15b50c0..4be315700 100644
--- a/perl-install/network/tools.pm
+++ b/perl-install/network/tools.pm
@@ -48,43 +48,41 @@ sub passwd_by_login {
}
}
-sub connect_backend {
- my ($net) = @_;
- run_program::raw({ detach => 1, root => $::prefix }, "/sbin/ifup", $net->{net_interface});
-}
-
-sub disconnect_backend {
- my ($net) = @_;
- run_program::raw({ detach => 1, root => $::prefix }, "/sbin/ifdown", $net->{net_interface});
-}
-
-sub bg_command_as_root {
+sub wrap_command_for_root {
my ($name, @args) = @_;
#- FIXME: duplicate code from common::require_root_capability
- if (check_for_xserver() && fuzzy_pidofs(qr/\bkwin\b/) > 0) {
- run_program::raw({ detach => 1 }, "kdesu", "--ignorebutton", "-c", "$name @args");
- } else {
- run_program::raw({ detach => 1 }, [ 'consolehelper', $name ], @args);
- }
+ check_for_xserver() && fuzzy_pidofs(qr/\bkwin\b/) > 0 ?
+ ("kdesu", "--ignorebutton", "-c", "$name @args") :
+ ([ 'consolehelper', $name ], @args);
}
-sub user_run_interface_command {
- my ($command, $intf) = @_;
- if (system("/usr/sbin/usernetctl $intf report") == 0) {
- run_program::raw({ detach => 1 }, $command, $intf);
- } else {
- bg_command_as_root($command, $intf);
- }
+sub run_interface_command {
+ my ($command, $intf, $detach) = @_;
+ my @command =
+ !$> || system("/usr/sbin/usernetctl $intf report") == 0 ?
+ ($command, $intf) :
+ wrap_command_for_root($command, $intf);
+ run_program::raw({ detach => $detach, root => $::prefix }, @command);
}
sub start_interface {
- my ($intf) = @_;
- user_run_interface_command('/sbin/ifup', $intf);
+ my ($intf, $detach) = @_;
+ run_interface_command('/sbin/ifup', $intf, $detach);
}
sub stop_interface {
- my ($intf) = @_;
- user_run_interface_command('/sbin/ifdown', $intf);
+ my ($intf, $detach) = @_;
+ run_interface_command('/sbin/ifdown', $intf, $detach);
+}
+
+sub start_net_interface {
+ my ($net, $detach) = @_;
+ start_interface($net->{net_interface}, $detach);
+}
+
+sub stop_net_interface {
+ my ($net, $detach) = @_;
+ stop_interface($net->{net_interface}, $detach);
}
sub connected() { gethostbyname("mandrakesoft.com") ? 1 : 0 }
diff --git a/perl-install/standalone/drakconnect b/perl-install/standalone/drakconnect
index 3b8393265..20f9638b2 100755
--- a/perl-install/standalone/drakconnect
+++ b/perl-install/standalone/drakconnect
@@ -94,9 +94,9 @@ my $int_connect = Gtk2::Button->new(N("Wait please"));
$int_connect->set_sensitive(0);
$int_connect->signal_connect(clicked => sub {
if (!$isconnected) {
- network::tools::start_interface($net->{net_interface});
+ network::tools::start_net_interface($net, 1);
} else {
- network::tools::stop_interface($net->{net_interface});
+ network::tools::stop_net_interface($net, 1);
}
});
diff --git a/perl-install/standalone/net_applet b/perl-install/standalone/net_applet
index d8e72394e..03b5cba10 100644
--- a/perl-install/standalone/net_applet
+++ b/perl-install/standalone/net_applet
@@ -63,8 +63,8 @@ Run the \"%s\" assistant from the Mandriva Linux Control Center", N("Set up a ne
);
my %actions = (
- 'upNetwork' => { name => sub { N("Connect %s", $_[0]) }, launch => \&network::tools::start_interface },
- 'downNetwork' => { name => sub { N("Disconnect %s", $_[0]) }, launch => \&network::tools::stop_interface },
+ 'upNetwork' => { name => sub { N("Connect %s", $_[0]) }, launch => sub { network::tools::start_interface($_[0], 1) } },
+ 'downNetwork' => { name => sub { N("Disconnect %s", $_[0]) }, launch => sub { network::tools::stop_interface($_[0], 1) } },
'monitorNetwork' => { name => N("Monitor Network"), launch => sub { system("/usr/sbin/net_monitor --defaultintf $_[0] &") } },
'wireless' => { name => N("Manage wireless networks"), launch => sub { system("/usr/sbin/drakroam &") } },
'confNetwork' => { name => N("Configure Network"), launch => sub { system("/usr/sbin/drakconnect --skip-wizard &") } },
@@ -82,8 +82,9 @@ my %actions = (
choices => sub { network::network::netprofile_list() },
choice_selected => sub { $_[0] eq $net->{PROFILE} },
launch => sub {
- $net->{PROFILE} = $_[0];
- network::tools::bg_command_as_root('/sbin/set-netprofile', $net->{PROFILE});
+ require run_program;
+ $net->{PROFILE} = $_[0];
+ run_program::raw({ detach => 1 }, network::tools::wrap_command_for_root('/sbin/set-netprofile', $net->{PROFILE}));
}
},
'refresh' => { name => N("Refresh"), launch => sub { checkNetworkForce() } },
diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor
index e72e8e53a..1bef0f4d5 100755
--- a/perl-install/standalone/net_monitor
+++ b/perl-install/standalone/net_monitor
@@ -47,8 +47,8 @@ network::network::read_net_conf($net);
$default_intf ||= $net->{default}{interface};
if ($force) {
- $connect and network::tools::start_interface($default_intf);
- $disconnect and network::tools::stop_interface($default_intf);
+ $connect and network::tools::start_interface($default_intf, 1);
+ $disconnect and network::tools::stop_interface($default_intf, 1);
$connect = $disconnect = 0;
}
$quiet and exit(0);
@@ -251,8 +251,8 @@ sub connection() {
$tool_pid =
$wasconnected == 1
- ? network::tools::stop_interface($default_intf)
- : network::tools::start_interface($default_intf);
+ ? network::tools::stop_interface($default_intf, 1)
+ : network::tools::start_interface($default_intf, 1);
}
sub graph_window_width() { $width - $left_border }