AuthSample

  • Hi,
    I use a loader in my program to achieve root powers, however for some reason
    in leopard it has become broken. The code is based off authsample and works
    if i use a fork to execute the commands
    (chown/chmod/kextload/kextunload/pmset) however if i place a simple system()
    call it fails to achieve the root powers. Now to my understanding a fork
    should have the exact same powers as the parent.

    So does anyone know why the fork is needed?

    PS. Does anyone else use a "loader" and is able to send some sample code
    which also gets a result from the command it exectuted?

    PSS. My code was modified from someone elses who was based on authtool which
    works but means i might be missing some original code and explanations
  • On Oct 28, 2007, at 5:38 AM, Andrew James wrote:

    > I use a loader in my program to achieve root powers, however for
    > some reason
    > in leopard it has become broken. The code is based off authsample
    > and works
    > if i use a fork to execute the commands
    > (chown/chmod/kextload/kextunload/pmset) however if i place a simple
    > system()
    > call it fails to achieve the root powers. Now to my understanding a
    > fork
    > should have the exact same powers as the parent.
    >
    > So does anyone know why the fork is needed?

    I bet it failed for security reasons. system() invokes a command using
    a shell, and running a shell as root (or with root privileges) is
    generally a bad idea. Try using fork/exec instead of system().

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • Hi,
    So it seems the newer version of Leopard is whats dropping the privs,
    however what is the best way to retrieve the return value of the commands if
    i use fork/exec

    On 10/29/07, Nick Zitzmann <nick...> wrote:
    >
    >
    > On Oct 28, 2007, at 5:38 AM, Andrew James wrote:
    >
    >> I use a loader in my program to achieve root powers, however for
    >> some reason
    >> in leopard it has become broken. The code is based off authsample
    >> and works
    >> if i use a fork to execute the commands
    >> (chown/chmod/kextload/kextunload/pmset) however if i place a simple
    >> system()
    >> call it fails to achieve the root powers. Now to my understanding a
    >> fork
    >> should have the exact same powers as the parent.
    >>
    >> So does anyone know why the fork is needed?
    >
    >
    > I bet it failed for security reasons. system() invokes a command using
    > a shell, and running a shell as root (or with root privileges) is
    > generally a bad idea. Try using fork/exec instead of system().
    >
    > Nick Zitzmann
    > <http://www.chronosnet.com/>
    >
    >
    >
    >
    >
  • On 10/29/07, Andrew James <semaja2...> wrote:
    > Hi,
    > So it seems the newer version of Leopard is whats dropping the privs,
    > however what is the best way to retrieve the return value of the commands if
    > i use fork/exec

    Use the wait or waitpid system call, which will block until a
    particular process terminates.

    Dave.
  • On 29/10/2007, Andrew James <semaja2...> wrote:
    > Hi,
    > So it seems the newer version of Leopard is whats dropping the privs,
    > however what is the best way to retrieve the return value of the commands if
    > i use fork/exec

    You may want to read up on fork()/exec()/waitpid()/pipe() topics:

    http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html
    http://www.cs.uleth.ca/~holzmann/C/system/pipeforkexec.html
    http://www.iu.hio.no/~mark/unix/unix.html#SEC177

    etc

    -- Finlay
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today