4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2018 Peter Tribble.
24 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
32 #include <user_attr.h>
36 putuserattr(const userattr_t
*user
, FILE *fp
)
45 if (fprintf(fp
, "%s:%s:%s:%s:",
46 user
->name
!= NULL
? user
->name
: "",
47 user
->qualifier
!= NULL
? user
->res1
: "",
48 user
->res1
!= NULL
? user
->res1
: "",
49 user
->res2
!= NULL
? user
->res2
: "") == EOF
)
54 for (i
= 0; i
< attrs
->length
; i
++) {
55 if (fprintf(fp
, "%s=%s%s",
56 data
[i
].key
!= NULL
? data
[i
].key
: "",
57 data
[i
].value
!= NULL
? data
[i
].value
: "",
58 i
< (attrs
->length
)-1 ? ";" : "") == EOF
)
62 if (putc('\n', fp
) == EOF
)
68 dogetuserattr(const char **list
)
76 if (list
== NULL
|| *list
== NULL
) {
78 while ((puser
= getuserattr()) != NULL
)
79 (void) putuserattr(puser
, stdout
);
82 for (; *list
!= NULL
; list
++) {
83 uid
= strtoul(*list
, &ptr
, 10);
84 if (*ptr
== '\0' && errno
== 0) {
85 if ((pwp
= getpwuid(uid
)) == NULL
) {
86 puser
= getusernam(*list
);
88 puser
= getusernam(pwp
->pw_name
);
91 puser
= getusernam(*list
);
94 rc
= EXC_NAME_NOT_FOUND
;
96 (void) putuserattr(puser
, stdout
);