Re: setuid funciton

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Cihan Kömeçoğlu wrote:

> Hello everybody
> 
> I have written simple code about usage of setuid. this program file
> set-user-id bit is on and this process after exec when I execute this
> program, effective user id and saved-user-id bit will be
> program-file's user id. this correct?
> 
> But the last output when I set uid to 80(www) ,effective user id
> wasn't 80. Why not? saved set user id is still 80? What is the
> problem?
> 
> 
> I compiled below code with gcc and I set-user-id bit and change own
> file with this command

[snip]

It works for me; I get:

Real UID	= 1001
Effective UID	= 80
Real UID	= 1001
Effective UID	= 1001
Real UID	= 1001
Effective UID	= 80

This is with a 2.6.17.13 kernel, compiled from stock sources (no
vendor patches).

If you are using a kernel with additional security features (e.g. 
SELinux, AppArmor etc), it may impose additional restrictions on
setuid(). You could try using setreuid() to swap the real and
effective UIDs, rather than relying upon the saved UID.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux