LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 11-13-2003, 01:08 PM   #1
jones507
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?

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

Rep: Reputation: 50
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.
 
  


Reply


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


All times are GMT -5. The time now is 02:58 AM.

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