FAQ
Hello,
i need some answers...

1) I need to run some linux commands (from inside my app) that require
superuser privileges (mkfs, losetup, etc), how do i do that? (I do not
want to run my app with root privileges, but it will just ask the user
for the root password before proceeding)
2) When i execute the command i need to read its output (especially the
error messages) to know if everything went fine but i do not know how :(
3) How can i know if the user that is running my app is root or normal user?

Thank you,
Luca

Search Discussions

  • Mathias Waack at Mar 14, 2004 at 8:52 pm

    Luca T. wrote:
    1) I need to run some linux commands (from inside my app) that
    require superuser privileges (mkfs, losetup, etc), how do i do
    that? (I do not want to run my app with root privileges, but it
    will just ask the user for the root password before proceeding)
    man sudo(1), su(1) or setuid-bit (chmod(1))
    2) When i execute the command i need to read its output (especially
    the error messages) to know if everything went fine but i do not
    know how :
    see the popen family of functions in the Python library.
    ( 3) How can i know if the user that is running my app is
    root or normal user?
    os.getuid()

    Mathias
  • Luca T. at Mar 14, 2004 at 9:46 pm

    Mathias Waack wrote:
    Luca T. wrote:
    1) I need to run some linux commands (from inside my app) that
    require superuser privileges (mkfs, losetup, etc), how do i do
    that? (I do not want to run my app with root privileges, but it
    will just ask the user for the root password before proceeding)

    man sudo(1), su(1) or setuid-bit (chmod(1))
    Hmmmm,
    ok... "sudo" requires me to modify the user's system (or in other words
    write in /etc/sudoers), a thing that i don't want to do. My app has not
    to change the configuration of the machine.
    Same thing for setuid-bit/chmod.

    This leaves me with "su"... but there is a problem... "su" doesn't
    execute any command, it just gives you a "prompt" as root (or another
    user)... how can use this?

    Thank you,
    Luca
  • Mathias Waack at Mar 14, 2004 at 9:17 pm

    Luca T. wrote:
    This leaves me with "su"... but there is a problem... "su" doesn't
    execute any command, it just gives you a "prompt" as root (or
    another user)... how can use this?
    Please read su(1) until you find the answer. Or use the right group;)

    Mathias
  • Luca T. at Mar 14, 2004 at 10:09 pm

    Mathias Waack wrote:

    Please read su(1) until you find the answer. Or use the right group;)
    Damn, you are right, thanx... now i wonder why sudo exists though... oh
    well.

    Bye,
    Luca
  • Nai Namae at Mar 14, 2004 at 11:48 pm
    a magic combination of both would be the command:

    sudo su -

    :)

    make a shell "script" out of it:

    #!/bin/bash
    sudo su -

    call it "root", make it executable to everyone, put it in /usr/local/bin or
    any other path in $PATH, add all users on your system to /etc/sudoers...

    and just run your new "root" command and enjoy.. ok, of course you should
    not do so!
    by using "root" you can now have a root shell withouth having to type a
    password every time :/

    Luca T. wrote:
    Mathias Waack wrote:
    Please read su(1) until you find the answer. Or use the right group;)
    Damn, you are right, thanx... now i wonder why sudo exists though... oh
    well.

    Bye,
    Luca
  • Bobb at Mar 15, 2004 at 12:14 am
    I use pexpect to telnet and ssh...

    "Luca T." <lucat at despammed.com> wrote in message
    news:c32b2j$222k3a$1 at ID-99001.news.uni-berlin.de...
    Hello,
    i need some answers...

    1) I need to run some linux commands (from inside my app) that require
    superuser privileges (mkfs, losetup, etc), how do i do that? (I do not
    want to run my app with root privileges, but it will just ask the user
    for the root password before proceeding)
    2) When i execute the command i need to read its output (especially the
    error messages) to know if everything went fine but i do not know how :(
    3) How can i know if the user that is running my app is root or normal user?
    Thank you,
    Luca

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 14, '04 at 7:15p
activeMar 15, '04 at 12:14a
posts7
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase