getloginclass(2)

getloginclass2

Get/set login class

Usage

#include <unistd.h>

int

getloginclass(char *name, size_t len);

int

setloginclass(const char *name);

Library

Standard C Library (libc, -lc)

Overview

The getloginclass() routine returns the login class name associated with the calling process, as previously set by setloginclass(). The caller must provide the buffer name with length len bytes to hold the result. The buffer should be at least MAXLOGNAME bytes in length.

The setloginclass() system call sets the login class of the calling process to name. This system call is restricted to the super-user, and is 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.

Return values

The getloginclass() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

Errors

The following errors may be returned by these calls:

[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.

Releases

34 releases since FreeBSD 9.0-RELEASE; the text changed 20 times.

  1. 9.0
  2. 9.1
  3. 9.2
  4. 9.3
  5. 10.0
  6. 10.1
  7. 10.2
  8. 10.3
  9. 10.4
  10. 11.0
  11. 11.1
  12. 11.2
  13. 11.3
  14. 11.4
  15. 12.0
  16. 12.1
  17. 12.2
  18. 12.3
  19. 12.4
  20. 13.0–13.2
  21. 13.3–16.0

History

The getloginclass() and setloginclass() system calls first appeared in FreeBSD 9.0.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.