Best way to gain root privileges
Alexander Kapps
alex.kapps at web.de
Wed Feb 16 17:37:24 EST 2011
On 16.02.2011 23:02, Ian Kelly wrote:
> On Wed, Feb 16, 2011 at 2:29 PM, Daniel Mahoney<catdude at gmail.com> wrote:
>> On Wed, 16 Feb 2011 21:26:26 +0000, GSO wrote:
>>
>>> I'm sure this question is as old as time, but what is the best way to
>>> gain root privileges? (Am using Python 2.6.5, pygtk2 v2.16, Gtk
>>> v2.18.9, on RHEL6.)
>>
>> Gain root privileges for a script? Write a c wrapper to call the script,
>> chown it (the wrapper) to root, and set it (the wrapper) suid.
>
> Or for better security, write a shell script that execs the Python
> script via sudo.
This is what I occasionally use (in a non security critical
environment anyway):
#!/bin/sh
SUDO=gksudo
[ -z "$DISPLAY" ] && SUDO=sudo
[ "$(id -u)" != 0 ] && exec $SUDO $0 $@
# your_root_privileges_requiring_commands_here
Don't ask me for any security issues. Properly setting up a
dedicated user group and grant dedicated sudo privileges is probably
a better way.
HTH
More information about the Python-list
mailing list