1 '\" te
   2 .\" Copyright (c) 2005, Sun Microsystems, Inc.  All Rights Reserved.
   3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
   4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
   5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
   6 .TH GETUSERATTR 3SECDB "Aug 13, 2018"
   7 .SH NAME
   8 getuserattr, getusernam, getuseruid, free_userattr, setuserattr, enduserattr,
   9 fgetuserattr \- get user_attr entry
  10 .SH SYNOPSIS
  11 .LP
  12 .nf
  13 cc [ \fIflag\fR... ] \fIfile\fR... -lsecdb  -lsocket  -lnsl [ \fIlibrary\fR... ]
  14 #include <user_attr.h>
  15 
  16 \fBuserattr_t *\fR\fBgetuserattr\fR(\fBvoid\fR);
  17 .fi
  18 
  19 .LP
  20 .nf
  21 \fBuserattr_t *\fR\fBgetusernam\fR(\fBconst char *\fR\fI\fR\fIname\fR);
  22 .fi
  23 
  24 .LP
  25 .nf
  26 \fBuserattr_t *\fR\fBgetuseruid\fR(\fBuid_t\fR \fIuid\fR);
  27 .fi
  28 
  29 .LP
  30 .nf
  31 \fBvoid\fR \fBfree_userattr\fR(\fBuserattr_t *\fR\fIuserattr\fR);
  32 .fi
  33 
  34 .LP
  35 .nf
  36 \fBvoid\fR \fBsetuserattr\fR(\fBvoid\fR);
  37 .fi
  38 
  39 .LP
  40 .nf
  41 \fBvoid\fR \fBenduserattr\fR(\fBvoid\fR);
  42 .fi
  43 
  44 .LP
  45 .nf
  46 \fBuserattr_t *\fR\fBfgetuserattr\fR(\fBFILE *\fR\fIf\fR);
  47 .fi
  48 
  49 .SH DESCRIPTION
  50 .LP
  51 The \fBgetuserattr()\fR, \fBgetusernam()\fR, and \fBgetuseruid()\fR functions
  52 each return a \fBuser_attr\fR(4) entry. Entries can come from any of the
  53 sources specified in the \fBnsswitch.conf\fR(4) file. The \fBgetuserattr()\fR
  54 function enumerates \fBuser_attr\fR entries. The \fBgetusernam()\fR function
  55 searches for a \fBuser_attr\fR entry with a given user name \fIname\fR. The
  56 \fBgetuseruid()\fR function searches for a \fBuser_attr\fR entry with a given
  57 user ID \fIuid\fR. Successive calls to these functions return either successive
  58 \fBuser_attr\fR entries or \fINULL\fR.
  59 .sp
  60 .LP
  61 The \fBfgetuserattr()\fR function does not use \fBnsswitch.conf\fR but reads
  62 and parses the next line from the stream \fIf\fR. This stream is assumed to
  63 have the format of the \fBuser_attr\fR files.
  64 .sp
  65 .LP
  66 The \fBfree_userattr()\fR function releases memory allocated by the
  67 \fBgetusernam()\fR, \fBgetuserattr()\fR, and \fBfgetuserattr()\fR functions.
  68 .sp
  69 .LP
  70 The internal representation of a \fBuser_attr\fR entry is a \fBuserattr_t\fR
  71 structure defined in <\fBuser_attr.h\fR> with the following members:
  72 .sp
  73 .in +2
  74 .nf
  75 char  *name;       /* name of the user */
  76 char  *qualifier;  /* reserved for future use */
  77 char  *res1;       /* reserved for future use */
  78 char  *res2;       /* reserved for future use */
  79 kva_t *attr;       /* list of attributes */
  80 .fi
  81 .in -2
  82 
  83 .sp
  84 .LP
  85 The \fBsetuserattr()\fR function "rewinds" to the beginning of the enumeration
  86 of \fBuser_attr\fR entries.  Calls to \fBgetusernam()\fR may leave the
  87 enumeration in an indeterminate state, so \fBsetuserattr()\fR should be called
  88 before the first call to \fBgetuserattr()\fR.
  89 .sp
  90 .LP
  91 The \fBenduserattr()\fR function may be called to indicate that \fBuser_attr\fR
  92 processing is complete; the library may then close any open \fBuser_attr\fR
  93 file, deallocate any internal storage, and so forth.
  94 .SH RETURN VALUES
  95 .LP
  96 The \fBgetuserattr()\fR function returns a pointer to a \fBuserattr_t\fR if it
  97 successfully enumerates an entry; otherwise it returns \fINULL\fR, indicating
  98 the end of the enumeration.
  99 .sp
 100 .LP
 101 The \fBgetusernam()\fR function returns a pointer to a \fBuserattr_t\fR if it
 102 successfully locates the requested entry; otherwise it returns \fINULL\fR.
 103 .SH USAGE
 104 .LP
 105 The \fBgetuserattr()\fR and \fBgetusernam()\fR functions both allocate memory
 106 for the pointers they return. This memory should be deallocated with the
 107 \fBfree_userattr()\fR function.
 108 .sp
 109 .LP
 110 Individual attributes can be referenced in the \fBattr\fR structure by calling
 111 the \fBkva_match\fR(3SECDB) function.
 112 .SH WARNINGS
 113 .LP
 114 Because the list of legal keys is likely to expand, code must be written to
 115 ignore unknown key-value pairs without error.
 116 .SH FILES
 117 .ne 2
 118 .na
 119 \fB\fB/etc/user_attr\fR\fR
 120 .ad
 121 .RS 22n
 122 extended user attributes
 123 .RE
 124 
 125 .sp
 126 .ne 2
 127 .na
 128 \fB\fB/etc/nsswitch.conf\fR\fR
 129 .ad
 130 .RS 22n
 131 configuration file lookup information for the name service switch
 132 .RE
 133 
 134 .SH ATTRIBUTES
 135 .LP
 136 See \fBattributes\fR(5) for descriptions of the following attributes:
 137 .sp
 138 
 139 .sp
 140 .TS
 141 box;
 142 c | c
 143 l | l .
 144 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 145 _
 146 MT-Level        MT-Safe
 147 .TE
 148 
 149 .SH SEE ALSO
 150 .LP
 151 \fBgetauthattr\fR(3SECDB), \fBgetexecattr\fR(3SECDB),
 152 \fBgetprofattr\fR(3SECDB), \fBkva_match\fR(3SECDB), \fBuser_attr\fR(4),
 153 \fBattributes\fR(5)