xref: /f-stack/tools/libutil/login_cap.3 (revision 22ce4aff)
11eaf0ac3Slogwang.\" Copyright (c) 1995 David Nugent <[email protected]>
21eaf0ac3Slogwang.\" All rights reserved.
31eaf0ac3Slogwang.\"
41eaf0ac3Slogwang.\" Redistribution and use in source and binary forms, with or without
51eaf0ac3Slogwang.\" modification, is permitted provided that the following conditions
61eaf0ac3Slogwang.\" are met:
71eaf0ac3Slogwang.\" 1. Redistributions of source code must retain the above copyright
81eaf0ac3Slogwang.\"    notice immediately at the beginning of the file, without modification,
91eaf0ac3Slogwang.\"    this list of conditions, and the following disclaimer.
101eaf0ac3Slogwang.\" 2. Redistributions in binary form must reproduce the above copyright
111eaf0ac3Slogwang.\"    notice, this list of conditions and the following disclaimer in the
121eaf0ac3Slogwang.\"    documentation and/or other materials provided with the distribution.
131eaf0ac3Slogwang.\" 3. This work was done expressly for inclusion into FreeBSD.  Other use
141eaf0ac3Slogwang.\"    is permitted provided this notation is included.
151eaf0ac3Slogwang.\" 4. Absolutely no warranty of function or purpose is made by the author
161eaf0ac3Slogwang.\"    David Nugent.
171eaf0ac3Slogwang.\" 5. Modifications may be freely made to this file providing the above
181eaf0ac3Slogwang.\"    conditions are met.
191eaf0ac3Slogwang.\"
201eaf0ac3Slogwang.\" $FreeBSD$
211eaf0ac3Slogwang.\"
22*22ce4affSfengbojiang.Dd May 10, 2020
231eaf0ac3Slogwang.Dt LOGIN_CAP 3
241eaf0ac3Slogwang.Os
251eaf0ac3Slogwang.Sh NAME
261eaf0ac3Slogwang.Nm login_close ,
271eaf0ac3Slogwang.Nm login_getcapbool ,
281eaf0ac3Slogwang.Nm login_getcaplist ,
291eaf0ac3Slogwang.Nm login_getcapnum ,
301eaf0ac3Slogwang.Nm login_getcapstr ,
311eaf0ac3Slogwang.Nm login_getcapsize ,
321eaf0ac3Slogwang.Nm login_getcaptime ,
331eaf0ac3Slogwang.Nm login_getclass ,
341eaf0ac3Slogwang.Nm login_getclassbyname ,
351eaf0ac3Slogwang.Nm login_getpwclass ,
361eaf0ac3Slogwang.Nm login_getstyle ,
371eaf0ac3Slogwang.Nm login_getuserclass ,
381eaf0ac3Slogwang.Nm login_setcryptfmt
391eaf0ac3Slogwang.Nd "functions for accessing the login class capabilities database"
401eaf0ac3Slogwang.Sh LIBRARY
411eaf0ac3Slogwang.Lb libutil
421eaf0ac3Slogwang.Sh SYNOPSIS
431eaf0ac3Slogwang.In sys/types.h
441eaf0ac3Slogwang.In login_cap.h
451eaf0ac3Slogwang.Ft void
461eaf0ac3Slogwang.Fn login_close "login_cap_t *lc"
471eaf0ac3Slogwang.Ft login_cap_t *
481eaf0ac3Slogwang.Fn login_getclassbyname "const char *nam" "const struct passwd *pwd"
491eaf0ac3Slogwang.Ft login_cap_t *
501eaf0ac3Slogwang.Fn login_getclass "const char *nam"
511eaf0ac3Slogwang.Ft login_cap_t *
521eaf0ac3Slogwang.Fn login_getpwclass "const struct passwd *pwd"
531eaf0ac3Slogwang.Ft login_cap_t *
541eaf0ac3Slogwang.Fn login_getuserclass "const struct passwd *pwd"
551eaf0ac3Slogwang.Ft "const char *"
561eaf0ac3Slogwang.Fn login_getcapstr "login_cap_t *lc" "const char *cap" "const char *def" "const char *error"
571eaf0ac3Slogwang.Ft "const char **"
581eaf0ac3Slogwang.Fn login_getcaplist "login_cap_t *lc" "const char *cap" "const char *chars"
591eaf0ac3Slogwang.Ft "const char *"
601eaf0ac3Slogwang.Fn login_getpath "login_cap_t *lc" "const char *cap" "const char *error"
611eaf0ac3Slogwang.Ft rlim_t
621eaf0ac3Slogwang.Fn login_getcaptime "login_cap_t *lc" "const char *cap" "rlim_t def" "rlim_t error"
631eaf0ac3Slogwang.Ft rlim_t
641eaf0ac3Slogwang.Fn login_getcapnum "login_cap_t *lc" "const char *cap" "rlim_t def" "rlim_t error"
651eaf0ac3Slogwang.Ft rlim_t
661eaf0ac3Slogwang.Fn login_getcapsize "login_cap_t *lc" "const char *cap" "rlim_t def" "rlim_t error"
671eaf0ac3Slogwang.Ft int
681eaf0ac3Slogwang.Fn login_getcapbool "login_cap_t *lc" "const char *cap" "int def"
691eaf0ac3Slogwang.Ft "const char *"
701eaf0ac3Slogwang.Fn login_getstyle "login_cap_t *lc" "const char *style" "const char *auth"
711eaf0ac3Slogwang.Ft const char *
721eaf0ac3Slogwang.Fn login_setcryptfmt "login_cap_t *lc" "const char *def" "const char *error"
731eaf0ac3Slogwang.Sh DESCRIPTION
741eaf0ac3SlogwangThese functions represent a programming interface to the login
751eaf0ac3Slogwangclasses database provided in
761eaf0ac3Slogwang.Xr login.conf 5 .
771eaf0ac3SlogwangThis database contains capabilities, attributes and default environment
781eaf0ac3Slogwangand accounting settings for users and programs running as specific users,
791eaf0ac3Slogwangas determined by the login class field within entries in
801eaf0ac3Slogwang.Pa /etc/master.passwd .
811eaf0ac3Slogwang.Pp
821eaf0ac3SlogwangEntries in
831eaf0ac3Slogwang.Xr login.conf 5
841eaf0ac3Slogwangconsist of colon
851eaf0ac3Slogwang.Ql \&:
861eaf0ac3Slogwangseparated fields, the first field in each record being one or more
871eaf0ac3Slogwangidentifiers for the record (which must be unique for the entire database),
881eaf0ac3Slogwangeach separated by a
891eaf0ac3Slogwang.Ql | ,
901eaf0ac3Slogwangand may optionally include a description as
911eaf0ac3Slogwangthe last
921eaf0ac3Slogwang.Sq name .
931eaf0ac3SlogwangRemaining fields in the record consist of keyword/data pairs.
941eaf0ac3SlogwangLong lines may be continued with a backslash within empty entries,
951eaf0ac3Slogwangwith the second and subsequent lines optionally indented for readability.
961eaf0ac3SlogwangThis is similar to the format used in
971eaf0ac3Slogwang.Xr termcap 5 ,
981eaf0ac3Slogwangexcept that keywords are not limited to two significant characters,
991eaf0ac3Slogwangand are usually longer for improved readability.
1001eaf0ac3SlogwangAs with termcap entries, multiple records can be linked together
1011eaf0ac3Slogwang(one record including another) using a field containing
1021eaf0ac3Slogwang.Ql tc= Ns Va <recordid> .
1031eaf0ac3SlogwangThe result is that the entire record referenced by
1041eaf0ac3Slogwang.Va <recordid>
1051eaf0ac3Slogwangreplaces the
1061eaf0ac3Slogwang.Va tc=
1071eaf0ac3Slogwangfield at the point at which it occurs.
1081eaf0ac3SlogwangSee
1091eaf0ac3Slogwang.Xr getcap 3
1101eaf0ac3Slogwangfor further details on the format and use of a capabilities database.
1111eaf0ac3Slogwang.Pp
1121eaf0ac3SlogwangThe
1131eaf0ac3Slogwang.Nm login_cap
1141eaf0ac3Slogwanginterface provides a convenient means of retrieving login class
1151eaf0ac3Slogwangrecords with all
1161eaf0ac3Slogwang.Va tc=
1171eaf0ac3Slogwangreferences expanded.
1181eaf0ac3SlogwangA program will typically call one of
1191eaf0ac3Slogwang.Fn login_getclass ,
1201eaf0ac3Slogwang.Fn login_getpwclass ,
1211eaf0ac3Slogwang.Fn login_getuserclass
1221eaf0ac3Slogwangor
1231eaf0ac3Slogwang.Fn login_getclassbyname
1241eaf0ac3Slogwangaccording to its requirements.
1251eaf0ac3SlogwangEach of these functions returns a login capabilities structure,
1261eaf0ac3Slogwang.Vt login_cap_t ,
1271eaf0ac3Slogwangwhich may subsequently be used to interrogate the database for
1281eaf0ac3Slogwangspecific values using the rest of the API.
1291eaf0ac3SlogwangOnce the
1301eaf0ac3Slogwang.Vt login_cap_t
1311eaf0ac3Slogwangis of no further use, the
1321eaf0ac3Slogwang.Fn login_close
1331eaf0ac3Slogwangfunction should be called to free all resources used.
1341eaf0ac3Slogwang.Pp
1351eaf0ac3SlogwangThe structure of
1361eaf0ac3Slogwang.Vt login_cap_t
1371eaf0ac3Slogwangis defined in
1381eaf0ac3Slogwang.In login_cap.h ,
1391eaf0ac3Slogwangas:
1401eaf0ac3Slogwang.Bd -literal -offset indent
1411eaf0ac3Slogwangtypedef struct {
1421eaf0ac3Slogwang	char *lc_class;
1431eaf0ac3Slogwang	char *lc_cap;
1441eaf0ac3Slogwang	char *lc_style;
1451eaf0ac3Slogwang} login_cap_t;
1461eaf0ac3Slogwang.Ed
1471eaf0ac3Slogwang.Pp
1481eaf0ac3SlogwangThe
1491eaf0ac3Slogwang.Fa lc_class
1501eaf0ac3Slogwangmember contains a pointer to the name of the login class
1511eaf0ac3Slogwangretrieved.
1521eaf0ac3SlogwangThis may not necessarily be the same as the one requested,
1531eaf0ac3Slogwangeither directly via
1541eaf0ac3Slogwang.Fn login_getclassbyname ,
1551eaf0ac3Slogwangor indirectly via a user's login record using
1561eaf0ac3Slogwang.Fn login_getpwclass ,
1571eaf0ac3Slogwangby class name using
1581eaf0ac3Slogwang.Fn login_getclass .
1591eaf0ac3SlogwangIf the referenced user has no login class specified in
1601eaf0ac3Slogwang.Pa /etc/master.passwd ,
1611eaf0ac3Slogwangthe class name is
1621eaf0ac3Slogwang.Dv NULL
1631eaf0ac3Slogwangor an empty string.
1641eaf0ac3SlogwangIf the class
1651eaf0ac3Slogwangspecified does not exist in the database, each of these
1661eaf0ac3Slogwangfunctions will search for a record with an id of
1671eaf0ac3Slogwang.Ql default ,
1681eaf0ac3Slogwangwith that name returned in the
1691eaf0ac3Slogwang.Fa lc_class
1701eaf0ac3Slogwangfield.
1711eaf0ac3SlogwangIn addition, if the referenced user has a UID of 0 (normally,
1721eaf0ac3Slogwang.Ql root ,
1731eaf0ac3Slogwangalthough the user name is not considered) then
1741eaf0ac3Slogwang.Fn login_getpwclass
1751eaf0ac3Slogwangwill search for a record with an id of
1761eaf0ac3Slogwang.Ql root
1771eaf0ac3Slogwangbefore it searches
1781eaf0ac3Slogwangfor the record with the id of
1791eaf0ac3Slogwang.Ql default .
1801eaf0ac3Slogwang.Pp
1811eaf0ac3SlogwangThe
1821eaf0ac3Slogwang.Fa lc_cap
1831eaf0ac3Slogwangfield is used internally by the library to contain the
1841eaf0ac3Slogwangexpanded login capabilities record.
1851eaf0ac3SlogwangPrograms with unusual requirements may wish to use this
1861eaf0ac3Slogwangwith the lower-level
1871eaf0ac3Slogwang.Fn getcap
1881eaf0ac3Slogwangstyle functions to access the record directly.
1891eaf0ac3Slogwang.Pp
1901eaf0ac3SlogwangThe
1911eaf0ac3Slogwang.Fa lc_style
1921eaf0ac3Slogwangfield is set by the
1931eaf0ac3Slogwang.Fn login_getstyle
1941eaf0ac3Slogwangfunction to the authorisation style, according to the requirements
1951eaf0ac3Slogwangof the program handling a login itself.
1961eaf0ac3Slogwang.Pp
1971eaf0ac3SlogwangThe
1981eaf0ac3Slogwang.Fn login_getclassbyname
1991eaf0ac3Slogwangfunction is the basic means to get a
2001eaf0ac3Slogwang.Vt login_cap_t
2011eaf0ac3Slogwangobject.
2021eaf0ac3SlogwangIt accepts two arguments: the first one,
2031eaf0ac3Slogwang.Fa name ,
2041eaf0ac3Slogwangis the record identifier of the
2051eaf0ac3Slogwangrecord to be retrieved; the second,
2061eaf0ac3Slogwang.Fa pwd ,
2071eaf0ac3Slogwangis an optional pointer to a
2081eaf0ac3Slogwang.Vt passwd
2091eaf0ac3Slogwangstructure.
2101eaf0ac3SlogwangFirst of all, its arguments are used by the function
2111eaf0ac3Slogwangto choose between system and user modes of operation.
2121eaf0ac3SlogwangWhen in system mode, only the system login class database is used.
2131eaf0ac3SlogwangWhen in user mode, the supplemental login class database in the
2141eaf0ac3Slogwanguser's home directory is allowed to override settings from the system
2151eaf0ac3Slogwangdatabase in a limited way as noted below.
2161eaf0ac3SlogwangTo minimize security implications, user mode is entered by
2171eaf0ac3Slogwang.Fn login_getclassbyname
2181eaf0ac3Slogwangif and only if
2191eaf0ac3Slogwang.Fa name
2201eaf0ac3Slogwangis
2211eaf0ac3Slogwang.Dv LOGIN_MECLASS
2221eaf0ac3Slogwang.Pq Ql me
2231eaf0ac3Slogwangand
2241eaf0ac3Slogwang.Fa pwd
2251eaf0ac3Slogwangis not
2261eaf0ac3Slogwang.Dv NULL .
2271eaf0ac3SlogwangOtherwise system mode is chosen.
2281eaf0ac3Slogwang.Pp
2291eaf0ac3SlogwangIn system mode, any record in the system database
2301eaf0ac3Slogwang.Pa /etc/login.conf
2311eaf0ac3Slogwangcan be accessed,
2321eaf0ac3Slogwangand a fallback to the default record is provided as follows.
2331eaf0ac3SlogwangIf
2341eaf0ac3Slogwang.Fa name
2351eaf0ac3Slogwangis
2361eaf0ac3Slogwang.Dv NULL ,
2371eaf0ac3Slogwangan empty string, or a class that does not exist
2381eaf0ac3Slogwangin the login class database, then the
2391eaf0ac3Slogwang.Dv LOGIN_DEFCLASS
2401eaf0ac3Slogwangrecord
2411eaf0ac3Slogwang.Pq Ql default
2421eaf0ac3Slogwangis returned instead.
2431eaf0ac3Slogwang.Pp
2441eaf0ac3SlogwangIn user mode, only the
2451eaf0ac3Slogwang.Dv LOGIN_MECLASS
2461eaf0ac3Slogwangrecord
2471eaf0ac3Slogwang.Pq Ql me
2481eaf0ac3Slogwangis accessed and no fallback to the
2491eaf0ac3Slogwang.Ql default
2501eaf0ac3Slogwangrecord is provided.
2511eaf0ac3SlogwangThe directory specified by
2521eaf0ac3Slogwang.Fa pwd->pw_dir
2531eaf0ac3Slogwangis searched for
2541eaf0ac3Slogwanga login database file called
2551eaf0ac3Slogwang.Pa .login_conf ,
2561eaf0ac3Slogwangand only the
2571eaf0ac3Slogwang.Ql me
2581eaf0ac3Slogwangcapability record
2591eaf0ac3Slogwangcontained within it may override the system record with the same name
2601eaf0ac3Slogwangwhile other records are ignored.
2611eaf0ac3SlogwangUsing this scheme, an application can explicitly
2621eaf0ac3Slogwangallow users to override a selected subset of login settings.
2631eaf0ac3SlogwangTo do so, the application should obtain two
2641eaf0ac3Slogwang.Vt login_cap_t
2651eaf0ac3Slogwangobjects, one in user mode and the other in system mode,
2661eaf0ac3Slogwangand then query the user object before the
2671eaf0ac3Slogwangsystem object for login parameters that are allowed to
2681eaf0ac3Slogwangbe overridden by the user.
2691eaf0ac3SlogwangFor example, the user's
2701eaf0ac3Slogwang.Pa .login_conf
2711eaf0ac3Slogwangcan provide a convenient way for a user to set up their preferred
2721eaf0ac3Slogwanglogin environment before the shell is invoked on login if supported by
2731eaf0ac3Slogwang.Xr login 1 .
2741eaf0ac3Slogwang.Pp
2751eaf0ac3SlogwangNote that access to the
2761eaf0ac3Slogwang.Pa /etc/login.conf
2771eaf0ac3Slogwangand
2781eaf0ac3Slogwang.Pa .login_conf
2791eaf0ac3Slogwangfiles will only be performed subject to the security checks documented in
2801eaf0ac3Slogwang.Xr _secure_path 3
2811eaf0ac3Slogwangfor the uids 0 and
2821eaf0ac3Slogwang.Fa pwd->pw_uid
2831eaf0ac3Slogwangrespectively.
2841eaf0ac3Slogwang.Pp
2851eaf0ac3SlogwangIf the specified record is
2861eaf0ac3Slogwang.Dv NULL ,
2871eaf0ac3Slogwangempty or does not exist, and the
2881eaf0ac3Slogwangsystem has no
2891eaf0ac3Slogwang.Ql default
2901eaf0ac3Slogwangrecord available to fall back to, there is a
2911eaf0ac3Slogwangmemory allocation error or for some reason
2921eaf0ac3Slogwang.Xr cgetent 3
2931eaf0ac3Slogwangis unable to access the login capabilities database, this function
2941eaf0ac3Slogwangreturns
2951eaf0ac3Slogwang.Dv NULL .
2961eaf0ac3Slogwang.Pp
2971eaf0ac3SlogwangThe functions
2981eaf0ac3Slogwang.Fn login_getclass ,
2991eaf0ac3Slogwang.Fn login_getpwclass
3001eaf0ac3Slogwangand
3011eaf0ac3Slogwang.Fn login_getuserclass
3021eaf0ac3Slogwangretrieve the applicable login class record for the user's passwd
3031eaf0ac3Slogwangentry or class name by calling
3041eaf0ac3Slogwang.Fn login_getclassbyname .
3051eaf0ac3SlogwangOn failure,
3061eaf0ac3Slogwang.Dv NULL
3071eaf0ac3Slogwangis returned.
3081eaf0ac3SlogwangThe difference between these functions is that
3091eaf0ac3Slogwang.Fn login_getuserclass
3101eaf0ac3Slogwangincludes the user's overriding
3111eaf0ac3Slogwang.Pa .login_conf
3121eaf0ac3Slogwangthat exists in the user's home directory, and
3131eaf0ac3Slogwang.Fn login_getpwclass
3141eaf0ac3Slogwangand
3151eaf0ac3Slogwang.Fn login_getclass
3161eaf0ac3Slogwangrestrict lookup only to the system login class database in
3171eaf0ac3Slogwang.Pa /etc/login.conf .
3181eaf0ac3SlogwangAs explained earlier,
3191eaf0ac3Slogwang.Fn login_getpwclass
3201eaf0ac3Slogwangdiffers from
3211eaf0ac3Slogwang.Fn login_getclass
3221eaf0ac3Slogwangin that it allows the default class for a super-user as
3231eaf0ac3Slogwang.Ql root
3241eaf0ac3Slogwangif none has been specified in the password database.
3251eaf0ac3SlogwangOtherwise, if the passwd pointer is
3261eaf0ac3Slogwang.Dv NULL ,
3271eaf0ac3Slogwangor the user record
3281eaf0ac3Slogwanghas no login class, then the system
3291eaf0ac3Slogwang.Ql default
3301eaf0ac3Slogwangentry is retrieved.
3311eaf0ac3SlogwangEssentially,
3321eaf0ac3Slogwang.Fn login_getclass name
3331eaf0ac3Slogwangis equivalent to
3341eaf0ac3Slogwang.Fn login_getclassbyname name NULL
3351eaf0ac3Slogwangand
3361eaf0ac3Slogwang.Fn login_getuserclass pwd
3371eaf0ac3Slogwangto
3381eaf0ac3Slogwang.Fn login_getclassbyname LOGIN_MECLASS pwd .
3391eaf0ac3Slogwang.Pp
3401eaf0ac3SlogwangOnce a program no longer wishes to use a
3411eaf0ac3Slogwang.Vt login_cap_t
3421eaf0ac3Slogwangobject,
3431eaf0ac3Slogwang.Fn login_close
3441eaf0ac3Slogwangmay be called to free all resources used by the login class.
3451eaf0ac3SlogwangThe
3461eaf0ac3Slogwang.Fn login_close
3471eaf0ac3Slogwangfunction may be passed a
3481eaf0ac3Slogwang.Dv NULL
3491eaf0ac3Slogwangpointer with no harmful side-effects.
3501eaf0ac3Slogwang.Pp
3511eaf0ac3SlogwangThe remaining functions may be used to retrieve individual
3521eaf0ac3Slogwangcapability records.
3531eaf0ac3SlogwangEach function takes a
3541eaf0ac3Slogwang.Vt login_cap_t
3551eaf0ac3Slogwangobject as its first parameter,
3561eaf0ac3Slogwanga capability tag as the second, and remaining parameters being
3571eaf0ac3Slogwangdefault and error values that are returned if the capability is
3581eaf0ac3Slogwangnot found.
3591eaf0ac3SlogwangThe type of the additional parameters passed and returned depend
3601eaf0ac3Slogwangon the
3611eaf0ac3Slogwang.Em type
3621eaf0ac3Slogwangof capability each deals with, be it a simple string, a list,
3631eaf0ac3Slogwanga time value, a file or memory size value, a path (consisting of
3641eaf0ac3Slogwanga colon-separated list of directories) or a boolean flag.
3651eaf0ac3SlogwangThe manpage for
3661eaf0ac3Slogwang.Xr login.conf 5
3671eaf0ac3Slogwangdeals in specific tags and their type.
3681eaf0ac3Slogwang.Pp
3691eaf0ac3SlogwangNote that with all functions in this group, you should not call
3701eaf0ac3Slogwang.Xr free 3
3711eaf0ac3Slogwangon any pointers returned.
3721eaf0ac3SlogwangMemory allocated during retrieval or processing of capability
3731eaf0ac3Slogwangtags is automatically reused by subsequent calls to functions
3741eaf0ac3Slogwangin this group, or deallocated on calling
3751eaf0ac3Slogwang.Fn login_close .
3761eaf0ac3Slogwang.Bl -tag -width "login_getcaplist()"
3771eaf0ac3Slogwang.It Fn login_getcapstr
3781eaf0ac3SlogwangThis function returns a simple string capability.
3791eaf0ac3SlogwangIf the string is not found, then the value in
3801eaf0ac3Slogwang.Fa def
3811eaf0ac3Slogwangis returned as the default value, or if an error
3821eaf0ac3Slogwangoccurs, the value in the
3831eaf0ac3Slogwang.Fa error
3841eaf0ac3Slogwangparameter is returned.
3851eaf0ac3Slogwang.It Fn login_getcaplist
3861eaf0ac3SlogwangThis function returns the value corresponding to the named
3871eaf0ac3Slogwangcapability tag as a list of values in a
3881eaf0ac3Slogwang.Dv NULL
3891eaf0ac3Slogwangterminated array.
3901eaf0ac3SlogwangWithin the login class database, some tags are of type
3911eaf0ac3Slogwang.Vt list ,
3921eaf0ac3Slogwangwhich consist of one or more comma- or space separated
3931eaf0ac3Slogwangvalues.
3941eaf0ac3SlogwangUsually, this function is not called directly from an
3951eaf0ac3Slogwangapplication, but is used indirectly via
3961eaf0ac3Slogwang.Fn login_getstyle .
3971eaf0ac3Slogwang.It Fn login_getpath
3981eaf0ac3SlogwangThis function returns a list of directories separated by colons
3991eaf0ac3Slogwang.Ql \&: .
4001eaf0ac3SlogwangCapability tags for which this function is called consist of a list of
4011eaf0ac3Slogwangdirectories separated by spaces.
4021eaf0ac3Slogwang.It Fn login_getcaptime
4031eaf0ac3SlogwangThis function returns a
4041eaf0ac3Slogwang.Vt time value
4051eaf0ac3Slogwangassociated with a particular capability tag with the value expressed
4061eaf0ac3Slogwangin seconds (the default), minutes, hours, days, weeks or (365 day)
4071eaf0ac3Slogwangyears or any combination of these.
4081eaf0ac3SlogwangA suffix determines the units used:
4091eaf0ac3Slogwang.Ql S
4101eaf0ac3Slogwangfor seconds,
4111eaf0ac3Slogwang.Ql M
4121eaf0ac3Slogwangfor minutes,
4131eaf0ac3Slogwang.Ql H
4141eaf0ac3Slogwangfor hours,
4151eaf0ac3Slogwang.Ql D
4161eaf0ac3Slogwangfor days,
4171eaf0ac3Slogwang.Ql W
4181eaf0ac3Slogwangfor weeks and
4191eaf0ac3Slogwang.Ql Y
4201eaf0ac3Slogwangfor 365 day years.
4211eaf0ac3SlogwangCase of the units suffix is ignored.
4221eaf0ac3Slogwang.Pp
4231eaf0ac3SlogwangTime values are normally used for setting resource, accounting and
4241eaf0ac3Slogwangsession limits.
4251eaf0ac3SlogwangIf supported by the operating system and compiler (which is true of
4261eaf0ac3Slogwang.Fx ) ,
4271eaf0ac3Slogwangthe value returned is a
4281eaf0ac3Slogwang.Vt quad
4291eaf0ac3Slogwang.Pq Vt long long ,
4301eaf0ac3Slogwangof type
4311eaf0ac3Slogwang.Vt rlim_t .
4321eaf0ac3SlogwangA value
4331eaf0ac3Slogwang.Ql inf
4341eaf0ac3Slogwangor
4351eaf0ac3Slogwang.Ql infinity
4361eaf0ac3Slogwangmay be used to express an infinite
4371eaf0ac3Slogwangvalue, in which case
4381eaf0ac3Slogwang.Dv RLIM_INFINITY
4391eaf0ac3Slogwangis returned.
4401eaf0ac3Slogwang.It Fn login_getcapnum
4411eaf0ac3SlogwangThis function returns a numeric value for a tag, expressed either as
4421eaf0ac3Slogwang.Ql tag=<value>
4431eaf0ac3Slogwangor the standard
4441eaf0ac3Slogwang.Fn cgetnum
4451eaf0ac3Slogwangformat
4461eaf0ac3Slogwang.Ql tag#<value> .
4471eaf0ac3SlogwangThe first format should be used in preference to the second, the
4481eaf0ac3Slogwangsecond format is provided for compatibility and consistency with the
4491eaf0ac3Slogwang.Xr getcap 3
4501eaf0ac3Slogwangdatabase format where numeric types use the
4511eaf0ac3Slogwang.Ql \&#
4521eaf0ac3Slogwangas the delimiter for numeric values.
4531eaf0ac3SlogwangIf in the first format, then the value given may be
4541eaf0ac3Slogwang.Ql inf
4551eaf0ac3Slogwangor
4561eaf0ac3Slogwang.Ql infinity
4571eaf0ac3Slogwangwhich results in a return value of
4581eaf0ac3Slogwang.Dv RLIM_INFINITY .
4591eaf0ac3SlogwangIf the given capability tag cannot be found, the
4601eaf0ac3Slogwang.Fa def
4611eaf0ac3Slogwangparameter is returned, and if an error occurs, the
4621eaf0ac3Slogwang.Fa error
4631eaf0ac3Slogwangparameter is returned.
4641eaf0ac3Slogwang.It Fn login_getcapsize
4651eaf0ac3Slogwang.Fn login_getcapsize
4661eaf0ac3Slogwangreturns a value representing a size (typically, file or memory)
4671eaf0ac3Slogwangwhich may be expressed as bytes (the default), 512 byte blocks,
4681eaf0ac3Slogwangkilobytes, megabytes, gigabytes, and on systems that support the
4691eaf0ac3Slogwang.Vt long long
4701eaf0ac3Slogwangtype, terabytes.
4711eaf0ac3SlogwangThe suffix used determines the units, and multiple values and
4721eaf0ac3Slogwangunits may be used in combination (e.g.\& 1m500k = 1.5 megabytes).
4731eaf0ac3SlogwangA value with no suffix is interpreted as bytes,
4741eaf0ac3Slogwang.Ql B
4751eaf0ac3Slogwangas 512-byte blocks,
4761eaf0ac3Slogwang.Ql K
4771eaf0ac3Slogwangas kilobytes,
4781eaf0ac3Slogwang.Ql M
4791eaf0ac3Slogwangas megabytes,
4801eaf0ac3Slogwang.Ql G
4811eaf0ac3Slogwangas gigabytes and
4821eaf0ac3Slogwang.Ql T
4831eaf0ac3Slogwangas terabytes.
4841eaf0ac3SlogwangCase is ignored.
4851eaf0ac3SlogwangThe error value is returned if there is a login capabilities database
4861eaf0ac3Slogwangerror, if an invalid suffix is used, or if a numeric value cannot be
4871eaf0ac3Slogwanginterpreted.
4881eaf0ac3Slogwang.It Fn login_getcapbool
4891eaf0ac3SlogwangThis function returns a boolean value tied to a particular flag.
4901eaf0ac3SlogwangIt returns 0 if the given capability tag is not present or is
4911eaf0ac3Slogwangnegated by the presence of a
4921eaf0ac3Slogwang.Ql tag@
4931eaf0ac3Slogwang(see
4941eaf0ac3Slogwang.Xr getcap 3
4951eaf0ac3Slogwangfor more information on boolean flags), and returns 1 if the tag
4961eaf0ac3Slogwangis found.
4971eaf0ac3Slogwang.It Fn login_getstyle
4981eaf0ac3SlogwangThis function is used by the login authorisation system to determine
4991eaf0ac3Slogwangthe style of login available in a particular case.
5001eaf0ac3SlogwangThe function accepts three parameters, the
5011eaf0ac3Slogwang.Fa lc
5021eaf0ac3Slogwangentry itself and
5031eaf0ac3Slogwangtwo optional parameters, and authorisation type
5041eaf0ac3Slogwang.Fa auth
5051eaf0ac3Slogwangand
5061eaf0ac3Slogwang.Fa style ,
5071eaf0ac3Slogwangand
5081eaf0ac3Slogwangapplies these to determine the authorisation style that best suites
5091eaf0ac3Slogwangthese rules.
5101eaf0ac3Slogwang.Bl -bullet
5111eaf0ac3Slogwang.It
5121eaf0ac3SlogwangIf
5131eaf0ac3Slogwang.Fa auth
5141eaf0ac3Slogwangis neither
5151eaf0ac3Slogwang.Dv NULL
5161eaf0ac3Slogwangnor an empty string, look for a tag of type
5171eaf0ac3Slogwang.Ql auth- Ns Fa <auth>
5181eaf0ac3Slogwangin the capability record.
5191eaf0ac3SlogwangIf not present, then look for the default tag
5201eaf0ac3Slogwang.Va auth= .
5211eaf0ac3Slogwang.It
5221eaf0ac3SlogwangIf no valid authorisation list was found from the previous step, then
5231eaf0ac3Slogwangdefault to
5241eaf0ac3Slogwang.Ql passwd
5251eaf0ac3Slogwangas the authorisation list.
5261eaf0ac3Slogwang.It
5271eaf0ac3SlogwangIf
5281eaf0ac3Slogwang.Fa style
5291eaf0ac3Slogwangis not
5301eaf0ac3Slogwang.Dv NULL
5311eaf0ac3Slogwangor empty, look for it in the list of authorisation
5321eaf0ac3Slogwangmethods found from the previous step.
5331eaf0ac3SlogwangIf
5341eaf0ac3Slogwang.Fa style
5351eaf0ac3Slogwangis
5361eaf0ac3Slogwang.Dv NULL
5371eaf0ac3Slogwangor an empty string, then default to
5381eaf0ac3Slogwang.Ql passwd
5391eaf0ac3Slogwangauthorisation.
5401eaf0ac3Slogwang.It
5411eaf0ac3SlogwangIf
5421eaf0ac3Slogwang.Fa style
5431eaf0ac3Slogwangis found in the chosen list of authorisation methods, then
5441eaf0ac3Slogwangreturn that, otherwise return
5451eaf0ac3Slogwang.Dv NULL .
5461eaf0ac3Slogwang.El
5471eaf0ac3Slogwang.Pp
5481eaf0ac3SlogwangThis scheme allows the administrator to determine the types of
5491eaf0ac3Slogwangauthorisation methods accepted by the system, depending on the
5501eaf0ac3Slogwangmeans by which the access occurs.
5511eaf0ac3SlogwangFor example, the administrator may require skey or kerberos as
5521eaf0ac3Slogwangthe authentication method used for access to the system via the
5531eaf0ac3Slogwangnetwork, and standard methods via direct dialup or console
5541eaf0ac3Slogwanglogins, significantly reducing the risk of password discovery
5551eaf0ac3Slogwangby "snooping" network packets.
5561eaf0ac3Slogwang.It Fn login_setcryptfmt
5571eaf0ac3SlogwangThe
5581eaf0ac3Slogwang.Fn login_setcryptfmt
5591eaf0ac3Slogwangfunction is used to set the
5601eaf0ac3Slogwang.Xr crypt 3
5611eaf0ac3Slogwangformat using the
5621eaf0ac3Slogwang.Va passwd_format
5631eaf0ac3Slogwangconfiguration entry.
5641eaf0ac3SlogwangIf no entry is found,
5651eaf0ac3Slogwang.Fa def
5661eaf0ac3Slogwangis taken to be used as the fallback.
5671eaf0ac3SlogwangIf calling
5681eaf0ac3Slogwang.Xr crypt_set_format 3
5691eaf0ac3Slogwangon the specifier fails,
5701eaf0ac3Slogwang.Fa error
5711eaf0ac3Slogwangis returned to indicate this.
5721eaf0ac3Slogwang.El
5731eaf0ac3Slogwang.Sh SEE ALSO
5741eaf0ac3Slogwang.Xr login 1 ,
5751eaf0ac3Slogwang.Xr crypt 3 ,
5761eaf0ac3Slogwang.Xr getcap 3 ,
5771eaf0ac3Slogwang.Xr login_class 3 ,
5781eaf0ac3Slogwang.Xr login.conf 5 ,
5791eaf0ac3Slogwang.Xr termcap 5
580*22ce4affSfengbojiang.Sh HISTORY
581*22ce4affSfengbojiangThe functions
582*22ce4affSfengbojiang.Fn login_close ,
583*22ce4affSfengbojiang.Fn login_getcapbool ,
584*22ce4affSfengbojiang.Fn login_getcaplist ,
585*22ce4affSfengbojiang.Fn login_getcapnum ,
586*22ce4affSfengbojiang.Fn login_getcapstr ,
587*22ce4affSfengbojiang.Fn login_getcapsize ,
588*22ce4affSfengbojiang.Fn login_getcaptime ,
589*22ce4affSfengbojiang.Fn login_getclass ,
590*22ce4affSfengbojiang.Fn login_getclassbyname ,
591*22ce4affSfengbojiang.Fn login_getpwclass ,
592*22ce4affSfengbojiang.Fn login_getstyle ,
593*22ce4affSfengbojiang.Fn login_getuserclass
594*22ce4affSfengbojiangand
595*22ce4affSfengbojiang.Fn login_setcryptfmt
596*22ce4affSfengbojiangfirst appeared in
597*22ce4affSfengbojiang.Fx 2.1.5 .
598