From 489c2506cd2fd51efa7b167248a378d07923abfe Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Thu, 21 Nov 2013 18:52:13 +0000 Subject: polkit: Fix support for several third party net management commands (mga#11286) --- NEWS | 1 + bin/net_applet | 2 +- lib/network/tools.pm | 10 +++++----- lib/network/vpn.pm | 3 +-- polkit/Makefile | 3 ++- polkit/com.redhat.initscripts.ifdown.policy.in | 21 +++++++++++++++++++++ polkit/com.redhat.initscripts.ifup.policy.in | 21 +++++++++++++++++++++ polkit/com.redhat.initscripts.vpn-start.policy.in | 21 +++++++++++++++++++++ polkit/com.redhat.initscripts.vpn-stop.policy.in | 21 +++++++++++++++++++++ polkit/org.mageia-x.set-netprofile.policy.in | 21 +++++++++++++++++++++ 10 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 polkit/com.redhat.initscripts.ifdown.policy.in create mode 100644 polkit/com.redhat.initscripts.ifup.policy.in create mode 100644 polkit/com.redhat.initscripts.vpn-start.policy.in create mode 100644 polkit/com.redhat.initscripts.vpn-stop.policy.in create mode 100644 polkit/org.mageia-x.set-netprofile.policy.in diff --git a/NEWS b/NEWS index 46ca9b1..f2c36b6 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +- polkit: fix support for several third party net management commands (mga#11286) - do not do costly urpmi check before forking net_monitor 1.28 diff --git a/bin/net_applet b/bin/net_applet index a722c28..7f36960 100755 --- a/bin/net_applet +++ b/bin/net_applet @@ -192,7 +192,7 @@ my %actions = ( launch => sub { require run_program; $net->{PROFILE} = $_[0]; - run_program::raw({ detach => 1 }, common::wrap_command_for_root('/sbin/set-netprofile', $net->{PROFILE})); + run_program::raw({ detach => 1 }, (if_($>, '/usr/bin/pkexec'), '/usr/sbin/set-netprofile', $net->{PROFILE})); } }, 'chooseVPN' => { diff --git a/lib/network/tools.pm b/lib/network/tools.pm index cd7b69d..951b445 100644 --- a/lib/network/tools.pm +++ b/lib/network/tools.pm @@ -20,22 +20,22 @@ sub passwd_by_login { } sub run_interface_command { - my ($command, $intf, $detach) = @_; + my ($action, $intf, $detach) = @_; my @command = !$> || system("/usr/sbin/usernetctl $intf report") == 0 ? - ($command, $intf, if_(!$::isInstall, "daemon")) : - common::wrap_command_for_root($command, $intf); + ('/usr/sbin/if' . $action, $intf, if_(!$::isInstall, "daemon")) : + ('/usr/bin/pkexec', '/usr/sbin/if' . $action, $intf); run_program::raw({ detach => $detach, root => $::prefix }, @command); } sub start_interface { my ($intf, $detach) = @_; - run_interface_command('/sbin/ifup', $intf, $detach); + run_interface_command('up', $intf, $detach); } sub stop_interface { my ($intf, $detach) = @_; - run_interface_command('/sbin/ifdown', $intf, $detach); + run_interface_command('down', $intf, $detach); } sub start_net_interface { diff --git a/lib/network/vpn.pm b/lib/network/vpn.pm index 21142c8..147ecc8 100644 --- a/lib/network/vpn.pm +++ b/lib/network/vpn.pm @@ -113,8 +113,7 @@ sub get_config_path { sub _run { my ($connection, $action, @args) = @_; - my @command = ('vpn-' . $action, $connection->get_type, $connection->get_name, @args); - @command = common::wrap_command_for_root(@command) if $>; + my @command = (if_($>, '/usr/bin/pkexec'), '/usr/sbin/vpn-' . $action, $connection->get_type, $connection->get_name, @args); require run_program; run_program::rooted($::prefix, , @command); } diff --git a/polkit/Makefile b/polkit/Makefile index dc7c4ba..631426e 100644 --- a/polkit/Makefile +++ b/polkit/Makefile @@ -5,7 +5,8 @@ POLKITPOLICYDEST = $(DESTDIR)/usr/share/polkit-1/actions POLICY_IN := $(wildcard *.policy.in) POLICY = $(POLICY_IN:.policy.in=.policy) -WRAPPERS = $(patsubst org.mageia.%.policy,%,$(POLICY)) +MGAPOLICY_IN := $(wildcard org.mageia.*.policy.in) +WRAPPERS = $(patsubst org.mageia.%.policy.in,%,$(MGAPOLICY_IN)) all: $(WRAPPERS) $(POLICY) diff --git a/polkit/com.redhat.initscripts.ifdown.policy.in b/polkit/com.redhat.initscripts.ifdown.policy.in new file mode 100644 index 0000000..1413004 --- /dev/null +++ b/polkit/com.redhat.initscripts.ifdown.policy.in @@ -0,0 +1,21 @@ + + + + + Mageia + http://www.mageia.org/ + + + <_description>Take Network Interface Down + <_message>Authentication is required to take down a network interface + drakconf + + no + no + auth_admin_keep + + /usr/sbin/ifdown + + diff --git a/polkit/com.redhat.initscripts.ifup.policy.in b/polkit/com.redhat.initscripts.ifup.policy.in new file mode 100644 index 0000000..73ac819 --- /dev/null +++ b/polkit/com.redhat.initscripts.ifup.policy.in @@ -0,0 +1,21 @@ + + + + + Mageia + http://www.mageia.org/ + + + <_description>Bring Network Interface Up + <_message>Authentication is required to bring up a network interface + drakconf + + no + no + auth_admin_keep + + /usr/sbin/ifup + + diff --git a/polkit/com.redhat.initscripts.vpn-start.policy.in b/polkit/com.redhat.initscripts.vpn-start.policy.in new file mode 100644 index 0000000..317b78e --- /dev/null +++ b/polkit/com.redhat.initscripts.vpn-start.policy.in @@ -0,0 +1,21 @@ + + + + + Mageia + http://www.mageia.org/ + + + <_description>Start Virtual Private Network + <_message>Authentication is required start the Virtual Private Network + drakconf + + no + no + auth_admin_keep + + /usr/sbin/vpn-start + + diff --git a/polkit/com.redhat.initscripts.vpn-stop.policy.in b/polkit/com.redhat.initscripts.vpn-stop.policy.in new file mode 100644 index 0000000..debfe21 --- /dev/null +++ b/polkit/com.redhat.initscripts.vpn-stop.policy.in @@ -0,0 +1,21 @@ + + + + + Mageia + http://www.mageia.org/ + + + <_description>Stop Virtual Private Network + <_message>Authentication is required stop the Virtual Private Network + drakconf + + no + no + auth_admin_keep + + /usr/sbin/vpn-stop + + diff --git a/polkit/org.mageia-x.set-netprofile.policy.in b/polkit/org.mageia-x.set-netprofile.policy.in new file mode 100644 index 0000000..df91115 --- /dev/null +++ b/polkit/org.mageia-x.set-netprofile.policy.in @@ -0,0 +1,21 @@ + + + + + Mageia + http://www.mageia.org/ + + + <_description>Set Network Profile + <_message>Authentication is required to set the network profile + drakconf + + no + no + auth_admin_keep + + /usr/sbin/set-netprofile + + -- cgit v1.2.1