Bypass Gnomesu for Sudo LAN Configuration for Non-Root Users

Novell Cool Solutions: Feature
By Axel Schmidt

Digg This - Slashdot This

Posted: 20 Jul 2006

This article is also available as a PDF

This document contains the basic steps for enabling the sudo functionality, that non-root users gain the right to change the network configuration of the SUSE Linux Enterprise Desktop featuring a seamless integration within GNOME. Discovering the GNOME Desktop, one will notice that the network configuration can be launched from different places, e.g. using "Control Center->Network Card" or through the NetworkManager Applet. All actions that need root access will start "gnomesu" with its pop-up window as shown below. After the root password is typed in, the corresponding YaST module will be called. In our case, for configuring the network, "/sbin/yast2 lan" is called.


  • The desktop user may not have root access, e.g. is not able to call YaST for system configuration.
  • The non-root user shall be able to change the network configuration, to be able to configure the wired and wlan network interface.


The "sudo" configuration file specifies what a user may execute as another user and can be used for adding system function calls like "/sbin/yast2 lan" that requires root permissions. After sudoers is configured, the user may execute "sudo /sbin/yast lan" without being asked to type in the root password. Here in the example we will create our own shell script "mod_lan.sh" which works as a helper script.

To edit /etc/sudoers perform the following steps:

  • Login as root
  • Execute: visudo
    Note: Do not use "vi /etc/sudoers", it is recommended to use "visudo" for editing sudeors.
  • Add the following line:
    ALL ALL = NOPASSWD:/usr/bin/mod_lan.sh

Script mod_lan.sh

This is the helper script which covers the yast2 function call and is basically used to export the DISPLAY environment variable, that the yast2 application running as root may display its output to the users X-window. Furthermore the user has to perform "xhost +local:root" to allow it. This can be done automatically by setting up a specific profile e.g. "/etc/profile.d/xdialog.sh" which performs the task, each time when a users logs into the system.

To create "mod_lan.sh" use the editor of your choice and perform the following steps:

  • Login as root
  • e.g. "vi /usr/bin/mod_lan.sh"
  • cut and paste the following lines below
  • save file
  • chmod 755 /usr/bin/mod_lan.sh
export DISPLAY=:0.0
/sbin/yast2 lan

Script xdialog.sh

The helper script "/etc/profile.d/xdialog.sh" allows root application on the localhost to be displayed on the users X-window. To create "xdialog.sh" use the editor of your choice and perform the following steps:

  • Login as root
  • e.g. "vi /etc/profile.d/xdialog.sh"
  • cut and paste the following lines below
  • save file
  • chmod 755 /etc/profile.d/xdialog.sh
# Enable root X messages to be written on Users Xterm
xhost +local:root

Note: For testing the actual result just call "sudo /usr/bin/mod_lan.sh". If Yast2 starts in text mode run xdialog.sh, because you have to logout and login again to run the profile scripts located below.



The gnomesu function is provided by the libgnomesu-1.0.0.-32.5 package. To achieve a seamless integration within GNOME we have to copy the original gnomesu function and have to replace it by our own "gnomesu" function, which takes over control only in the case when "/sbin/yast2 lan" is requested. You should be aware, that this solution is a kind of "hack" and you have to take care every time you update your system, because new versions of the libgnomesu package will overwrite our customized gnomesu and will disable the sudo lan configuration option again.

If you still feel ready to go forward with this solution, perform the following the steps:

  • mv /opt/gnome/bin/gnomesu /opt/gnome/bin/gnomesu.orig
  • create a file "/opt/gnome/bin/gnomesu" with the following entries:
# Plattform:     SuSE Linux Enterprise Desktop 10
# Purpose:       Helper Script to enable sudo access for non-privileged users for
#                for the following system configurations:
#                - lan
# Prerequisite:  Replace existing gnomesu with this script and rename it to
#                gnomesu.orig
#                Add /opt/PSA/bin/mod_lan.sh to sudeors.
# Note: depending on if "yast lan" is called from NM or control center the parameter
# nb. differs
if [ "$2" = "lan" -o "$3" = "lan" ]; then
        sudo /opt/PSA/bin/mod_lan.sh
    $(/opt/gnome/bin/gnomesu.orig $1 $2 $3 $4)


What about timezone? Just repeat the above steps for "/sbin/yast2 timezone":

  • Edit sudoers and add a script named "mod_time.sh".
  • Create the helper script mod_time.sh
  • Add a further if /else case in gnomesu:
. . .
. . .
 if [ "$2" = "timezone" -o "$3" = "timezone" ]; then
                        sudo /opt/PSA/bin/mod_time.sh
. . .

Have fun!

Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© Micro Focus