Making applications to ask for root password (wifi-radar example)

Some apps need root privileges in order to work properly. One of these is wifi-radar, simple tool for connecting with wireless networks. You can run it from root’s command-line, but it’s much easier (and cool, too ;) to execute it from gnome-panel, and make it ask for superuser’s password. Here’s how. Note: This example covers wifi-radar, however it should work similar way with all other apps.

  1. Assume, main wifi-radar file is located in /usr/local/bin directory (it’s wifi-radar’s default installation directory, anyway) and make sure all operations below are done as root user
  2. Create symbolic link to consolehelper by executing: ln -s /usr/bin/consolehelper /usr/local/bin/wifir (as root)
  3. Create file /etc/security/console.apps/wifir (note: name of file must be same as symbolic link created above) with following content:
    USER=root
    PROGRAM=/usr/local/bin/wifi-radar
    SESSION=true
    FALLBACK=false
    
  4. Create file /etc/pam.d/wifir with following content:
    #%PAM-1.0
    auth       sufficient   pam_rootok.so
    auth       sufficient   pam_timestamp.so
    auth       required     pam_stack.so service=system-auth
    session    required     pam_permit.so
    session    optional     pam_xauth.so
    session    optional     pam_timestamp.so
    account    required     pam_permit.so
    
  5. Now you can create gnome-panel launcher, making sure it will launch /usr/local/bin/wifir symbolic link, instead of wifi-radar itself.

That’s it! :)

Related

WiFi Radar’s homepage (original source of instructions above, however without FALLBACK=false line in /etc/security/console.apps/wifir, nothing happens after entering root’s password)

One Response to “Making applications to ask for root password (wifi-radar example)”

  1. Jon Says:

    Hi Evad,

    Gnome and KDE both provide a mechanism for running apps as the root user. Simply setup the shortcut to use ‘kdesu’ for kde and ‘gksu’ for gnome.

    e.g.
    gksu “wifir”