bin/72881 : yppush pushes map to local server [PATCH]

Thomas Quinot thomas at FreeBSD.ORG
Fri Aug 11 22:50:20 UTC 2006


The following reply was made to PR bin/72881; it has been noted by GNATS.

From: Thomas Quinot <thomas at FreeBSD.ORG>
To: bug-followup at freebsd.org
Cc:  
Subject: bin/72881 : yppush pushes map to local server [PATCH]
Date: Sat, 12 Aug 2006 00:40:37 +0200

 The patch below is a proposed fix for this PR. When running yppush on a
 NIS master, it skips pushing the map to itself. Tested locally.
 
 Thomas.
 
 Index: yppush_main.c
 ===================================================================
 RCS file: /space/mirror/ncvs/src/usr.sbin/yppush/yppush_main.c,v
 retrieving revision 1.20
 diff -u -r1.20 yppush_main.c
 --- yppush_main.c	12 Apr 2005 15:02:57 -0000	1.20
 +++ yppush_main.c	11 Aug 2006 22:36:07 -0000
 @@ -60,6 +60,7 @@
  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 +481,9 @@
  		return (status);
  
  	snprintf(server, sizeof(server), "%.*s", vallen, val);
 +	if (skip_master && !strcasecmp (server, yppush_master)) {
 +		return 0;
 +	}
  
  	/*
  	 * Restrict the number of concurrent jobs. If yppush_jobs number
 @@ -615,7 +619,13 @@
  		yppush_exit(1);
  	}
  
 -	if (strncmp(myname, data.data, data.size)) {
 +	if (!strncasecmp(myname, data.data, data.size)) {
 +		/* 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
 @@ -652,13 +662,13 @@
  	/* set initial transaction ID */
  	yppush_transid = time((time_t *)NULL);
  
 -	if (yppush_hostlist) {
 +	if (yppush_hostlist != NULL) {
  	/*
  	 * Host list was specified on the command line:
  	 * kick off the transfers by hand.
  	 */
  		tmp = yppush_hostlist;
 -		while (tmp) {
 +		while (tmp != NULL) {
  			yppush_foreach(YP_TRUE, NULL, 0, tmp->name,
  			    strlen(tmp->name), NULL);
  			tmp = tmp->next;


More information about the freebsd-bugs mailing list