After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 619156 - Limitation of anjuta_launcher_execute_v
Limitation of anjuta_launcher_execute_v
Status: RESOLVED OBSOLETE
Product: anjuta
Classification: Applications
Component: libanjuta
unspecified
Other Linux
: Normal major
: ---
Assigned To: Naba Kumar
Anjuta maintainers
Depends on:
Blocks:
 
 
Reported: 2010-05-20 02:39 UTC by liping Ke
Modified: 2010-10-12 14:25 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description liping Ke 2010-05-20 02:39:56 UTC
When we develop poky plugin, we found a limitation of this function. If in a bash script file (run as lke), we call another process such as (sudo start qemu)(run as root), then the passwd dialog will show. If the user click "cancel", we will have problem, it does kill the user process (bash script), but the son process (sudo start qemu) will hang there for ever.

I think for emulating tty terminal experiences, when you sudo, if the user did not enter passwd, he has no way to cancel, but to terminate the process. So the same way with the passwd dialog, maybe the dialog should has no cancel/X option? Or if user click cancel, you can just deliver "empty" to tty output?

This limitation will cause all (user process -> sudo root process -> cancel) usage senario fail, I think.

Thanks& Regards,
criping
Comment 1 Johannes Schmid 2010-05-20 07:36:43 UTC
Well, I added this because when you "make install" as root in anjuta and click cancel, there were two other prompts for the password and only after you also canceled them, the process was killed.

Is there a way to kill a process and all it's children? Some googling didn't help me too much.
Comment 2 liping Ke 2010-05-20 08:47:29 UTC
Hi, Johannes
I found this problem when we developer poky plugin. It's not because we run anjuta as root. Actually we run anjuta as normal user.

This problem is caused by the anjuta_launcher_execute_v. If the plugin use anjuta_launcher_execute_v  to execute a script as normal user, and the script then invoke a sudo process, anjuta_launcher_execute_v will pop up password dialog for this sudo process (this is son process whose parent is the script process. However this script process is running as the child process of current process according to anjuta_launcher_execute_v logic). If user click password dialog "cancel", the anjuta_launcher_execute_v did try to kill the child process (script process), yet the son's son sudo XX process still alive. Then the problem happens.

At first, we did consider that anjuta_launcher_execute_v should kill both parent script process as well as child sudo process. But it's unreasonable since user process can't kill son root process when sudo password dialog got "cancel" response. So we think anjuta_launcher_execute_v should treat "cancel" as blank input for the sudo password just like normal sudo command in terminal does.

We confirm this phenomenon by testing...

Thanks & Regards,
criping
Comment 3 Johannes Schmid 2010-05-20 14:59:54 UTC
> I found this problem when we developer poky plugin. It's not because we run
> anjuta as root. Actually we run anjuta as normal user.

Sorry, you misunderstood me, I didn't mean that you should ever do this or that anybody would.


> At first, we did consider that anjuta_launcher_execute_v should kill both
> parent script process as well as child sudo process. But it's unreasonable
> since user process can't kill son root process when sudo password dialog got
> "cancel" response. So we think anjuta_launcher_execute_v should treat "cancel"
> as blank input for the sudo password just like normal sudo command in terminal
> does.
> 
> We confirm this phenomenon by testing...

As I pointed out, treating it like a blank input sucks because the password prompt will come up again n times (with n probably 3 on most systems). And when the user presses cancel he really decides to cancel whatever happens and doesn't want that the prompt comes up again as if we input an invalid password.

I don't see the point why the parent process (e.g. anjuta) shouldn't be able to kill the child process (e.g. /bin/bash) and all it's children (e.g. sudo, which isn't running as root, yet). I think that would be the cleanest way. So I was asking if you know a system call that does exactly that.
Comment 4 liping Ke 2010-05-21 01:37:30 UTC
(In reply to comment #3)
> > I found this problem when we developer poky plugin. It's not because we run
> > anjuta as root. Actually we run anjuta as normal user.
> Sorry, you misunderstood me, I didn't mean that you should ever do this or that
> anybody would.
> > At first, we did consider that anjuta_launcher_execute_v should kill both
> > parent script process as well as child sudo process. But it's unreasonable
> > since user process can't kill son root process when sudo password dialog got
> > "cancel" response. So we think anjuta_launcher_execute_v should treat "cancel"
> > as blank input for the sudo password just like normal sudo command in terminal
> > does.
> > 
> > We confirm this phenomenon by testing...
> As I pointed out, treating it like a blank input sucks because the password
> prompt will come up again n times (with n probably 3 on most systems). And when
> the user presses cancel he really decides to cancel whatever happens and
> doesn't want that the prompt comes up again as if we input an invalid password.
Yes, I totally agree with you. If we have a way of really doing "cancel", it's great. Yet I just can't think out a way to kill the process and all its subprocess running as root currently...
> I don't see the point why the parent process (e.g. anjuta) shouldn't be able to
> kill the child process (e.g. /bin/bash) and all it's children (e.g. sudo, which
> isn't running as root, yet). I think that would be the cleanest way. So I was
> asking if you know a system call that does exactly that.

O, /bin/bash is killed (run as user lke). It's son process sudo start qemu still there:) I can confirm this by ps -eaf | grep "qemu". And I saw the user of this process is "root"(Although I'm not sure why it's running as root, but it does) :(

If not the privilege problem, I did search how to kill all child process by google, seems one -command \ can't do this... We have to use something like process group concept and kill one by one ... seems quite complex...
I also have few experiences on this:)

Thanks a lot for your help!
criping
Comment 5 Johannes Schmid 2010-06-29 08:50:16 UTC
Could you get around this problem somehow? I really don't see a way how to fix that properly without giving the users annoying password dialogs when they already cancelled things.
Comment 6 liping Ke 2010-06-29 09:07:18 UTC
Hi, Johannes
We did find a solution to workaround, do sudo earlier (before sub-process created) for avoiding normal-user parent process to create root-user process and normal-user has no way to kill the root-user sub-process.

We use sudo to launch the qemu script. So when dialog prompts, there's only one process (sub process[qemu launching] is not created yet). If user cancels, anjuta will kill this single ONE process normally.


Thanks& Regards,
criping
Comment 7 Johannes Schmid 2010-10-12 14:25:57 UTC
Closing this! Thanks for taking the time to figure out how to fix it for you.