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) 1999, 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/types.h>
33 #include <nss_dbdefs.h>
34 #include <auth_attr.h>
37 /* Externs from libnsl */
38 extern authstr_t
*_getauthnam(const char *, authstr_t
*, char *, int, int *);
39 extern authstr_t
*_getauthattr(authstr_t
*, char *, int, int *);
40 extern void _setauthattr();
41 extern void _endauthattr(void);
44 static authattr_t
*authstr2attr(authstr_t
*);
51 char buf
[NSS_BUFLEN_AUTHATTR
];
55 (void) memset(&auth
, 0, sizeof (authstr_t
));
56 tmp
= _getauthattr(&auth
, buf
, NSS_BUFLEN_AUTHATTR
, &err
);
57 return (authstr2attr(tmp
));
62 getauthnam(const char *name
)
65 char buf
[NSS_BUFLEN_AUTHATTR
];
70 return ((authattr_t
*)NULL
);
72 (void) memset(&auth
, 0, sizeof (authstr_t
));
73 tmp
= _getauthnam(name
, &auth
, buf
, NSS_BUFLEN_AUTHATTR
, &err
);
74 return (authstr2attr(tmp
));
93 free_authattr(authattr_t
*auth
)
99 free(auth
->short_desc
);
100 free(auth
->long_desc
);
101 _kva_free(auth
->attr
);
108 authstr2attr(authstr_t
*auth
)
113 return ((authattr_t
*)NULL
);
115 if ((newauth
= (authattr_t
*)malloc(sizeof (authattr_t
))) == NULL
)
116 return ((authattr_t
*)NULL
);
118 newauth
->name
= _do_unescape(auth
->name
);
119 newauth
->res1
= _do_unescape(auth
->res1
);
120 newauth
->res2
= _do_unescape(auth
->res2
);
121 newauth
->short_desc
= _do_unescape(auth
->short_desc
);
122 newauth
->long_desc
= _do_unescape(auth
->long_desc
);
123 newauth
->attr
= _str2kva(auth
->attr
, KV_ASSIGN
, KV_DELIMITER
);
130 print_authattr(authattr_t
*auth
)
132 extern void print_kva(kva_t
*);
133 char *empty
= "empty";
140 printf("name=%s\n", auth
->name
? auth
->name
: empty
);
141 printf("res1=%s\n", auth
->res1
? auth
->res1
: empty
);
142 printf("res2=%s\n", auth
->res2
? auth
->res2
: empty
);
143 printf("short_desc=%s\n", auth
->short_desc
? auth
->short_desc
: empty
);
144 printf("long_desc=%s\n", auth
->long_desc
? auth
->long_desc
: empty
);
146 print_kva(auth
->attr
);