LOGIN_CLASS(3)
π LOGIN_CLASS(3) β Library Functions Manual π
okay so bestie, this is LOGIN_CLASS(3) from the Library Functions Manual β the libutil login-class glow-up, and it is literally here to make your life easier. π
β¨
β¨ NAME β¨
The squad is setclasscontext, setclasscpumask, setclassenvironment, setclassresources, and setusercontext β functions for using the login class capabilities database. π«Ά
π«Ά LIBRARY π«Ά
System Utilities Library (libutil, -lutil). iconic. π
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <login_cap.h>
int
setclasscontext(const char *classname, unsigned int flags);
void
setclasscpumask(login_cap_t *lc);
void
setclassenvironment(login_cap_t *lc, const struct passwd *pwd,
int paths);
void
setclassresources(login_cap_t *lc);
int
setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid,
unsigned int flags);
π DESCRIPTION π
These functions provide a higher level interface to the login class database than those documented in login_cap(3). Theyβre used to set resource limits, environment and accounting settings for users on logging into the system, and when selecting an appropriate set of environment and resource settings for system daemons based on login classes. π
bestie, these functions may only be called if the current process is running with root privileges. π¨
if theLOGIN_SETLOGINflag is used, this function callssetlogin(2), and due care must be taken as detailed in the manpage for that function. this affects all processes running in the same session and not just the current process π β like, the whole group chat, not just you.
The setclasscontext() function sets various class context values (resource limits, umask and process priorities) based on values for a specific named class.
The setusercontext() function sets class context values based on a given login_cap_t object and a specific passwd record (if login_cap_t is NULL), the current sessionβs login, and the current process user and group ownership. Each of these actions is selectable via bit-flags passed in the flags parameter, which is comprised of one or more of the following:
LOGIN_SETLOGINβ set the login associated with the current session to the user specified in the passwd structure usingsetlogin(2). Thepwdparameter must not beNULLif this option is used.LOGIN_SETUSERβ set ownership of the current process to the uid specified in theuidparameter usingsetuid(2).LOGIN_SETGROUPβ set group ownership of the current process to the group id specified in the passwd structure usingsetgid(2), and callsinitgroups(3)to set up the group access list for the current process. Thepwdparameter must not beNULLif this option is used.LOGIN_SETRESOURCESβ set resource limits for the current process based on values specified in the system login class database. Class capability tags used, with and without-cur(soft limit) or-max(hard limit) suffixes and the corresponding resource setting:cputimeβRLIMIT_CPUfilesizeβRLIMIT_FSIZEdatasizeβRLIMIT_DATAstacksizeβRLIMIT_STACKcoredumpsizeβRLIMIT_COREmemoryuseβRLIMIT_RSSmemorylockedβRLIMIT_MEMLOCKmaxprocβRLIMIT_NPROCopenfilesβRLIMIT_NOFILEsbsizeβRLIMIT_SBSIZEvmemoryuseβRLIMIT_VMEMpseudoterminalsβRLIMIT_NPTSswapuseβRLIMIT_SWAPkqueuesβRLIMIT_KQUEUESumtxpβRLIMIT_UMTXPpipebufβRLIMIT_PIPEBUF
LOGIN_SETPRIORITYβ set the scheduling priority for the current process based on the value specified in the system login class database. Class capability tags used:priority
LOGIN_SETUMASKβ set the umask for the current process to a value in the user or system login class database. Class capability tags used:umask
LOGIN_SETPATHβ set thepathandmanpathenvironment variables based on values in the user or system login class database. Class capability tags used with the corresponding environment variables set:pathβPATHmanpathβMANPATH
LOGIN_SETENVβ set various environment variables based on values in the user or system login class database. Class capability tags used with the corresponding environment variables set:langβLANGcharsetβMM_CHARSETtimezoneβTZtermβTERM
Additional environment variables may be set using the list type capability setenv=var1 val1,var2 val2..,varN valN.
LOGIN_SETMACβ set the MAC label for the current process to the label specified in system login class database.LOGIN_SETCPUMASKβ create a newcpuset(2)and set the cpu affinity to the specified mask. The string may contain a comma separated list of numbers and/or number ranges as handled by thecpuset(1)utility or the case-insensitive stringdefault. If the string isdefaultno action will be taken.LOGIN_SETLOGINCLASSβ set the login class of the current process usingsetloginclass(2).LOGIN_SETALLβ enables all of the above settings.
Note that when setting environment variables and a valid passwd pointer is provided in the pwd parameter, the characters ~ and $ are substituted for the userβs home directory and login name respectively. π π
The setclasscpumask(), setclassresources() and setclassenvironment() functions are subsets of the setcontext functions above, but may be useful in isolation. π¦
π RETURN VALUES π
The setclasscontext() and setusercontext() functions return -1 if an error occurred, or 0 on success. If an error occurs when attempting to set the user, login, group or resources, a message is reported to syslog(3), with LOG_ERR priority and directed to the currently active facility. ππ
π SEE ALSO π
cpuset(1), ps(1), cpuset(2), setgid(2), setlogin(2), setloginclass(2), setuid(2), getcap(3), initgroups(3), login_cap(3), mac_set_proc(3), login.conf(5), termcap(5)
π HISTORY π
The functions setclasscontext(), setclasscpumask(), setclassenvironment(), setclassresources() and setusercontext() first appeared in FreeBSD 2.1.5. β¨
mwah π the footer says Debian, May 10, 2020, and LOGIN_CLASS(3) β bye bestie! π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1995 David Nugent <davidn@blaze.net.au>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms