diff options
author | 2015-09-11 12:42:47 +0000 | |
---|---|---|
committer | 2015-09-11 12:42:47 +0000 | |
commit | 7db392d8e5f02ded278a11c225bfe6e995d70fbc (patch) | |
tree | a809a88a8ee03aa85f378e26c3a019ef4fbf4b1e | |
parent | Syslog does not need the global list of TCP clients, libevent handles (diff) | |
download | wireguard-openbsd-7db392d8e5f02ded278a11c225bfe6e995d70fbc.tar.xz wireguard-openbsd-7db392d8e5f02ded278a11c225bfe6e995d70fbc.zip |
Put a private copy of the ypresp_allfn/ypresp_data interface into ypserv
(which uses it in a strange way..) thereby making it possible to static
the interface in libc.
ok guenther
-rw-r--r-- | lib/libc/Symbols.list | 2 | ||||
-rw-r--r-- | lib/libc/yp/yp_all.c | 5 | ||||
-rw-r--r-- | lib/libc/yp/ypinternal.h | 5 | ||||
-rw-r--r-- | usr.sbin/ypserv/common/yplib_host.c | 70 |
4 files changed, 68 insertions, 14 deletions
diff --git a/lib/libc/Symbols.list b/lib/libc/Symbols.list index 5f3c4b6ac6d..c5f9988e6e4 100644 --- a/lib/libc/Symbols.list +++ b/lib/libc/Symbols.list @@ -1687,5 +1687,3 @@ yperr_string ypprot_err _yp_check /* chpass, passwd, login_chpass */ yp_unbind /* passwd */ -ypresp_allfn /* ypserv */ -ypresp_data /* ypserv */ diff --git a/lib/libc/yp/yp_all.c b/lib/libc/yp/yp_all.c index 35398acafdc..24333d8016d 100644 --- a/lib/libc/yp/yp_all.c +++ b/lib/libc/yp/yp_all.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp_all.c,v 1.11 2015/01/16 16:48:51 deraadt Exp $ */ +/* $OpenBSD: yp_all.c,v 1.12 2015/09/11 12:42:47 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com> * All rights reserved. @@ -36,6 +36,9 @@ #include <rpcsvc/ypclnt.h> #include "ypinternal.h" +static int (*ypresp_allfn)(u_long, char *, int, char *, int, void *); +static void *ypresp_data; + bool_t xdr_ypresp_all_seq(XDR *xdrs, u_long *objp) { diff --git a/lib/libc/yp/ypinternal.h b/lib/libc/yp/ypinternal.h index 8767a830533..6eabf9153a1 100644 --- a/lib/libc/yp/ypinternal.h +++ b/lib/libc/yp/ypinternal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ypinternal.h,v 1.8 2015/01/14 23:36:16 deraadt Exp $ */ +/* $OpenBSD: ypinternal.h,v 1.9 2015/09/11 12:42:47 deraadt Exp $ */ /* * Copyright (c) 1992, 1993, 1996 Theo de Raadt <deraadt@theos.com> @@ -44,9 +44,6 @@ struct dom_binding { #define BINDINGDIR "/var/yp/binding" #define YPBINDLOCK "/var/run/ypbind.lock" -int (*ypresp_allfn)(u_long, char *, int, char *, int, void *); -void *ypresp_data; - extern struct dom_binding *_ypbindlist; extern char _yp_domain[HOST_NAME_MAX+1]; extern int _yplib_timeout; diff --git a/usr.sbin/ypserv/common/yplib_host.c b/usr.sbin/ypserv/common/yplib_host.c index ddd1b207622..4bea9869199 100644 --- a/usr.sbin/ypserv/common/yplib_host.c +++ b/usr.sbin/ypserv/common/yplib_host.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yplib_host.c,v 1.18 2015/01/16 06:40:22 deraadt Exp $ */ +/* $OpenBSD: yplib_host.c,v 1.19 2015/09/11 12:42:47 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com> @@ -44,9 +44,6 @@ #include <rpcsvc/ypclnt.h> #include "yplib_host.h" -extern int (*ypresp_allfn)(u_long, char *, int, char *, int, void *); -extern void *ypresp_data; - int _yplib_host_timeout = 10; CLIENT * @@ -237,6 +234,65 @@ yp_next_host(CLIENT *client, char *indomain, char *inmap, char *inkey, return r; } +int (*ypserv_ypresp_allfn)(u_long, char *, int, char *, int, void *); +void *ypserv_ypresp_data; + +bool_t +ypserv_xdr_ypresp_all_seq(XDR *xdrs, u_long *objp) +{ + struct ypresp_all out; + u_long status; + char *key, *val; + int size; + int done = 0; /* set to 1 when the user does not want more data */ + bool_t rc = TRUE; /* FALSE at the end of loop signals failure */ + + memset(&out, 0, sizeof out); + while (rc && !done) { + rc = FALSE; + if (!xdr_ypresp_all(xdrs, &out)) { + *objp = (u_long)YP_YPERR; + goto fail; + } + if (out.more == 0) + goto fail; + status = out.ypresp_all_u.val.stat; + if (status == YP_TRUE) { + size = out.ypresp_all_u.val.key.keydat_len; + if ((key = malloc(size + 1)) == NULL) { + *objp = (u_long)YP_YPERR; + goto fail; + } + (void)memcpy(key, out.ypresp_all_u.val.key.keydat_val, + size); + key[size] = '\0'; + + size = out.ypresp_all_u.val.val.valdat_len; + if ((val = malloc(size + 1)) == NULL) { + free(key); + *objp = (u_long)YP_YPERR; + goto fail; + } + (void)memcpy(val, out.ypresp_all_u.val.val.valdat_val, + size); + val[size] = '\0'; + + done = (*ypserv_ypresp_allfn)(status, key, + out.ypresp_all_u.val.key.keydat_len, val, + out.ypresp_all_u.val.val.valdat_len, ypserv_ypresp_data); + free(key); + free(val); + } else + done = 1; + if (status != YP_NOMORE) + *objp = status; + rc = TRUE; +fail: + xdr_free(xdr_ypresp_all, (char *)&out); + } + return rc; +} + int yp_all_host(CLIENT *client, char *indomain, char *inmap, struct ypall_callback *incallback) @@ -250,11 +306,11 @@ yp_all_host(CLIENT *client, char *indomain, char *inmap, yprnk.domain = indomain; yprnk.map = inmap; - ypresp_allfn = incallback->foreach; - ypresp_data = (void *)incallback->data; + ypserv_ypresp_allfn = incallback->foreach; + ypserv_ypresp_data = (void *)incallback->data; (void) clnt_call(client, YPPROC_ALL, - xdr_ypreq_nokey, &yprnk, xdr_ypresp_all_seq, &status, tv); + xdr_ypreq_nokey, &yprnk, ypserv_xdr_ypresp_all_seq, &status, tv); if (status != YP_FALSE) return ypprot_err(status); return 0; |