LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   execl() fails with EACCES after setuid() call (https://www.linuxquestions.org/questions/linux-security-4/execl-fails-with-eacces-after-setuid-call-557223/)

pampo 05-28-2007 10:22 AM

execl() fails with EACCES after setuid() call
 
Hello there,

myname 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.

wjevans_7d1@yahoo.co 05-28-2007 01:54 PM

This seems to be a duplicate question. I've posted a response on the other copy of this question.

win32sux 05-28-2007 05:39 PM

I'm closing this thread, as it's a duplicate.


All times are GMT -5. The time now is 01:13 AM.