GETLOGINCLASS(2)

πŸ’– GETLOGINCLASS(2) β€” the system calls manual, bestie edition πŸ’–

okay so this is the page for getloginclass and setloginclass, aka the little duo that handles your login class. it's a section 2 manpage, iykyk, syscalls only, no cap. πŸ¦‹


✨ NAME ✨

getloginclass, setloginclass β€” get/set login class πŸ’…

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” she's literally in libc, she's everywhere, main character energy fr fr. ✨

🌸 SYNOPSIS 🌸

#include <unistd.h>

int
getloginclass(char *name, size_t len);

int
setloginclass(const char *name);

πŸ’œ DESCRIPTION πŸ’œ

so getloginclass() is the one that tells you your login class name β€” the one that's attached to the process that's calling her, as previously set by setloginclass(). you, the caller, have to hand her a buffer called name with len bytes of room so she can drop the result in there. πŸŽ€

pro tip bestie: make that buffer at least MAXLOGNAME bytes long or you're gonna have a bad time. 😭

and setloginclass() is the system call that sets the login class of the calling process to name. she's ✨ exclusive ✨ β€” this one is restricted to the super-user only, periodt. she's normally used only when a brand new session is being created on behalf of the named user (like, at login time, or when a remote shell gets invoked). and the lore? processes inherit their login class from their parents. generational, honestly. πŸ‘‘

🫢 RETURN VALUES 🫢

when everything slays: the value 0 is returned. πŸŽ‰

when it does NOT slay: the value -1 is returned, and the global variable errno gets set to tell you what went wrong. not me getting humbled by errno again πŸ’€

🚨 ERRORS 🚨

here's the lil roster of errors these calls might throw at you, no filter:

  • [EFAULT] β€” the name argument gave an invalid address. like, girl, that pointer is not pointing anywhere real. πŸ™ˆ
  • [EINVAL] β€” the name argument pointed to a string that was too long. login class names are limited to MAXLOGNAME (from <sys/param.h>) characters, currently 33 including the null. yes, thirty-three. count them. she's on a budget. πŸ’…
  • [EPERM] β€” the caller tried to set the login class and was not the super-user. bestie you are not on the list, i'm so sorry. 😭
  • [ENAMETOOLONG] β€” the size of the buffer is smaller than the result to be returned. the buffer said "i'm full" and honestly? valid. πŸ“

πŸ‘€ SEE ALSO πŸ‘€

ps(1), setusercontext(3), login.conf(5), rctl(8) β€” go read these next, they're the friend group. 🌈

⭐ HISTORY ⭐

the getloginclass() and setloginclass() system calls first appeared in FreeBSD 9.0. vintage but make it iconic. πŸ‘‘


and that's the whole page, bestie!! πŸ¦‹βœ¨ this one came from the Debian crew and she's dated July 12, 2016 β€” a classic, an heirloom, a little time capsule. πŸ’– thanks for reading, go set your login class responsibly (or don't, you need super-user anyway πŸ’…). πŸŽ€

πŸ“¦ where this page comes from