I'm creating a small router program (GTK frontend) in python for some of our less CLI savvy users. I've developed the glade front-end and able to connect the various signals. Now, I'm facing only one issue which is to create the 'sudo' interface.
For some reasons, we don't want the user to start the program using gksu, but instead provide him a password dialog that is later stored in the program (similar to what happens with synaptic package manager).
Trouble is that the script works fine when I tested on GNOME 3 desktop where I developed it, but on ubuntu the gksu command is not saving anything to keyring. Instead, it asks password for each command! Here is the function in the program that calls gksu:
def execute(command,errorstring='', wait = True, shellexec = True): try: print 'command=' + command p=subprocess.Popen("gksu '" + command + "'", shell=shellexec,stdout=subprocess.PIPE,stderr=subprocess.PIPE) if wait: p.wait() result=get_stdout(p) return result else: print 'not waiting' return p except subprocess.CalledProcessError as e: print 'error occured:' + errorstring return errorstring
And here is an example of how I call the execute function in some parts of my program:
#stop hostapd if already running. if is_process_running('hostapd')>0: writelog('stopping hostapd') **execute('killall hostapd')** #enable forwarding in sysctl. writelog('enabling forward in sysctl.') set_sysctl('net.ipv4.ip_forward','1')
How do I go about it so that the gksu call stores password in the keyring or something and doesn't bother user each time ?