Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-23-2008, 09:52 AM   #16
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 31

I'm thinking about just rewriting the second script as a C program. Then then SUID bit should actually function.

Is there anyway to call a linux shell command (like cp for copying) from a C program? That would make life easier.

hmm "system()" function. I'll look it up.


Rewrite the script... I'm just going to make a tiny wrapper program to call the script for me... actually I just finished making it. Now to test...

Last edited by davidstvz; 08-23-2008 at 11:15 AM.
Old 08-23-2008, 11:38 AM   #17
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 31
I just wrote a test program ( while(true); ) and set the suid bit and the owner, but when the unprivileged user runs the program, it does not pay any attention to the suid bit as far as I can tell.

I don't know what I could have done wrong. Here are the permissions:

-rwsr-xr-x 1 privuser group 10385 2008-08-23 11:27 a.out

Here is the call from the regular user:


Here is what ps -aux reports:

privuser 32637 113 0.0 6900 840 pts/4 R+ 11:37 0:03 /home/privuser/bin/a.out


I think I got it! The default fstab option for suid vs. nosuid in suse is apparently nosuid. So I explicitly set it to suid and it appears to have finally started working right.

Now to test the actual functionality.


And it does NOTHING (*#$)(*#@


PS shows the user ID for the privileged user, but when the program tries to even access the shellscript (which I now have set to rwx------ so that only the privuser can run it) the rws program won't even access it.

Makes no sense...

Is there a special way to invoke suid?

Last edited by davidstvz; 08-23-2008 at 11:55 AM.
Old 08-23-2008, 12:27 PM   #18
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 31
Is it possible that when I make the system() call from the suid program, it loses suid privileges and reverts back to the user's privileges?
Old 08-23-2008, 01:33 PM   #19
Registered: Jun 2008
Posts: 405

Original Poster
Rep: Reputation: 31

That's exactly what's happening. I've verified that the suid wrapper I wrote is running properly (it can write files and everything, though so far it won't create directories though I am just using ofstream myfile;

It will only make a new file in a directory that already exists and has --x privileges set for group. weird.


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
permissions question fluidicslave Linux - Security 4 07-23-2006 08:52 PM
permissions question sunman Slackware 7 11-18-2005 10:00 PM
Permissions question: what does the Thaidog Linux - General 7 03-29-2005 10:16 PM
Permissions question gauge73 Linux - Newbie 4 05-02-2003 04:33 PM
permissions question cinnix Linux - General 2 07-09-2001 07:59 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:50 AM.

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
Open Source Consulting | Domain Registration