1 /* Get public or secret key from key server.
2 Copyright (C) 1996-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
21 #include <rpc/netdb.h>
22 #include <rpc/auth_des.h>
27 /* Type of the lookup function for the public key. */
28 typedef int (*public_function
) (const char *, char *, int *);
30 /* Type of the lookup function for the secret key. */
31 typedef int (*secret_function
) (const char *, char *, const char *, int *);
33 /* The lookup function for the first entry of this service. */
34 extern int __nss_publickey_lookup (service_user
**nip
, const char *name
,
35 void **fctp
) internal_function
;
39 getpublickey (const char *name
, char *key
)
41 static service_user
*startp
;
42 static public_function start_fct
;
49 enum nss_status status
= NSS_STATUS_UNAVAIL
;
54 no_more
= __nss_publickey_lookup (&nip
, "getpublickey", &fct
.ptr
);
56 startp
= (service_user
*) -1;
66 no_more
= (nip
= startp
) == (service_user
*) -1;
71 status
= (*fct
.f
) (name
, key
, &errno
);
73 no_more
= __nss_next2 (&nip
, "getpublickey", NULL
, &fct
.ptr
, status
, 0);
76 return status
== NSS_STATUS_SUCCESS
;
78 libc_hidden_nolink_sunrpc (getpublickey
, GLIBC_2_0
)
82 getsecretkey (const char *name
, char *key
, const char *passwd
)
84 static service_user
*startp
;
85 static secret_function start_fct
;
92 enum nss_status status
= NSS_STATUS_UNAVAIL
;
97 no_more
= __nss_publickey_lookup (&nip
, "getsecretkey", &fct
.ptr
);
99 startp
= (service_user
*) -1;
109 no_more
= (nip
= startp
) == (service_user
*) -1;
114 status
= (*fct
.f
) (name
, key
, passwd
, &errno
);
116 no_more
= __nss_next2 (&nip
, "getsecretkey", NULL
, &fct
.ptr
, status
, 0);
119 return status
== NSS_STATUS_SUCCESS
;
121 libc_hidden_nolink_sunrpc (getsecretkey
, GLIBC_2_0
)