su spawns a new (shell) process. This is a new Process, so its
completely separated from the process it have been called. After the
line system("su -") you program would be sleeping and the opened shell
would not get any new commands like the call to your init script.
Simple solution:
Just pop up a box saying that the user has to start /etc/init.d/net.ath0
start before using your program.
The root password should be typed in a entry box, let's say
'rootpasswordentry'. I know I could get it's text with
rootpasswordentry->get_text().
This does not help either since your box would ask the root passwort in
the user process. su instead spawns the new process before asksing the
passwort. This reduces the risk that the passwort gets keylogged.
In fact program would be a root passwort sniffer which has to be
rejected.
Any idea, guys? What do you recommend me to read? Should I continue with
Gtkmm 2.4 Book (it seems just like a reference book since the ¨ "Button"
chapter)?
Well your problem isnt gtkmm or glade based. But read on :)
Maybe you want to beek into Advanced UNIX Programming (2nd Edition):
http://www.amazon.com/exec/obidos/tg/detail/-/0131411543/qid=1108891477/sr=8-1/ref=pd_csp_1/002-2061515-3535227?v=glance&s=books&n=507846
Bye Gunther
Gunther, thank you for your answer. Indeed, the program is designed to
run "/etc/init.d/net.ath0" command, for example. For this command to
run, it is needed the root password. Have you ever seen Synaptic or
other program that needs to do a admin task and asks the root password?
That's what I want to do.