summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-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 */