xref: /minix3/lib/libutil/login_cap.3 (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc.\" $NetBSD: login_cap.3,v 1.21 2013/06/23 08:38:41 wiz Exp $
20c3983b2SBen Gras.\"
30c3983b2SBen Gras.\" Copyright (c) 1996,1997 Berkeley Software Design, Inc. All rights reserved.
40c3983b2SBen Gras.\"
50c3983b2SBen Gras.\" Redistribution and use in source and binary forms, with or without
60c3983b2SBen Gras.\" modification, are permitted provided that the following conditions
70c3983b2SBen Gras.\" are met:
80c3983b2SBen Gras.\" 1. Redistributions of source code must retain the above copyright
90c3983b2SBen Gras.\"    notice, this list of conditions and the following disclaimer.
100c3983b2SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
110c3983b2SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
120c3983b2SBen Gras.\"    documentation and/or other materials provided with the distribution.
130c3983b2SBen Gras.\" 3. All advertising materials mentioning features or use of this software
140c3983b2SBen Gras.\"    must display the following acknowledgement:
150c3983b2SBen Gras.\"	This product includes software developed by Berkeley Software Design,
160c3983b2SBen Gras.\"	Inc.
170c3983b2SBen Gras.\" 4. The name of Berkeley Software Design, Inc.  may not be used to endorse
180c3983b2SBen Gras.\"    or promote products derived from this software without specific prior
190c3983b2SBen Gras.\"    written permission.
200c3983b2SBen Gras.\"
210c3983b2SBen Gras.\" THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
220c3983b2SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
230c3983b2SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
240c3983b2SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
250c3983b2SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
260c3983b2SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
270c3983b2SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
280c3983b2SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
290c3983b2SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
300c3983b2SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
310c3983b2SBen Gras.\" SUCH DAMAGE.
320c3983b2SBen Gras.\"
330c3983b2SBen Gras.\" BSDI login_cap.3,v 1.4 1997/11/07 16:22:27 jch Exp
340c3983b2SBen Gras.\"
35*84d9c625SLionel Sambuc.Dd June 20, 2013
360c3983b2SBen Gras.Dt LOGIN_CAP 3
370c3983b2SBen Gras.Os
380c3983b2SBen Gras.Sh NAME
390c3983b2SBen Gras.Nm login_getclass ,
400c3983b2SBen Gras.Nm login_getcapbool ,
410c3983b2SBen Gras.Nm login_getcapnum ,
420c3983b2SBen Gras.Nm login_getcapsize ,
430c3983b2SBen Gras.Nm login_getcapstr ,
440c3983b2SBen Gras.Nm login_getcaptime ,
45*84d9c625SLionel Sambuc.Nm login_getpwclass ,
460c3983b2SBen Gras.Nm login_close ,
470c3983b2SBen Gras.Nm setclasscontext ,
480c3983b2SBen Gras.Nm setusercontext
490c3983b2SBen Gras.Nd query login.conf database about a user class
500c3983b2SBen Gras.Sh LIBRARY
510c3983b2SBen Gras.Lb libutil
520c3983b2SBen Gras.Sh SYNOPSIS
530c3983b2SBen Gras.In sys/types.h
540c3983b2SBen Gras.In login_cap.h
550c3983b2SBen Gras.Ft login_cap_t *
560c3983b2SBen Gras.Fn login_getclass "char *class"
570c3983b2SBen Gras.Ft int
580c3983b2SBen Gras.Fn login_getcapbool "login_cap_t *lc" "const char *cap" "u_int def"
590c3983b2SBen Gras.Ft quad_t
600c3983b2SBen Gras.Fn login_getcapnum "login_cap_t *lc" "const char *cap" "quad_t def" "quad_t err"
610c3983b2SBen Gras.Ft quad_t
620c3983b2SBen Gras.Fn login_getcapsize "login_cap_t *lc" "const char *cap" "quad_t def" "quad_t err"
630c3983b2SBen Gras.Ft char *
640c3983b2SBen Gras.Fn login_getcapstr "login_cap_t *lc" "const char *cap" "char *def" "char *err"
650c3983b2SBen Gras.Ft quad_t
660c3983b2SBen Gras.Fn login_getcaptime "login_cap_t *lc" "const char *cap" "quad_t def" "quad_t err"
67*84d9c625SLionel Sambuc.Ft login_cap_t *
68*84d9c625SLionel Sambuc.Fn login_getpwclass "struct passwd *pwd"
690c3983b2SBen Gras.Ft void
700c3983b2SBen Gras.Fn login_close "login_cap_t *lc"
710c3983b2SBen Gras.Ft int
720c3983b2SBen Gras.Fn setclasscontext "const char *class" "u_int flags"
730c3983b2SBen Gras.Ft int
740c3983b2SBen Gras.Fn setusercontext "login_cap_t *lc" "const struct passwd *pwd" "uid_t uid" "u_int flags"
750c3983b2SBen Gras.Sh DESCRIPTION
760c3983b2SBen GrasThe
770c3983b2SBen Gras.Fn login_getclass
780c3983b2SBen Grasfunction extracts the entry specified by
790c3983b2SBen Gras.Ar class
800c3983b2SBen Gras(or
810c3983b2SBen Gras.Li default
820c3983b2SBen Grasif
830c3983b2SBen Gras.Ar class
840c3983b2SBen Grasis
850c3983b2SBen Gras.Dv NULL
860c3983b2SBen Grasor the empty string)
870c3983b2SBen Grasfrom
880c3983b2SBen Gras.Pa /etc/login.conf
890c3983b2SBen Gras(see
900c3983b2SBen Gras.Xr login.conf 5 ) .
910c3983b2SBen GrasIf the entry is found, a
920c3983b2SBen Gras.Li login_cap_t
930c3983b2SBen Graspointer is returned.
940c3983b2SBen Gras.Dv NULL
950c3983b2SBen Grasis returned if the user class is not found.
960c3983b2SBen GrasWhen the
970c3983b2SBen Gras.Li login_cap_t
980c3983b2SBen Grasstructure is no longer needed, it should be freed by the
990c3983b2SBen Gras.Fn login_close
1000c3983b2SBen Grasfunction.
1010c3983b2SBen Gras.Pp
102*84d9c625SLionel SambucThe
103*84d9c625SLionel Sambuc.Fn login_getpwclass
104*84d9c625SLionel Sambucfunction is equivalent to:
105*84d9c625SLionel Sambuc.Dl login_getclass(pwd\ ? pwd->pw_class\ : NULL)
106*84d9c625SLionel Sambuc.Pp
1070c3983b2SBen GrasOnce
1080c3983b2SBen Gras.Ar lc
1090c3983b2SBen Grashas been returned by
1100c3983b2SBen Gras.Fn login_getclass ,
1110c3983b2SBen Grasany of the other
1120c3983b2SBen Gras.Fn login_*
1130c3983b2SBen Grasfunctions may be called.
1140c3983b2SBen Gras.Pp
1150c3983b2SBen GrasThe
1160c3983b2SBen Gras.Fn login_getcapnum ,
1170c3983b2SBen Gras.Fn login_getcapsize ,
1180c3983b2SBen Gras.Fn login_getcapstr ,
1190c3983b2SBen Grasand
1200c3983b2SBen Gras.Fn login_getcaptime
1210c3983b2SBen Grasfunctions all query the database entry for a field named
1220c3983b2SBen Gras.Ar cap .
1230c3983b2SBen GrasIf the field is found, its value is returned.
1240c3983b2SBen GrasIf the field is not found, the value specified by
1250c3983b2SBen Gras.Ar def
1260c3983b2SBen Grasis returned.
1270c3983b2SBen GrasIf an error is encountered while trying to find the field,
1280c3983b2SBen Gras.Ar err
1290c3983b2SBen Grasis returned.
1300c3983b2SBen GrasSee
1310c3983b2SBen Gras.Xr login.conf 5
1320c3983b2SBen Grasfor a discussion of the various textual forms the value may take.
1330c3983b2SBen GrasThe
1340c3983b2SBen Gras.Fn login_getcapbool
1350c3983b2SBen Grasfunction is slightly different.
1360c3983b2SBen GrasIt returns
1370c3983b2SBen Gras.Ar def
1380c3983b2SBen Grasif no capabilities were found for this class (typically meaning that
1390c3983b2SBen Grasthe default class was used and the
1400c3983b2SBen Gras.Li /etc/login.conf
1410c3983b2SBen Grasfile is missing).
1420c3983b2SBen GrasIt returns a non-zero value if
1430c3983b2SBen Gras.Ar cap ,
1440c3983b2SBen Graswith no value, was found,
1450c3983b2SBen Graszero otherwise.
1460c3983b2SBen Gras.Pp
1470c3983b2SBen GrasThe
1480c3983b2SBen Gras.Fn setclasscontext
1490c3983b2SBen Grasfunction takes
1500c3983b2SBen Gras.Ar class ,
1510c3983b2SBen Grasthe name of a user class,
1520c3983b2SBen Grasand sets the resources defined by that class according to
1530c3983b2SBen Gras.Ar flags .
1540c3983b2SBen GrasOnly the
1550c3983b2SBen Gras.Dv LOGIN_SETPATH ,
1560c3983b2SBen Gras.Dv LOGIN_SETPRIORITY ,
1570c3983b2SBen Gras.Dv LOGIN_SETRESOURCES ,
1580c3983b2SBen Grasand
1590c3983b2SBen Gras.Dv LOGIN_SETUMASK
1600c3983b2SBen Grasbits are used.
1610c3983b2SBen Gras(See
1620c3983b2SBen Gras.Fn setusercontext
1630c3983b2SBen Grasbelow).
1640c3983b2SBen GrasIt returns 0 on success and -1 on failure.
1650c3983b2SBen Gras.Pp
1660c3983b2SBen GrasThe
1670c3983b2SBen Gras.Fn setusercontext
1680c3983b2SBen Grasfunction
1690c3983b2SBen Grassets the resources according to
1700c3983b2SBen Gras.Ar flags .
1710c3983b2SBen GrasThe
1720c3983b2SBen Gras.Ar lc
1730c3983b2SBen Grasargument, if not
1740c3983b2SBen Gras.Dv NULL ,
1750c3983b2SBen Grascontains the class information that should
1760c3983b2SBen Grasbe used.
1770c3983b2SBen GrasThe
1780c3983b2SBen Gras.Ar pwd
1790c3983b2SBen Grasargument, if not
1800c3983b2SBen Gras.Dv NULL ,
1810c3983b2SBen Grasprovides information about the user.
1820c3983b2SBen GrasBoth
1830c3983b2SBen Gras.Ar lc
1840c3983b2SBen Grasand
1850c3983b2SBen Gras.Ar pwd
1860c3983b2SBen Grascannot be
1870c3983b2SBen Gras.Dv NULL .
1880c3983b2SBen GrasThe
1890c3983b2SBen Gras.Ar uid
1900c3983b2SBen Grasargument is used in place of the user id contained in the
1910c3983b2SBen Gras.Ar pwd
1920c3983b2SBen Grasstructure when calling
1930c3983b2SBen Gras.Xr setuid 2 .
1940c3983b2SBen GrasThe various bits available to be or-ed together to make up
1950c3983b2SBen Gras.Ar flags
1960c3983b2SBen Grasare:
1970c3983b2SBen Gras.Bl -tag -width LOGIN_SETRESOURCESXX
1980c3983b2SBen Gras.It LOGIN_SETGID
1990c3983b2SBen GrasSet the group id.
2000c3983b2SBen GrasRequires the
2010c3983b2SBen Gras.Ar pwd
2020c3983b2SBen Grasfield be specified.
2030c3983b2SBen Gras.It LOGIN_SETGROUPS
2040c3983b2SBen GrasSet the group membership list by calling
2050c3983b2SBen Gras.Xr initgroups 3 .
2060c3983b2SBen GrasRequires the
2070c3983b2SBen Gras.Ar pwd
2080c3983b2SBen Grasfield be specified.
2090c3983b2SBen Gras.It LOGIN_SETGROUP
2100c3983b2SBen GrasSet the group id and call
2110c3983b2SBen Gras.Xr initgroups 3 .
2120c3983b2SBen GrasRequires the
2130c3983b2SBen Gras.Ar pwd
2140c3983b2SBen Grasfield be specified.
2150c3983b2SBen Gras.It LOGIN_SETLOGIN
2160c3983b2SBen GrasSets the login name by
2170c3983b2SBen Gras.Xr setlogin 2 .
2180c3983b2SBen GrasRequires the
2190c3983b2SBen Gras.Ar pwd
2200c3983b2SBen Grasfield be specified.
2210c3983b2SBen Gras.It LOGIN_SETPATH
2220c3983b2SBen GrasSets the
2230c3983b2SBen Gras.Ev PATH
2240c3983b2SBen Grasenvironment variable.
2250c3983b2SBen Gras.It LOGIN_SETPRIORITY
2260c3983b2SBen GrasSets the priority by
2270c3983b2SBen Gras.Xr setpriority 2 .
2280c3983b2SBen Gras.It LOGIN_SETRESOURCES
2290c3983b2SBen GrasSets the various system resources by
2300c3983b2SBen Gras.Xr setrlimit 2 .
2310c3983b2SBen Gras.It LOGIN_SETUMASK
2320c3983b2SBen GrasSets the umask by
2330c3983b2SBen Gras.Xr umask 2 .
2340c3983b2SBen Gras.It LOGIN_SETUSER
2350c3983b2SBen GrasSets the user id to
2360c3983b2SBen Gras.Ar uid
2370c3983b2SBen Grasby
2380c3983b2SBen Gras.Xr setuid 2 .
2390c3983b2SBen Gras.It LOGIN_SETENV
2400c3983b2SBen GrasSets the environment variables as defined by the setenv keyword, by
2410c3983b2SBen Gras.Xr setenv 3 .
2420c3983b2SBen Gras.It LOGIN_SETALL
2430c3983b2SBen GrasSets all of the above.
2440c3983b2SBen Gras.El
2450c3983b2SBen Gras.Sh SEE ALSO
2460c3983b2SBen Gras.Xr setlogin 2 ,
2470c3983b2SBen Gras.Xr setpriority 2 ,
2480c3983b2SBen Gras.Xr setrlimit 2 ,
2490c3983b2SBen Gras.Xr setuid 2 ,
2500c3983b2SBen Gras.Xr umask 2 ,
2510c3983b2SBen Gras.Xr initgroups 3 ,
2520c3983b2SBen Gras.Xr secure_path 3 ,
2530c3983b2SBen Gras.Xr login.conf 5
2540c3983b2SBen Gras.Sh HISTORY
2550c3983b2SBen GrasThe
2560c3983b2SBen Gras.Nm
2570c3983b2SBen Grasfamily of functions are largely based on the
2580c3983b2SBen Gras.Bsx
2590c3983b2SBen Grasimplementation of same, and appeared in
2600c3983b2SBen Gras.Nx 1.5
2610c3983b2SBen Grasby kind permission.
2620c3983b2SBen Gras.Sh CAVEATS
2630c3983b2SBen GrasThe string returned by
2640c3983b2SBen Gras.Fn login_getcapstr
2650c3983b2SBen Grasis allocated via
2660c3983b2SBen Gras.Xr malloc 3
2670c3983b2SBen Graswhen the specified capability is present and thus it is the responsibility
2680c3983b2SBen Grasof the caller to
2690c3983b2SBen Gras.Fn free
2700c3983b2SBen Grasthis space.
2710c3983b2SBen GrasHowever, if the capability was not found or an error occurred and
2720c3983b2SBen Gras.Fa def
2730c3983b2SBen Grasor
2740c3983b2SBen Gras.Fa err
2750c3983b2SBen Gras(whichever is relevant) are
2760c3983b2SBen Gras.Pf non- Dv NULL
2770c3983b2SBen Grasthe returned value is simply what was passed in to
2780c3983b2SBen Gras.Fn login_getcapstr .
2790c3983b2SBen GrasTherefore it is not possible to blindly
2800c3983b2SBen Gras.Fn free
2810c3983b2SBen Grasthe return value without first checking it against
2820c3983b2SBen Gras.Fa def
2830c3983b2SBen Grasand
2840c3983b2SBen Gras.Fa err .
2850c3983b2SBen Gras.Pp
2860c3983b2SBen GrasThe same warnings set forth in
2870c3983b2SBen Gras.Xr setlogin 2
2880c3983b2SBen Grasapply to
2890c3983b2SBen Gras.Fn setusercontext
2900c3983b2SBen Graswhen the
2910c3983b2SBen Gras.Dv LOGIN_SETLOGIN
2920c3983b2SBen Grasflag is used.
2930c3983b2SBen GrasSpecifically, changing the login name affects all processes in the current
2940c3983b2SBen Grassession, not just the current process.
2950c3983b2SBen GrasSee
2960c3983b2SBen Gras.Xr setlogin 2
2970c3983b2SBen Grasfor more information.
298