Comment 3 for bug 258799

Revision history for this message
hoganrobert (robert-roberthogan) wrote :

This patch:

- Fixes an infinite loop in 'kdesudo -s'
- Removes a compiler warning.
- Documents the escape sequences and quoting required to run shell commands.
  (Not sure about the docbook patch.)

I've experimented quite a bit with the command parsing required to make
kdesudo functionally equivalent with kdesu. I tried using the parsing found in
kdesu and while this fixes the quoting of each element for some commands, the
fact that kdesudo is not using the Suprocess/ttyprocess and kdesud abstraction
layers seems fatal. The code required to take a naively quoted/escaped command
such as this one used by KDevelop:

kdesu -t -c 'cd '/home/robert/kdesudo-2.6-new' && WANT_AUTOCONF_2_5="1" WANT_AUTOMAKE_1_6="1" LC_MESSAGES="C" LC_CTYPE="C" make install'

and make it work with kdesudo is beyond me. AFAICS, kdesudo would need to prepend
a shell to the command (sh -c) and properly quote and escape each element before
passing it to sudo. This would be a huge job and extremely brittle.

Since kdesudo is kubuntu-specific the more pragmatic approach would seem to be to
document the command format kdesudo requires and patch kdesu-using packages as
appropriate.

So kubuntu-KDevelop should use:

kdesudo -t -c "sh -c 'cd '/home/robert/kdesudo-2.6-new' && WANT_AUTOCONF_2_5=\"1\" WANT_AUTOMAKE_1_6=\"1\" LC_MESSAGES=\"C\" LC_CTYPE=\"C\" make install'"

This could also be passed upstream since it also works with kdesu.distrib.

For my own case the command required by kdesudo is:

kdesudo -c "sh -c 'printf \"ControlPort 9051\n\" >> /etc/tor/torrc'"

This also works with kdesu.distrib.