summaryrefslogtreecommitdiff
path: root/usr.sbin/amd
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-04-25 00:53:50 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-04-25 00:53:50 +0000
commita7561fa666a69e4cf4462d2d758924bb9470736f (patch)
tree6ab127b6aa9b0c3c78cdcc2eb46d7aaf18fcfe14 /usr.sbin/amd
parent06acb9e73401609b754a00ffa89901ac4bc9996d (diff)
NIS+ in YP compatibility mode does not support a working yp_order(). amd
wants one so it can flush it's cache intelligently. Here's a working compromise... solution worked out by matthieu@laas.fr and I.
Diffstat (limited to 'usr.sbin/amd')
-rw-r--r--usr.sbin/amd/amd/info_nis.c57
1 files changed, 48 insertions, 9 deletions
diff --git a/usr.sbin/amd/amd/info_nis.c b/usr.sbin/amd/amd/info_nis.c
index 72025fa0e22..2d445a30d7b 100644
--- a/usr.sbin/amd/amd/info_nis.c
+++ b/usr.sbin/amd/amd/info_nis.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)info_nis.c 8.1 (Berkeley) 6/6/93
- * $Id: info_nis.c,v 1.1 1995/10/18 08:47:10 deraadt Exp $
+ * $Id: info_nis.c,v 1.2 1996/04/25 00:53:43 deraadt Exp $
*/
/*
@@ -48,6 +48,12 @@
#ifdef HAS_NIS_MAPS
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
+#include <time.h>
+
+/*
+ * Sun's NIS+ server in NIS compat mode does not have yp_order()
+ */
+static int has_yp_order = FALSE;
/*
* Figure out the nis domain name
@@ -180,10 +186,24 @@ time_t *tp;
/*
* Make sure domain initialised
*/
- if (!domain) {
- int error = determine_nis_domain();
- if (error)
- return error;
+ if (has_yp_order) {
+ /* check if map has changed */
+ if (yp_order(domain, map, &order))
+ return EIO;
+ if ((time_t) order > *tp) {
+ *tp = (time_t) order;
+ return -1;
+ }
+ } else {
+ /*
+ * NIS+ server without yp_order
+ * Check if timeout has expired to invalidate the cache
+ */
+ order = time(NULL);
+ if ((time_t)order - *tp > am_timeo) {
+ *tp = (time_t)order;
+ return(-1);
+ }
}
/*
@@ -223,6 +243,8 @@ char *map;
time_t *tp;
{
int order;
+ int yp_order_result;
+ char *master;
if (!domain) {
int error = determine_nis_domain();
@@ -234,12 +256,29 @@ time_t *tp;
* To see if the map exists, try to find
* a master for it.
*/
- if (yp_order(domain, map, &order))
- return ENOENT;
- *tp = (time_t) order;
+ yp_order_result = yp_order(domain, map, &order);
+ switch (yp_order_result) {
+ case 0:
+ has_yp_order = TRUE;
+ *tp = (time_t)order;
#ifdef DEBUG
- dlog("NIS master for %s@%s has order %d", map, domain, order);
+ dlog("NIS master for %s@%s has order %d", map, domain, order);
#endif
+ break;
+ case YPERR_YPERR:
+ plog(XLOG_ERROR, "%s: %s", map, "NIS+ server");
+ /* NIS+ server found ! */
+ has_yp_order = FALSE;
+
+ /* try yp_master() instead */
+ if (yp_master(domain, map, &master))
+ return ENOENT;
+ else
+ *tp = time(NULL); /* Use fake timestamps */
+ break;
+ default:
+ return ENOENT;
+ }
return 0;
}
#endif /* HAS_NIS_MAPS */