Thread View: uw.unix
1 messages
1 total messages
Started by lindsay
Fri, 18 Aug 1989 22:52
setting permissions
Author: lindsay
Date: Fri, 18 Aug 1989 22:52
Date: Fri, 18 Aug 1989 22:52
27 lines
1161 bytes
1161 bytes
From: Lindsay Patten <lindsay@watnext>
The following program illustrates how to do what I think you
want to do. Chown it to root and chmod it.
main()
{
printf("ruid = %d, euid = %d\n", getuid(), geteuid());
if(chroot("/tmp"))
perror("chroot");
if(seteuid(getuid()))
perror("seteuid");
if(fopen("/tmp/test","w") == 0)
perror("fopen");
printf("ruid = %d, euid = %d\n", getuid(), geteuid());
}
By using chmod u+s the euid gets set to the owner of the file,
the ruid remains that of the real user. After the seteuid(getuid())
call the process will have
euid == ruid == (uid of process that called the program)
and will be unable to ever regain it's setuid status. Thus there
is no security risk provided the program itself is not tampered with.
The file will appear in /tmp/tmp/test.
Cheers,
Lindsay
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads