1997-01-04 16:50:08 +00:00
|
|
|
.\" Copyright (c) 1995 David Nugent <davidn@blaze.net.au>
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, is permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice immediately at the beginning of the file, without modification,
|
|
|
|
.\" this list of conditions, and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. This work was done expressly for inclusion into FreeBSD. Other use
|
|
|
|
.\" is permitted provided this notation is included.
|
|
|
|
.\" 4. Absolutely no warranty of function or purpose is made by the author
|
|
|
|
.\" David Nugent.
|
|
|
|
.\" 5. Modifications may be freely made to this file providing the above
|
|
|
|
.\" conditions are met.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1997-01-04 16:50:08 +00:00
|
|
|
.\"
|
2011-03-24 16:06:57 +00:00
|
|
|
.Dd March 24, 2011
|
1997-01-04 16:50:08 +00:00
|
|
|
.Dt LOGIN_CLASS 3
|
2010-04-14 19:08:06 +00:00
|
|
|
.Os
|
1997-01-04 16:50:08 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm setclasscontext ,
|
2008-10-20 17:03:05 +00:00
|
|
|
.Nm setclasscpumask ,
|
2000-04-22 16:17:00 +00:00
|
|
|
.Nm setclassenvironment ,
|
1997-01-04 16:50:08 +00:00
|
|
|
.Nm setclassresources ,
|
2000-04-22 16:17:00 +00:00
|
|
|
.Nm setusercontext
|
2001-04-18 15:54:10 +00:00
|
|
|
.Nd "functions for using the login class capabilities database"
|
2000-04-22 16:17:00 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libutil
|
1997-01-04 16:50:08 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/types.h
|
|
|
|
.In login_cap.h
|
1997-01-04 16:50:08 +00:00
|
|
|
.Ft int
|
1997-04-13 14:12:48 +00:00
|
|
|
.Fn setclasscontext "const char *classname" "unsigned int flags"
|
1997-01-04 16:50:08 +00:00
|
|
|
.Ft void
|
2008-10-20 17:03:05 +00:00
|
|
|
.Fn setclasscpumask "login_cap_t *lc"
|
1997-01-04 16:50:08 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn setclassenvironment "login_cap_t *lc" "const struct passwd *pwd" "int paths"
|
2008-10-20 17:03:05 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn setclassresources "login_cap_t *lc"
|
|
|
|
.Ft int
|
|
|
|
.Fn setusercontext "login_cap_t *lc" "const struct passwd *pwd" "uid_t uid" "unsigned int flags"
|
1997-01-04 16:50:08 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
These functions provide a higher level interface to the login class
|
|
|
|
database than those documented in
|
|
|
|
.Xr login_cap 3 .
|
|
|
|
These functions are 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.
|
|
|
|
These functions may only be called if the current process is
|
1998-06-06 05:50:53 +00:00
|
|
|
running with root privileges.
|
1997-01-04 16:50:08 +00:00
|
|
|
If the LOGIN_SETLOGIN flag is used this function calls
|
|
|
|
.Xr setlogin 2 ,
|
|
|
|
and due care must be taken as detailed in the manpage for that
|
|
|
|
function and this affects all processes running in the same session
|
|
|
|
and not just the current process.
|
|
|
|
.Pp
|
2003-03-24 16:02:05 +00:00
|
|
|
The
|
1997-01-04 16:50:08 +00:00
|
|
|
.Fn setclasscontext
|
2003-03-24 16:02:05 +00:00
|
|
|
function sets various class context values (resource limits, umask and
|
1997-01-04 16:50:08 +00:00
|
|
|
process priorities) based on values for a specific named class.
|
|
|
|
.Pp
|
2003-03-24 16:02:05 +00:00
|
|
|
The
|
1997-01-04 16:50:08 +00:00
|
|
|
.Fn setusercontext
|
2003-03-24 16:02:05 +00:00
|
|
|
function sets class context values based on a given login_cap_t
|
2004-05-11 11:10:09 +00:00
|
|
|
object and a specific passwd record (if login_cap_t is NULL),
|
|
|
|
the current session's login, and the current process
|
1997-01-04 16:50:08 +00:00
|
|
|
user and group ownership.
|
2004-05-11 11:10:09 +00:00
|
|
|
Each of these actions is selectable via bit-flags passed
|
1997-01-04 16:50:08 +00:00
|
|
|
in the
|
|
|
|
.Ar flags
|
|
|
|
parameter, which is comprised of one or more of the following:
|
2011-03-06 08:56:44 +00:00
|
|
|
.Bl -tag -width LOGIN_SETLOGINCLASS
|
1997-01-04 16:50:08 +00:00
|
|
|
.It LOGIN_SETLOGIN
|
|
|
|
Set the login associated with the current session to the user
|
2003-03-24 16:02:05 +00:00
|
|
|
specified in the passwd structure using
|
1997-01-04 16:50:08 +00:00
|
|
|
.Xr setlogin 2 .
|
|
|
|
The
|
|
|
|
.Ar pwd
|
|
|
|
parameter must not be NULL if this option is used.
|
|
|
|
.It LOGIN_SETUSER
|
2006-06-17 07:25:58 +00:00
|
|
|
Set ownership of the current process to the uid specified in the
|
1997-01-04 16:50:08 +00:00
|
|
|
.Ar uid
|
|
|
|
parameter using
|
|
|
|
.Xr setuid 2 .
|
|
|
|
.It LOGIN_SETGROUP
|
|
|
|
Set group ownership of the current process to the group id
|
|
|
|
specified in the passwd structure using
|
|
|
|
.Xr setgid 2 ,
|
|
|
|
and calls
|
|
|
|
.Xr initgroups 3
|
|
|
|
to set up the group access list for the current process.
|
|
|
|
The
|
|
|
|
.Ar pwd
|
|
|
|
parameter must not be NULL if this option is used.
|
|
|
|
.It 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:
|
|
|
|
.Bd -literal
|
2011-03-24 16:06:57 +00:00
|
|
|
cputime RLIMIT_CPU
|
|
|
|
filesize RLIMIT_FSIZE
|
|
|
|
datasize RLIMIT_DATA
|
|
|
|
stacksize RLIMIT_STACK
|
|
|
|
coredumpsize RLIMIT_CORE
|
|
|
|
memoryuse RLIMIT_RSS
|
|
|
|
memorylocked RLIMIT_MEMLOCK
|
|
|
|
maxproc RLIMIT_NPROC
|
|
|
|
openfiles RLIMIT_NOFILE
|
|
|
|
sbsize RLIMIT_SBSIZE
|
|
|
|
vmemoryuse RLIMIT_VMEM
|
|
|
|
pseudoterminals RLIMIT_NPTS
|
|
|
|
swapuse RLIMIT_SWAP
|
2013-10-21 16:46:12 +00:00
|
|
|
kqueues RLIMIT_KQUEUES
|
2016-03-12 14:54:34 +00:00
|
|
|
umtxp RLIMIT_UMTXP
|
1997-01-04 16:50:08 +00:00
|
|
|
.Ed
|
|
|
|
.It 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:
|
|
|
|
.Bd -literal
|
|
|
|
priority
|
|
|
|
.Ed
|
|
|
|
.It LOGIN_SETUMASK
|
|
|
|
Set the umask for the current process to a value in the user or
|
|
|
|
system login class database.
|
|
|
|
Class capability tags used:
|
|
|
|
.Bd -literal
|
|
|
|
umask
|
|
|
|
.Ed
|
|
|
|
.It LOGIN_SETPATH
|
|
|
|
Set the "path" and "manpath" environment variables based on values
|
|
|
|
in the user or system login class database.
|
|
|
|
Class capability tags used with the corresponding environment
|
|
|
|
variables set:
|
|
|
|
.Bd -literal
|
|
|
|
path PATH
|
|
|
|
manpath MANPATH
|
|
|
|
.Ed
|
|
|
|
.It 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:
|
|
|
|
.Bd -literal
|
|
|
|
lang LANG
|
|
|
|
charset MM_CHARSET
|
|
|
|
timezone TZ
|
|
|
|
term TERM
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Additional environment variables may be set using the list type
|
|
|
|
capability "setenv=var1 val1,var2 val2..,varN valN".
|
2005-12-30 06:16:20 +00:00
|
|
|
.It LOGIN_SETMAC
|
|
|
|
Set the MAC label for the current process to the label specified
|
|
|
|
in system login class database.
|
2008-07-25 19:58:14 +00:00
|
|
|
.It LOGIN_SETCPUMASK
|
|
|
|
Create a new
|
|
|
|
.Xr cpuset 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 the
|
|
|
|
.Xr cpuset 1
|
2008-10-20 17:03:05 +00:00
|
|
|
utility or the case-insensitive string
|
2008-07-25 19:58:14 +00:00
|
|
|
.Ql default .
|
|
|
|
If the string is
|
|
|
|
.Ql default
|
|
|
|
no action will be taken.
|
2011-03-06 08:56:44 +00:00
|
|
|
.It LOGIN_SETLOGINCLASS
|
|
|
|
Set the login class of the current process using
|
|
|
|
.Xr setloginclass 2 .
|
1997-01-04 16:50:08 +00:00
|
|
|
.It LOGIN_SETALL
|
|
|
|
Enables all of the above settings.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Note that when setting environment variables and a valid passwd
|
|
|
|
pointer is provided in the
|
|
|
|
.Ar pwd
|
|
|
|
parameter, the characters
|
|
|
|
.Ql \&~
|
|
|
|
and
|
|
|
|
.Ql \&$
|
|
|
|
are substituted for the user's home directory and login name
|
|
|
|
respectively.
|
|
|
|
.Pp
|
|
|
|
The
|
2008-10-20 17:03:05 +00:00
|
|
|
.Fn setclasscpumask ,
|
1997-01-04 16:50:08 +00:00
|
|
|
.Fn setclassresources
|
|
|
|
and
|
|
|
|
.Fn setclassenvironment
|
|
|
|
functions are subsets of the setcontext functions above, but may
|
|
|
|
be useful in isolation.
|
|
|
|
.Sh RETURN VALUES
|
2003-03-24 16:02:05 +00:00
|
|
|
The
|
1997-01-04 16:50:08 +00:00
|
|
|
.Fn setclasscontext
|
|
|
|
and
|
|
|
|
.Fn setusercontext
|
2003-03-24 16:02:05 +00:00
|
|
|
functions return -1 if an error occurred, or 0 on success.
|
1997-01-04 16:50:08 +00:00
|
|
|
If an error occurs when attempting to set the user, login, group
|
|
|
|
or resources, a message is reported to
|
|
|
|
.Xr syslog 3 ,
|
|
|
|
with LOG_ERR priority and directed to the currently active facility.
|
|
|
|
.Sh SEE ALSO
|
2008-07-25 19:58:14 +00:00
|
|
|
.Xr cpuset 1 ,
|
2011-03-06 08:56:44 +00:00
|
|
|
.Xr ps 1 ,
|
2008-07-25 19:58:14 +00:00
|
|
|
.Xr cpuset 2 ,
|
1997-01-20 23:23:22 +00:00
|
|
|
.Xr setgid 2 ,
|
1997-01-04 16:50:08 +00:00
|
|
|
.Xr setlogin 2 ,
|
2011-03-06 08:56:44 +00:00
|
|
|
.Xr setloginclass 2 ,
|
1997-01-04 16:50:08 +00:00
|
|
|
.Xr setuid 2 ,
|
1997-01-20 23:23:22 +00:00
|
|
|
.Xr getcap 3 ,
|
1997-01-04 16:50:08 +00:00
|
|
|
.Xr initgroups 3 ,
|
|
|
|
.Xr login_cap 3 ,
|
2005-12-30 06:16:20 +00:00
|
|
|
.Xr mac_set_proc 3 ,
|
1997-01-04 16:50:08 +00:00
|
|
|
.Xr login.conf 5 ,
|
1997-01-20 23:23:22 +00:00
|
|
|
.Xr termcap 5
|