View Full Version : changing user's uid

09-03-2004, 03:04 PM
Hi everyone !

I need to make a program that changes the user's id. I know you can do it using the seteuid() sys calls but the problem is that it doesnt uses any passwd auth.. (i need something like "su") so that you suply the user id and user passwd... Does it exists any syscall for this or do i need to do it in a nasty way using su in completion with exec() or system() ?

09-03-2004, 04:19 PM
You try looking at the source for su? Do a web search for coreutils to find a gnu version..


09-04-2004, 01:44 AM
Yeah in the mean time i searched for su.c and found the soulution..Thanx!

09-04-2004, 04:24 AM
No i haven't find it ;(

su is a suid program so changing uid's is kinda easy with seuid()..The problem is that my program should be running with users privileges

09-22-2004, 09:50 AM
I don't think that is possible. I am pretty sure in order to change your uid, you have to have root privs, that is why su is suid.
you can change to any user though with su, not just root. simply supply the other user name, and it will change to that one.