when executing this:
err = setuid(0);
if (err < 0) {
fprintf(stderr, "return value: %d \n", err);
fprintf(stderr, "error code: %d \n", errno);
}
I am getting this output:
return value: -1
error code: 1
Error code 1 implies an EPERM error. Any ideas as to how should I fix it?
You cannot setuid()
to root from a non-root user.
If you want to run your application as root, use Authorization Services , or sudo
if it's a command-line tool.
If the user is not the super user, or the uid specified is not the real, effective ID, or saved ID,these functions return -1.
setuid(0);
will work only from root(SU) user.
error code: 1
#define EPERM 1 /* Operation not permitted */
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.