From thomas@cuivre.fr.eu.org  Tue Oct 19 15:00:47 2004
Return-Path: <thomas@cuivre.fr.eu.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 2A86316A531
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 Oct 2004 15:00:47 +0000 (GMT)
Received: from melusine.cuivre.fr.eu.org (melusine.cuivre.fr.eu.org [82.225.155.84])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A97FF43D48
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 19 Oct 2004 15:00:46 +0000 (GMT)
	(envelope-from thomas@cuivre.fr.eu.org)
Received: by melusine.cuivre.fr.eu.org (Postfix, from userid 1000)
	id 53D822C3D0; Tue, 19 Oct 2004 17:00:45 +0200 (CEST)
Message-Id: <20041019150045.53D822C3D0@melusine.cuivre.fr.eu.org>
Date: Tue, 19 Oct 2004 17:00:45 +0200 (CEST)
From: Thomas Quinot <thomas@cuivre.fr.eu.org>
Reply-To: Thomas Quinot <thomas@cuivre.fr.eu.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: yppush pushes map to local server
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         72881
>Category:       bin
>Synopsis:       yppush pushes map to local server
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    thomas
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 19 15:10:22 GMT 2004
>Closed-Date:    Thu Aug 31 18:11:40 GMT 2006
>Last-Modified:  Thu Aug 31 18:11:40 GMT 2006
>Originator:     Thomas Quinot
>Release:        FreeBSD 5.2.1-RELEASE-p5 i386
>Organization:
>Environment:
System: FreeBSD melusine.cuivre.fr.eu.org 5.2.1-RELEASE-p5 FreeBSD 5.2.1-RELEASE-p5 #1: Sat May 22 22:28:16 CEST 2004 thomas@melusine.cuivre.fr.eu.org:/usr2/obj/usr2/src/RELENG_5_2/sys/MELUSINE i386


	
>Description:
	When updating NIS maps with /var/yp/Makefile, yppush always
	produces error messages:

yppush: transfer of map group.byname to server local-server failed
yppush: status returned by ypxfr: Master's version not newer

	Obvisouly master's version is not newer, since the machine
	*is* the local NIS master where yppush is being invoked.

>How-To-Repeat:
	cd /var/yp && make
>Fix:

	
>Release-Note:
>Audit-Trail:

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: bug-followup@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;
State-Changed-From-To: open->patched 
State-Changed-By: ru 
State-Changed-When: Sun Aug 13 19:58:16 UTC 2006 
State-Changed-Why:  
Patch committed (with minor mods). 


Responsible-Changed-From-To: freebsd-bugs->thomas 
Responsible-Changed-By: ru 
Responsible-Changed-When: Sun Aug 13 19:58:16 UTC 2006 
Responsible-Changed-Why:  
Originator is more than welcome to use his commit bit to do MFCs.  :-) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72881 
State-Changed-From-To: patched->closed 
State-Changed-By: thomas 
State-Changed-When: Thu Aug 31 18:11:27 UTC 2006 
State-Changed-Why:  
MFC'd to RELENG_6 (yppush_main.c 1.20.2.1). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72881 
>Unformatted:
