Execute prog as other user

This is a discussion on Execute prog as other user within the C Programming forums, part of the General Programming Boards category; Hello All, I'm writing a program that will execute external programs under a linux machine. This program will run as ...

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    41

    Execute prog as other user

    Hello All,

    I'm writing a program that will execute external programs under a linux machine. This program will run as root and each external program must be run by the user that is calling it...

    for example:

    in the exec.conf file I have:
    #user|binary
    apache|/bin/apache_clean

    The prog will read the file and should execute the binary as the user, in this case /bin/apache_clean by the user apache.

    I'm using execv to execute the external program but I didnt find out how to execute it as another user. I've tryed execve with no sucess.

    Any ideias ?

    Thanks,

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    Lookup setuid()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    41
    Salem, Thank you one more time for your help ! Its very simple:

    Code:
    setuid(userid);
    Thanks,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help making a dot bounce up and down y axis in this prog
    By redwing26 in forum Game Programming
    Replies: 10
    Last Post: 08-05-2006, 12:48 PM
  2. pass error before char
    By bazzano in forum C Programming
    Replies: 3
    Last Post: 03-26-2006, 11:00 AM
  3. Error checking user input
    By theharbinger in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2003, 09:57 AM
  4. execute until user presses a key?
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 07-31-2002, 11:31 PM
  5. Stopping a user from typeing.
    By knave in forum C++ Programming
    Replies: 4
    Last Post: 09-10-2001, 12:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21