4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
35 #include <sys/types.h>
37 boolean_t verbose
= B_FALSE
;
38 char *attr_name
= NULL
;
40 #if !defined(TEXT_DOMAIN)
41 #define TEXT_DOMAIN "SYS_TEST"
42 #endif /* !TEXT_DOMAIN */
45 * userattr [-v] attr_name [user]
50 attr(const char *name
, kva_t
*kva
, void *ctxt
, void *pres
)
54 if ((val
= kva_match(kva
, attr_name
)) != NULL
) {
56 char *prof_name
= "user_attr";
59 prof_name
= (char *)name
;
61 (void) printf("%s : %s\n", prof_name
, val
);
63 (void) printf("%s\n", val
);
68 return (0); /* no match */
72 main(int argc
, char *argv
[])
78 (void) setlocale(LC_ALL
, "");
79 (void) textdomain(TEXT_DOMAIN
);
82 (strncmp(argv
[opt
], "-v", sizeof ("-v")) == 0)) {
88 attr_name
= argv
[opt
++];
94 if ((attr_name
== NULL
) || (opt
< argc
)) {
95 (void) fprintf(stderr
,
96 gettext("Usage: %s [-v] attribute_name [user]\n"), argv
[0]);
101 uid_t uid
= getuid();
103 if ((pwd
= getpwuid(uid
)) == NULL
) {
104 (void) fprintf(stderr
,
105 gettext("Cannot find user for uid %d\n"), uid
);
110 if ((pwd
= getpwnam(user
)) == NULL
) {
111 (void) fprintf(stderr
,
112 gettext("No such user %s\n"), user
);
117 (void) _enum_attrs(user
, attr
, NULL
, NULL
);
120 (void) fprintf(stderr
,
121 gettext("attribute \"%s\" not found for %s\n"), attr_name
,