I have the following c program.
$ cat main.c#include <stdio.h>#include <fcntl.h>#include <unistd.h>int main(int argc, char *argv[]) { int fd; if((fd = open(argv[1], O_RDONLY)) == -1) { perror("open"); return 1; } if(close(fd) == -1) { perror("close"); return 1; } return 0;}But I got the following error.
touch tmpfilesudo chown root tmpfilesudo chown root ./main_progsudo setcap cap_setuid+ep ./main_prog # There will be no error if I use sudo chmod u+s./main_prog tmpfileopen: Permission deniedCould anybody show me how to use setcap for setuid?