Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6502

How to use setcap to enable setuid capability

$
0
0

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 denied

Could anybody show me how to use setcap for setuid?


Viewing all articles
Browse latest Browse all 6502

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>