I have this C file: I compile it, set the UID and GID both to root and set the setuid bit, so that it looks like this: However when I call $ ./a.out I still get: What am I doing wrong? Answer The real user ID is still the user that called the program, but the effective user ID is
Tag: setuid
In a setuid root program, how to check that the current user (that root is doing the work for) owns a file?
The use case is a mount tool, I want to restrict mounting (a unionfs(r+x dir, squashfs) ) to files owned by the caller. I know about fusefs, But I’d like to use overlayfs and squashfs in the kernel. Answer So long as you haven’t called setuid() or setreuid() yet, you can use getuid() to get the user ID of the
setuid(0) fails to execute for root owned program
I need to write some code which can gain root priveleges and execute system level operations. Here’s what I’ve written (this is not the actual code, just to test if I’m doing things correctly or not): After doing gcc -o setuid setuid.c, I run ls -al on this to get following results: Trying to run the application results in: I