LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Losing sticky bit privilege when using fork() (https://www.linuxquestions.org/questions/programming-9/losing-sticky-bit-privilege-when-using-fork-115634/)

jones507 11-13-2003 12:08 PM

Losing sticky bit privilege when using fork()
 
In our code we do some calls that require superuser privilege. So we do not have to run as 'root', we change the owner of the exe to root and set the sticky bit.

Now we have a process that forks itself one time. The original exe runs as root because of the sticky bit. But when the fork occurs, the new process is running under my ID and does not have root privilege. So part of the code fails because it does not have superuser privilege.
Is there an option in fork() or anything else I can do to get past this?

Thanks

kev82 11-13-2003 03:57 PM

im not sure what the problem is, i ran the following program
Code:

#include <unistd.h>
#include <stdio.h>

int main()
{
        fprintf(stderr, "%d, %d\n", getuid(), geteuid());
        fork();
        fprintf(stderr, "%d, %d\n", getuid(), geteuid());
        return 0;
}

with permissions

-rwsr-xr-x 1 root root 10841 Nov 13 21:26 a.out

as as normal user with the following output

1004, 0
1004, 0
1004, 0

as you can see the effective id is 0 before and after the fork in both child and parent process.


All times are GMT -5. The time now is 09:18 PM.