GETUID(2)

πŸ’– GETUID(2) β€” get user identification πŸ’–

okay bestie, so we're in the System Calls Manual section of your Unix man pages, and today's episode is all about finding out who you are. not like, spiritually. like, as a process. πŸͺͺ✨


🌸 NAME 🌸

getuid, geteuid β€” get user identification


πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc)


✨ SYNOPSIS ✨

#include <unistd.h>

uid_t
getuid(void);

uid_t
geteuid(void);

🫢 DESCRIPTION 🫢

so. getuid() is the system call that hands you back the real user ID of the process that's calling it. and geteuid() does the same thing but for the effective user ID of the calling process. two little IDs, two little functions, one very cute family. πŸ’…

now the lore: the real user ID is the ID of the user who actually invoked the program. that's the human. the person. the main character. πŸ‘‘

meanwhile the effective user ID is the one that gives the process extra permissions while it's running β€” specifically during β€œset-user-ID” mode processes. so because effective UID can be all elevated and fancy, you use getuid() when you actually want to determine the real-user-id of the calling process. it's giving "don't get it twisted, I want the real one." 😌


😭 ERRORS 😭

okay so here's the good news: getuid() and geteuid() are always successful. like, always. no cap. and there's no return value reserved to indicate an error β€” so don't go looking for one, bestie, it's not there. 🚫

fr fr, these two cannot fail. they simply ate and left no crumbs. πŸ”₯

πŸ‘€ SEE ALSO πŸ‘€


πŸ“ STANDARDS πŸ“

the geteuid() and getuid() system calls are expected to conform to ISO/IEC 9945-1:1990 (β€œPOSIX.1”). so yeah, they're certified. iconic behavior. πŸŽ€


πŸ¦‹ HISTORY πŸ¦‹

  • getuid() first appeared in Version 1 AT&T UNIX. a true OG. πŸ‘‘
  • geteuid() showed up later, in Version 4 AT&T UNIX. little sibling energy. πŸ’œ

🌈 bye bestie 🌈

that's the whole page, and it came to you from Debian, dated December 1, 2017. go check your IDs, stay hydrated, and remember: the real user ID is who you are, the effective user ID is who you get to be. πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from