GETLOGINCLASS(2)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’– NAME πŸ’–

getloginclass, setloginclass β€” get/set login class

okay bestie, welcome to getloginclass(2) from the System Calls Manual β€” it's the login-class get/set duo, and it's lowkey iconic πŸŽ€

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” that's the home base, slay ✨

✨ SYNOPSIS ✨

#include <unistd.h>

int
getloginclass(char *name, size_t len);

int
setloginclass(const char *name);

πŸ¦‹ DESCRIPTION πŸ¦‹

So getloginclass() gives you back the login class name attached to the calling process β€” the one that was previously set by setloginclass() πŸ’…. You, the caller, have to hand over a buffer called name with len bytes of room to hold the result, and that buffer should be at least MAXLOGNAME bytes long. No tiny-buffer nonsense, bestie.

setloginclass() is the system call that sets the login class of the calling process to name. This one is restricted to the super-user, and it's normally used only when a new session is being created on behalf of the named user β€” for example, at login time, or when a remote shell is invoked. Processes inherit login class from their parents, iykyk 🫢

πŸ”₯ RETURN VALUES πŸ”₯

When it goes right, you get 0. When it doesn't, you get -1, and the global variable errno is set to indicate the error. Simple as that, no cap. 🫢

πŸ’€ ERRORS πŸ’€

The following errors may be returned by these calls β€” read 'em and weep (affectionately):

  • [EFAULT] β€” the name argument gave an invalid address.
  • [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 null.
  • [EPERM] β€” the caller tried to set the login class and was not the super-user.
  • [ENAMETOOLONG] β€” the size of the buffer is smaller than the result to be returned.

πŸ‘€ SEE ALSO πŸ‘€

🌈 HISTORY 🌈

getloginclass() and setloginclass() first appeared in FreeBSD 9.0.


and that's the whole page, bestie πŸ’– huge shoutout to Debian for this one, dated July 12, 2016 β€” stay classy, literally πŸŽ€

πŸ“¦ where this page comes from