From 1ca146c4506ba4101ebba61a4cc126f023c1ee2f Mon Sep 17 00:00:00 2001 From: ru Date: Sun, 13 Aug 2006 19:57:32 +0000 Subject: Don't push a map on a master server which will fail anyway. PR: bin/72881 Submitted by: thomas (slightly coloured by me) --- usr.sbin/yppush/yppush_main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'usr.sbin/yppush') diff --git a/usr.sbin/yppush/yppush_main.c b/usr.sbin/yppush/yppush_main.c index 951f413..59108db 100644 --- a/usr.sbin/yppush/yppush_main.c +++ b/usr.sbin/yppush/yppush_main.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ char *yp_dir = _PATH_YP; char *yppush_mapname = NULL; /* Map to transfer. */ char *yppush_domain = NULL; /* Domain in which map resides. */ char *yppush_master = NULL; /* Master NIS server for said domain. */ +int skip_master = 0; /* Do not attempt to push map to master. */ int verbose = 0; /* Toggle verbose mode. */ unsigned long yppush_transid = 0; int yppush_timeout = 80; /* Default timeout. */ @@ -480,6 +482,8 @@ yppush_foreach(int status, char *key, int keylen, char *val, int vallen, return (status); snprintf(server, sizeof(server), "%.*s", vallen, val); + if (skip_master && strcasecmp(server, yppush_master) == 0) + return (0); /* * Restrict the number of concurrent jobs. If yppush_jobs number @@ -615,7 +619,13 @@ main(int argc, char *argv[]) yppush_exit(1); } - if (strncmp(myname, data.data, data.size)) { + if (strncasecmp(myname, data.data, data.size) == 0) { + /* I am master server, and no explicit host list was + specified: do not push map to myself -- this will + fail with YPPUSH_AGE anyway. */ + if (yppush_hostlist == NULL) + skip_master = 1; + } else { yp_error("warning: this host is not the master for %s", yppush_mapname); #ifdef NITPICKY -- cgit v1.1