1 .\" Copyright (c) 1995 David Nugent <davidn@blaze.net.au>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, is permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice immediately at the beginning of the file, without modification,
9 .\" this list of conditions, and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
13 .\" 3. This work was done expressly for inclusion into FreeBSD. Other use
14 .\" is permitted provided this notation is included.
15 .\" 4. Absolutely no warranty of function or purpose is made by the author
17 .\" 5. Modifications may be freely made to this file providing the above
18 .\" conditions are met.
20 .\" $FreeBSD: src/lib/libutil/login_class.3,v 1.9.2.4 2003/04/29 14:40:07 trhodes Exp $
27 .Nm setclassenvironment ,
28 .Nm setclassresources ,
30 .Nd "functions for using the login class capabilities database"
37 .Fn setclasscontext "const char *classname" "unsigned int flags"
39 .Fn setusercontext "login_cap_t *lc" "const struct passwd *pwd" "uid_t uid" "unsigned int flags"
41 .Fn setclassresources "login_cap_t *lc"
43 .Fn setclassenvironment "login_cap_t *lc" "const struct passwd *pwd" "int paths"
45 These functions provide a higher level interface to the login class
46 database than those documented in
48 These functions are used to set resource limits, environment and
49 accounting settings for users on logging into the system and when
50 selecting an appropriate set of environment and resource settings
51 for system daemons based on login classes.
52 These functions may only be called if the current process is
53 running with root privileges.
54 If the LOGIN_SETLOGIN flag is used this function calls
56 and due care must be taken as detailed in the manpage for that
57 function and this affects all processes running in the same session
58 and not just the current process.
61 sets various class context values (resource limits, umask and
62 process priorities) based on values for a specific named class.
66 sets class context values based on a given login_cap_t
67 object, a specific passwd record (if login_cap_t is NULL),
68 sets the current session's login and the current process
69 user and group ownership.
70 Each of these functions is selectable via bit-flags passed
73 parameter, which is comprised of one or more of the following:
74 .Bl -tag -width LOGIN_SETRESOURCES
76 Set the login associated with the current session to the user
77 specified in the passwd structure.
81 parameter must not be NULL if this option is used.
83 Set ownership of the current process to the uid specified in the
88 Set group ownership of the current process to the group id
89 specified in the passwd structure using
93 to set up the group access list for the current process.
96 parameter must not be NULL if this option is used.
97 .It LOGIN_SETRESOURCES
98 Set resource limits for the current process based on values
99 specified in the system login class database.
100 Class capability tags used, with and without -cur (soft limit)
101 or -max (hard limit) suffixes and the corresponding resource
105 filesize RLIMIT_FSIZE
107 stacksize RLIMIT_STACK
108 coredumpsize RLIMIT_CORE
110 memorylocked RLIMIT_MEMLOCK
112 openfiles RLIMIT_NOFILE
114 vmemoryuse RLIMIT_VMEM
116 .It LOGIN_SETPRIORITY
117 Set the scheduling priority for the current process based on the
118 value specified in the system login class database.
119 Class capability tags used:
124 Set the umask for the current process to a value in the user or
125 system login class database.
126 Class capability tags used:
131 Set the "path" and "manpath" environment variables based on values
132 in the user or system login class database.
133 Class capability tags used with the corresponding environment
140 Set various environment variables based on values in the user or
141 system login class database.
142 Class capability tags used with the corresponding environment
151 Additional environment variables may be set using the list type
152 capability "setenv=var1 val1,var2 val2..,varN valN".
154 Enables all of the above settings.
157 Note that when setting environment variables and a valid passwd
158 pointer is provided in the
160 parameter, the characters
164 are substituted for the user's home directory and login name
168 .Fn setclassresources
170 .Fn setclassenvironment
171 functions are subsets of the setcontext functions above, but may
172 be useful in isolation.
178 functions return -1 if an error occurred, or 0 on success.
179 If an error occurs when attempting to set the user, login, group
180 or resources, a message is reported to
182 with LOG_ERR priority and directed to the currently active facility.
187 .Fn setclassenvironment
188 failed because it were unable to allocate memory for the environment.