Have you thought what if your application which is running in you want to make system call which need to run as root user then how to make it work ???
May that why you are here !!!!
May that why you are here !!!!
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
setuid(0);
system("kill 1090");
return 0;
}
$ gcc program.c -o program
$ sudo chown root.root program
$ sudo chmod 4755 program
$ ./program
The setuid
, setgid
, and sticky
Permissions
Other than the permissions already discussed, there are three other specific settings that all administrators should know about. They are the setuid
, setgid
, andsticky
permissions.
These settings are important for some UNIX® operations as they provide functionality not normally granted to normal users. To understand them, the difference between the real user ID and effective user ID must be noted.
The real user ID is the UID who owns or starts the process. The effective UID is the user ID the process runs as. As an example, passwd(1) runs with the real user ID when a user changes their password. However, in order to update the password database, the command runs as the effective ID of the root
user. This allows users to change their passwords without seeing a Permission Denied error.
The setuid permission may be set by prefixing a permission set with the number four (4) as shown in the following example:
#
chmod 4755 suidexample.sh
ref:https://www.freebsd.org/doc/handbook/permissions.html
No comments:
Post a Comment