LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-28-2007, 10:25 AM   #1
pampo
LQ Newbie
 
Registered: May 2007
Posts: 4

Rep: Reputation: 0
Question execl() fails with EACCES after setuid() call


Hello there,

my name is Matteo and I'm writing from Italy.

Maybe this is a very trivial issue but I'm going crazy on it.

I have a simple application, say test, owned by myuid.mygid, of course different from root, where myuid=31 mygid=31.

Inside it I just do:

...

res = setgid(31);
if (res != 0)
printf("setgid() failed\n");

res = setuid(31);
if (res != 0)
printf("setuid() failed\n");

res = execl("/usr/sbin/myapp", (char*) NULL);
printf("execl() returned %d\n", res);
if (res != 0)
printf("execl() error: %s (%d)\n", strerror(errno), errno);

...


Please note that myapp is owned by 0.mygid and is readable/executable by mygid and the same for /usr and /usr/sbin.

But execl() fails with EACCES.

It seems that setuid() is the real cause, because if I comment only it the result is OK.

Can anyone please tell me what's wrong?

Many many thanks,

Matteo.
 
Old 05-28-2007, 01:53 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
This is strange. It should work.

I know you've already covered this, but as a sanity check, could you please copy and paste into a response on this site what you get as output to the following commands?

Code:
ls -lnad /usr/sbin
ls -ln   /usr/sbin/myapp
 
Old 05-29-2007, 02:56 AM   #3
pampo
LQ Newbie
 
Registered: May 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Hi,

first please excuse me for the duplicate post, of course it was not my intention but I couldn't remove the second one.

Then, doing a ls -lnad /usr/sbin I get

drwxr-x--- 2 0 31 4096 May 17 2007 /usr/sbin

and that should be OK, while ls -ln /usr/sbin/myapp gives

-rwxr-x--- 1 0 31 231477 May 17 2007 /usr/sbin/myapp

and that should be OK, too.

I can't really understand.

Thanks in advance,

Matteo.
 
Old 05-30-2007, 07:36 PM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
I'm thinking of various ways to explore this. But while I'm thinking, there's another piece of the puzzle that I need, please.

What user are you logged in as when you run test? User 31? User 0 (root)? Someone else? And what is the primary group number for that user?

By the way, "test" would be a bad name for this, because that word is used elsewhere in the shell and as a standard runnable program.

(Sorry for the slow response. I'm kinda overwhelmed with things to do at this end.)
 
  


Reply



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
execl() fails with EACCES after setuid() call pampo Linux - Security 2 05-28-2007 05:39 PM
Help using popen and execl cdog Linux - Software 3 02-28-2007 06:44 PM
Sockets : Getaddrinfo call fails abrb220 Programming 2 06-06-2004 11:26 PM
Ioctl() call fails Custer Linux - Wireless Networking 0 02-16-2004 12:47 PM
Samba 2.2.7a fails to call add user script on Red Hat 9 DrFooMod2 Linux - Networking 4 07-17-2003 09:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:33 PM.

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