xref: /freebsd/lib/libutil/login.conf.5 (revision 1edb7116)
1.\" Copyright (c) 1996 David Nugent <davidn@blaze.net.au>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, is permitted provided that the following conditions
6.\" are met:
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
16.\"    David Nugent.
17.\" 5. Modifications may be freely made to this file providing the above
18.\"    conditions are met.
19.\"
20.Dd June 28, 2023
21.Dt LOGIN.CONF 5
22.Os
23.Sh NAME
24.Nm login.conf
25.Nd login class capability database
26.Sh SYNOPSIS
27.Pa /etc/login.conf ,
28.Pa ~/.login_conf
29.Sh DESCRIPTION
30.Nm
31contains various attributes and capabilities of login classes.
32A login class (an optional annotation against each record in the user
33account database,
34.Pa /etc/master.passwd )
35determines session accounting, resource limits and user environment settings.
36It is used by various programs in the system to set up a user's login
37environment and to enforce policy, accounting and administrative restrictions.
38It also provides the means by which users are able to be
39authenticated to the system and the types of authentication available.
40Attributes in addition to the ones described here are available with
41third-party packages.
42.Pp
43A special record "default" in the system user class capability database
44.Pa /etc/login.conf
45is used automatically for any
46non-root user without a valid login class in
47.Pa /etc/master.passwd .
48A user with a uid of 0 without a valid login class will use the record
49"root" if it exists, or "default" if not.
50.Pp
51Users may individually create a file called
52.Pa .login_conf
53in their home directory using the same format, consisting of a single
54entry with a record id of "me".
55If present, this file is used by
56.Xr login 1
57to set user-defined environment settings which override those specified
58in the system login capabilities database.
59Only a subset of login capabilities may be overridden, typically those
60which do not involve authentication, resource limits and accounting.
61.Pp
62Records in a class capabilities database consist of a number of
63colon-separated fields.
64The first entry for each record gives one or more names that a record is
65to be known by, each separated by a '|' character.
66The first name is the most common abbreviation.
67The last name given should be a long name that is more descriptive
68of the capability entry, and all others are synonyms.
69All names but the last should be in lower case and contain no blanks;
70the last name may contain upper case characters and blanks for
71readability.
72.Pp
73Note that since a colon
74.Pq Ql :\&
75is used to separate capability entries, a
76.Ql \ec
77escape sequence must be used to embed a literal colon in the
78value or name of a capability.
79.Pp
80The default
81.Pa /etc/login.conf
82shipped with
83.Fx
84is an out of the box configuration.
85Whenever changes to this, or
86the user's
87.Pa ~/.login_conf ,
88file are made, the modifications will not be picked up until
89.Xr cap_mkdb 1
90is used to compile the file into a database.
91This database file will have a
92.Pa .db
93extension and is accessed through
94.Xr cgetent 3 .
95See
96.Xr getcap 3
97for a more in-depth description of the format of a capability database.
98.Sh CAPABILITIES
99Fields within each record in the database follow the
100.Xr getcap 3
101conventions for boolean, type string
102.Ql \&=
103and type numeric
104.Ql \&# ,
105although type numeric is deprecated in favour of the string format and
106either form is accepted for a numeric datum.
107Values fall into the following categories:
108.Bl -tag -width "program"
109.It bool
110If the name is present, then the boolean value is true; otherwise, it is
111false
112.It file
113Path name to a data file
114.It program
115Path name to an executable file
116.It list
117A list of values (or pairs of values) separated by commas or spaces
118.It path
119A space or comma separated list of path names, following the usual csh
120conventions (leading tilde with and without username being expanded to
121home directories etc.)
122.It number
123A numeric value, either decimal (default), hexadecimal (with leading 0x),
124or octal (with a leading 0).
125With a numeric type, only one numeric value is allowed.
126Numeric types may also be specified in string format (i.e., the capability
127tag being delimited from the value by '=' instead of '#').
128Whichever method is used, then all records in the database must use the
129same method to allow values to be correctly overridden in interpolated
130records.
131A numeric value may be infinite.
132.It size
133A number which expresses a size.
134The default interpretation of a value is the number of bytes, but a
135suffix may specify alternate units:
136.Bl -tag -offset indent -compact -width xxxx
137.It b
138explicitly selects 512-byte blocks
139.It k
140selects kilobytes (1024 bytes)
141.It m
142specifies a multiplier of 1 megabyte (1048576 bytes),
143.It g
144specifies units of gigabytes, and
145.It t
146represents terabytes.
147.El
148A size value is a numeric quantity and case of the suffix is not significant.
149Concatenated values are added together.
150A size value may be infinite.
151.It time
152A period of time, by default in seconds.
153A prefix may specify a different unit:
154.Bl -tag -offset indent -compact -width xxxx
155.It y
156indicates the number of 365 day years,
157.It w
158indicates the number of weeks,
159.It d
160the number of days,
161.It h
162the number of hours,
163.It m
164the number of minutes, and
165.It s
166the number of seconds.
167.El
168Concatenated values are added together.
169For example, 2 hours and 40 minutes may be written either as
1709600s, 160m or 2h40m.
171A time value may be infinite.
172.El
173.Pp
174.Dq infinity ,
175.Dq inf ,
176.Dq unlimited ,
177.Dq unlimit,
178and -1
179are considered infinite values.
180.Pp
181The usual convention to interpolate capability entries using the special
182.Em tc=value
183notation may be used.
184.Pp
185Default values are specified in the
186.Ql Default
187column.
188If there is no default, the value is inherited from the process setting up the
189login environment.
190.Sh RESOURCE LIMITS
191.Bl -column pseudoterminals indent indent
192.It Sy "Name	Type	Default	Description"
193.It "coredumpsize	size		Maximum coredump size limit."
194.It "cputime	time		CPU usage limit."
195.It "datasize	size		Maximum data size limit."
196.It "filesize	size		Maximum file size limit."
197.It "maxproc	number		Maximum number of processes."
198.It "memorylocked	size		Maximum locked in core memory size limit."
199.It "memoryuse	size		Maximum of core memory use size limit."
200.It "openfiles	number		Maximum number of open files per process."
201.It "sbsize	size		Maximum permitted socketbuffer size."
202.It "vmemoryuse	size		Maximum permitted total VM usage per process."
203.It "stacksize	size		Maximum stack size limit."
204.It "pseudoterminals	number		Maximum number of pseudo-terminals."
205.It "swapuse	size		Maximum swap space size limit."
206.It "umtxp	number		Maximum number of process-shared pthread locks."
207.El
208.Pp
209These resource limit entries actually specify both the maximum
210and current limits (see
211.Xr getrlimit 2 ) .
212The current (soft) limit is the one normally used, although the user is
213permitted to increase the current limit to the maximum (hard) limit.
214The maximum and current limits may be specified individually by appending a
215-max or -cur to the capability name.
216.Sh ENVIRONMENT
217.Bl -column ignorenologin indent xbinxxusrxbin
218.It Sy "Name	Type	Default	Description"
219.It "charset	string		Set $MM_CHARSET environment variable to the specified"
220value.
221.It "cpumask	string		List of cpus to bind the user to."
222The syntax is the same as for the
223.Fl l
224argument of
225.Xr cpuset 1
226or the word
227.Ql default .
228If set to
229.Ql default
230no action is taken.
231.It "hushlogin	bool	false	Same as having a ~/.hushlogin file."
232.It "ignorenologin	bool	false	Login not prevented by nologin."
233.It "ftp-chroot	bool	false	Limit FTP access with"
234.Xr chroot 2
235to the
236.Ev HOME
237directory of the user.
238See
239.Xr ftpd 8
240for details.
241.It "label	string		Default MAC policy; see"
242.Xr maclabel 7 .
243.It "lang	string		Set $LANG environment variable to the specified value."
244.It "mail	string		Set $MAIL environment variable to the specified value."
245.It "manpath	path		Default search path for manpages."
246.It "nocheckmail	bool	false	Display mail status at login."
247.It "nologin	file		If the file exists it will be displayed and"
248the login session will be terminated.
249.It "path	path	/bin /usr/bin	Default search path."
250.It "priority	number	0	Initial priority level."
251A value in the nice range
252.Pq -20 to 20 included ,
253extended below with the 32 real-time class priorities
254.Po
255so -52 maps to priority 0 in the real-time class, -51 to 1, and so on until -21
256which maps to 31; see
257.Xr rtprio 1
258.Pc
259and above with the 32 idle class priorities
260.Po
261so 21 maps to priority 0 in the idle class, 22 to 1, and so on until 52 which
262maps to 31; see
263.Xr idprio 1
264.Pc .
265Special value
266.Ql inherit
267prevents resetting the priority.
268.It "requirehome 	bool	false	Require a valid home directory to login."
269.It "setenv	list		A comma-separated list of environment variables and"
270values to which they are to be set.
271Values containing commas must be quoted.
272.It "shell	prog		Session shell to execute rather than the"
273shell specified in the passwd file.
274The SHELL environment variable will
275contain the shell specified in the password file.
276.It "term	string		Default terminal type if not able to determine"
277from other means.
278.It "timezone	string		Default value of $TZ environment variable."
279.It "umask	number		Initial umask. Should always have a leading 0 to"
280ensure octal interpretation.
281Special value
282.Ql inherit
283explicitly indicates not to change the umask.
284.It "welcome	file	/etc/motd	File containing welcome message."
285.El
286.Sh AUTHENTICATION
287.Bl -column passwd_prompt indent indent
288.It Sy "Name	Type	Default	Description"
289.\" .It "approve	program 	Program to approve login.
290.It "copyright	file		File containing additional copyright information"
291.It "host.allow	list		List of remote host wildcards from which users in"
292the class may access.
293.It "host.deny	list		List of remote host wildcards from which users"
294in the class may not access.
295.It "login_prompt	string		The login prompt given by"
296.Xr login 1
297.It "login-backoff	number	3	The number of login attempts"
298allowed before the backoff delay is inserted after each subsequent
299attempt.
300The backoff delay is the number of tries above
301.Em login-backoff
302multiplied by 5 seconds.
303.It "login-retries	number	10	The number of login attempts"
304allowed before the login fails.
305.It "passwd_format	string	sha512	The encryption format that new or"
306changed passwords will use.
307Valid values include "des", "md5", "blf", "sha256" and "sha512"; see
308.Xr crypt 3
309for details.
310NIS clients using a
311.No non- Ns Fx
312NIS server should probably use "des".
313.It "passwd_prompt	string		The password prompt presented by"
314.Xr login 1
315.It "passwordtime	time		Used by"
316.Xr passwd 1
317to set next password expiry date.
318.It "times.allow 	list		List of time periods during which"
319logins are allowed.
320.It "times.deny	list		List of time periods during which logins are"
321disallowed.
322.It "ttys.allow	list		List of ttys and ttygroups which users"
323in the class may use for access.
324.It "ttys.deny	list		List of ttys and ttygroups which users"
325in the class may not use for access.
326.It "warnexpire	time		Advance notice for pending account expiry."
327.It "warnpassword	time		Advance notice for pending password expiry."
328.\".It "widepasswords	bool	false	Use the wide password format. The wide password
329.\" format allows up to 128 significant characters in the password.
330.El
331.Pp
332These fields are intended to be used by
333.Xr passwd 1
334and other programs in the login authentication system.
335.Pp
336Capabilities that set environment variables are scanned for both
337.Ql \&~
338and
339.Ql \&$
340characters, which are substituted for a user's home directory and name
341respectively.
342To pass these characters literally into the environment variable, escape
343the character by preceding it with a backslash '\\'.
344.Pp
345The
346.Em host.allow
347and
348.Em host.deny
349entries are comma separated lists used for checking remote access to the system,
350and consist of a list of hostnames and/or IP addresses against which remote
351network logins are checked.
352Items in these lists may contain wildcards in the form used by shell programs
353for wildcard matching (See
354.Xr fnmatch 3
355for details on the implementation).
356The check on hosts is made against both the remote system's Internet address
357and hostname (if available).
358If both lists are empty or not specified, then logins from any remote host
359are allowed.
360If host.allow contains one or more hosts, then only remote systems matching
361any of the items in that list are allowed to log in.
362If host.deny contains one or more hosts, then a login from any matching hosts
363will be disallowed.
364.Pp
365The
366.Em times.allow
367and
368.Em times.deny
369entries consist of a comma-separated list of time periods during which the users
370in a class are allowed to be logged in.
371These are expressed as one or more day codes followed by a start and end times
372expressed in 24 hour format, separated by a hyphen or dash.
373For example, MoThSa0200-1300 translates to Monday, Thursday and Saturday between
374the hours of 2 am and 1 p.m..
375If both of these time lists are empty, users in the class are allowed access at
376any time.
377If
378.Em times.allow
379is specified, then logins are only allowed during the periods given.
380If
381.Em times.deny
382is specified, then logins are denied during the periods given, regardless of whether
383one of the periods specified in
384.Em times.allow
385applies.
386.Pp
387Note that
388.Xr login 1
389enforces only that the actual login falls within periods allowed by these entries.
390Further enforcement over the life of a session requires a separate daemon to
391monitor transitions from an allowed period to a non-allowed one.
392.Pp
393The
394.Em ttys.allow
395and
396.Em ttys.deny
397entries contain a comma-separated list of tty devices (without the /dev/ prefix)
398that a user in a class may use to access the system, and/or a list of ttygroups
399(See
400.Xr getttyent 3
401and
402.Xr ttys 5
403for information on ttygroups).
404If neither entry exists, then the choice of login device used by the user is
405unrestricted.
406If only
407.Em ttys.allow
408is specified, then the user is restricted only to ttys in the given
409group or device list.
410If only
411.Em ttys.deny
412is specified, then the user is prevented from using the specified devices or
413devices in the group.
414If both lists are given and are non-empty, the user is restricted to those
415devices allowed by ttys.allow that are not available by ttys.deny.
416.Pp
417The
418.Em minpasswordlen
419and
420.Em minpasswordcase
421facilities for enforcing restrictions on password quality, which used
422to be supported by
423.Nm ,
424have been superseded by the
425.Xr pam_passwdqc 8
426PAM module.
427.Sh RESERVED CAPABILITIES
428The following capabilities are reserved for the purposes indicated and
429may be supported by third-party software.
430They are not implemented in the base system.
431.Bl -column host.accounted indent indent
432.It Sy "Name	Type	Default	Description"
433.It "accounted	bool	false	Enable session time accounting for all users"
434in this class.
435.It "auth	list	passwd	Allowed authentication styles."
436The first item is the default style.
437.It "auth-" Ns Ar type Ta "list		Allowed authentication styles for the"
438authentication
439.Ar type .
440.It "autodelete	time		Time after expiry when account is auto-deleted."
441.It "bootfull	bool	false	Enable 'boot only if ttygroup is full' strategy"
442when terminating sessions.
443.It "daytime	time		Maximum login time per day."
444.It "expireperiod	time		Time for expiry allocation."
445.It "graceexpire 	time		Grace days for expired account."
446.It "gracetime	time		Additional grace login time allowed."
447.It "host.accounted	list		List of remote host wildcards from which"
448login sessions will be accounted.
449.It "host.exempt 	list		List of remote host wildcards from which"
450login session accounting is exempted.
451.It "idletime	time		Maximum idle time before logout."
452.It "minpasswordlen	number	6	The minimum length a local"
453password may be.
454.It "mixpasswordcase	bool	true	Whether"
455.Xr passwd 1
456will warn the user if an all lower case password is entered.
457.It "monthtime 	time		Maximum login time per month."
458.It "refreshtime 	time		New time allowed on account refresh."
459.It "refreshperiod	str		How often account time is refreshed."
460.It "sessiontime 	time		Maximum login time per session."
461.It "sessionlimit	number		Maximum number of concurrent"
462login sessions on ttys in any group.
463.It "ttys.accounted	list		List of ttys and ttygroups for which"
464login accounting is active.
465.It "ttys.exempt	list		List of ttys and ttygroups for which login accounting"
466is exempt.
467.It "warntime	time		Advance notice for pending out-of-time."
468.It "weektime	time		Maximum login time per week."
469.El
470.Pp
471The
472.Em ttys.accounted
473and
474.Em ttys.exempt
475fields operate in a similar manner to
476.Em ttys.allow
477and
478.Em ttys.deny
479as explained
480above.
481Similarly with the
482.Em host.accounted
483and
484.Em host.exempt
485lists.
486.Sh SEE ALSO
487.Xr cap_mkdb 1 ,
488.Xr login 1 ,
489.Xr chroot 2 ,
490.Xr getcap 3 ,
491.Xr getttyent 3 ,
492.Xr login_cap 3 ,
493.Xr login_class 3 ,
494.Xr pam 3 ,
495.Xr passwd 5 ,
496.Xr ttys 5 ,
497.Xr ftpd 8 ,
498.Xr pam_passwdqc 8
499.Sh HISTORY
500The file
501.Nm
502first appeared in
503.Fx 2.1.5 .
504