Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-13-2003, 01:08 PM   #1
LQ Newbie
Registered: Oct 2003
Posts: 3

Rep: Reputation: 0
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?

Old 11-13-2003, 04:57 PM   #2
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
im not sure what the problem is, i ran the following program
#include <unistd.h>
#include <stdio.h>

int main()
        fprintf(stderr, "%d, %d\n", getuid(), geteuid());
        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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sticky Bit Doesn't Seem to work krishvij Linux - Newbie 5 05-10-2005 06:31 PM
file modes list i.e. what is a sticky bit? Glover Linux - Newbie 2 07-04-2002 07:41 AM
Sticky Bit tarballed Linux - General 4 07-03-2002 04:54 PM
Sticky bit question...need help rootlinux Linux - General 1 01-26-2002 06:12 PM
sticky bit motiram Linux - General 1 08-01-2001 01:34 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:46 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration