The problem
Some programs require root privileges for part of their work: most notably Debian building tools such as dpkg-buildpackage or pdebuild. So, several command can be used to obtain real or fake root privileges: su, sudo, fakeroot, etc. Among them, su is quite distinct, because it only takes a quoted command to pass it to a shell. That is why its interface is completely incompatible with the others':
$ su -c "pbuilder --build package.dsc" $ sudo pbuild --build package.dsc
This is annoying when real root privileges are needed, for instance by pbuilder, a tool to build Debian packages inside a minimal chroot. Indeed, in such a case I only know one command to obtain the root privileges, sudo, and some people (read: me) prefer using su.
A wrapper
Long story short: as I saw no existing tool to do that (but I would be glad to hear if there was already one), I wrote a wrapper that emulates a (very basic) sudo-like interface by using su, and vice-versa. It is available from my Git repository:
$ git clone git://git.ortolo.eu/sudo-su.git
It is polymorphic, BusyBox-style: call it sudo-su and it will emulate sudo with su; call it su-sudo and it will emulate su with sudo. For instance:
$ pdebuild --pbuilderroot /usr/local/bin/sudo-su
It is WTFPL-licensed, it implements no options from sudo and su (except
sudo's -c
, of course), but I can do something better if
it may be useful to other people.
5 comments
saturday 28 may 2011 à 02:55 Ben Armstrong said : #1
saturday 28 may 2011 à 10:11 KiBi said : #2
saturday 28 may 2011 à 11:11 Elessar said : #3
friday 03 june 2011 à 11:47 mirabilos said : #4
sunday 05 june 2011 à 19:07 Tanguy said : #5