kdesudo exits with incorrect status

Bug #285084 reported by Davlet Panech on 2008-10-17
2
Affects Status Importance Assigned to Milestone
KdeSudo
Undecided
Unassigned

Bug Description

kdesudo exits with status 0 under various error conditions:
* when sudo returns non-zero (i.e., child process' exit code isn't propagated)
* when the user clicks "Cancel", "Ignore" or the close button on the dialog

I'm not sure how kdesu handles these situations, but it seems wrong. As it is it's impossible to determine whether a command succeeded or not e.g., when you call kdesudo from a script.

Related branches

Davlet Panech (dp1978x-lists) wrote :

OK, I did some more digging and found a whole bunch of problems, some of them are not (easily) fixable, please diregard my first patch for now. At this point I'm ready to give up on kdesudo, but I thought I'd describe the issues here so somebody can attend to them at some point. I appologize if this is not an appropriate place for this discussion, is there a dev mail list for this project or something?

Anyway here are some of the problems:

1) AFAICT "sudo" works as follows: it authenticates the user and then _execs_ the command. The result is that the exit status from sudo equals exit status of the command being executed (except when authentication failed), including WIFSIGNALED, etc.

Kdesudo can't do that because we can't easily authenticate the user (we would have to parse /etc/sudoers do do that). So I think to keep the beheavior consistent we should always wait until sudo exits and exit the same way, i.e., if it exited normally exit with the same status; if it was killed, kill self with the same signal number.

Right now kdesudo exits prematurely at least sometimes, so one can't rely on its exit status.

Note that kdesu suffers from silimar problems.

2) It sucks that STDERR gets printed on STDOUT. This is easilty fixable.

3) There's a problem with KProcess (at least in KDE 3.4 that I'm using): it doesn't guarantee the order of "processExited" and "receivedStd{out,err}" events. I think sometimes we receive "processExited" before processing sudo's output (no error message is displayed).

4) What's the purpose of the "Ignore" button? It seems to behave the same way as "Cancel/Close".

5) Using su/kdesu: "su/kdesu -c COMMAND" is the same thing as "su/kdesu /bin/sh -c COMMAND". (i.e., COMMAND is essentially a shell script). But kdesudo doesn't call /bin/sh, instead it does some half-assed word-splitting on COMMAND and then forks/execs the resultant command line. I guess it's to accomodate people who do this:

  kdesudo -c "program args..."

instead of (the right way):

  kdesudo program args

without relying on /bin/sh being mentioned in /etc/sudoers file.

Anyway I think it's a bad idea, it's weird and inconsistent with su/kdesu behavior, I'm not even sure if KShell::splitArgs is 100% compatible with the real shell.

Thoughts, comments?
D.

Changed in kdesudo:
status: New → Fix Committed
Changed in kdesudo:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers