Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22299

linux, setuid when user id does not exists

$
0
0
  1. In gcc, as root user, I call setuid system call with invalid user id (3009). errno variable is 0 (successful).

  2. When the program is running, in another session I execute ps command and I see the value of uid and euid is 3009 (invalid user id).

#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <errno.h>int main () {   int     i;   i=setuid(3009);    // user id 3009 does not exists   printf ("i=%d, err=%d(%s)\n", i, errno, strerror(errno));   exit(0);}

Is it ok or has some reasons? Platform is gcc 11.4 and Ubuntu 22.04.4.


Viewing all articles
Browse latest Browse all 22299

Latest Images

Trending Articles



Latest Images

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