In gcc, as root user, I call
setuid
system call with invalid user id (3009).errno
variable is0
(successful).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.