1.\" $NetBSD: pwcache.3,v 1.9 1998/07/28 17:09:10 mycroft Exp $ 2.\" 3.\" Copyright (c) 1989, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)pwcache.3 8.1 (Berkeley) 6/9/93 35.\" 36.Dd July 28, 1998 37.Dt PWCACHE 3 38.Os 39.Sh NAME 40.Nm pwcache , 41.Nm user_from_uid , 42.Nm group_from_gid 43.Nd cache password and group entries 44.Sh LIBRARY 45.Lb libc 46.Sh SYNOPSIS 47.Fd #include <pwd.h> 48.Ft const char * 49.Fn user_from_uid "uid_t uid" "int nouser" 50.Ft int 51.Fn uid_from_user "const char *name" "uid_t *uid" 52.Fd #include <grp.h> 53.Ft const char * 54.Fn group_from_gid "gid_t gid" "int nogroup" 55.Ft int 56.Fn gid_from_group "const char *name" "gid_t *gid" 57.Sh DESCRIPTION 58The 59.Fn user_from_uid 60function returns the user name associated with the argument 61.Fa uid . 62The user name is cached so that multiple calls with the same 63.Fa uid 64do not require additional calls to 65.Xr getpwuid 3 . 66If there is no user associated with the 67.Fa uid , 68a pointer is returned 69to a string representation of the 70.Fa uid , 71unless the argument 72.Fa nouser 73is non-zero, in which case a 74.Dv NULL 75pointer is returned. 76.Pp 77The 78.Fn group_from_gid 79function returns the group name associated with the argument 80.Fa gid . 81The group name is cached so that multiple calls with the same 82.Fa gid 83do not require additional calls to 84.Xr getgrgid 3 . 85If there is no group associated with the 86.Fa gid , 87a pointer is returned 88to a string representation of the 89.Fa gid , 90unless the argument 91.Fa nogroup 92is non-zero, in which case a 93.Dv NULL 94pointer is returned. 95.Pp 96The 97.Fn uid_from_user 98function returns the uid associated with the argument 99.Fa name . 100The uid is cached so that multiple calls with the same 101.Fa name 102do not require additional calls to 103.Xr getpwnam 3 . 104If there is no uid associated with the 105.Fa name , 106the 107.Fn uid_from_user 108function returns -1; otherwise it stores the uid at the location pointed to by 109.Fa uid 110and returns 0. 111.Pp 112The 113.Fn gid_from_group 114function returns the gid associated with the argument 115.Fa name . 116The gid is cached so that multiple calls with the same 117.Fa name 118do not require additional calls to 119.Xr getgrnam 3 . 120If there is no gid associated with the 121.Fa name , 122the 123.Fn gid_from_group 124function returns -1; otherwise it stores the gid at the location pointed to by 125.Fa gid 126and returns 0. 127.Sh SEE ALSO 128.Xr getgrgid 3 , 129.Xr getgrnam 3 , 130.Xr getpwnam 3 , 131.Xr getpwuid 3 132.Sh HISTORY 133The 134.Fn user_from_uid 135and 136.Fn group_from_gid 137functions first appeared in 138.Bx 4.4 . 139.Pp 140The 141.Fn uid_from_user 142and 143.Fn gid_from_group 144functions first appeared in 145.Nx 1.4 . 146