From tom@sdf.com  Mon Jan 26 09:46:28 1998
Received: from misery.sdf.com (misery.sdf.com [204.244.213.32])
          by hub.freebsd.org (8.8.8/8.8.8) with SMTP id JAA24255
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 26 Jan 1998 09:46:26 -0800 (PST)
          (envelope-from tom@sdf.com)
Received: from tom by misery.sdf.com with local (Exim 1.73 #1)
	id 0xwsLs-0006jg-00; Mon, 26 Jan 1998 09:29:40 -0800
Message-Id: <E0xwsLs-0006jg-00@misery.sdf.com>
Date: Mon, 26 Jan 1998 09:29:40 -0800
From: tom@sdf.com
Reply-To: tom@sdf.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: /var/yp/Makefile bug
X-Send-Pr-Version: 3.2

>Number:         5571
>Category:       bin
>Synopsis:       /var/yp/Makefile does not use temporary files properly
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 26 09:50:01 PST 1998
>Closed-Date:    Wed Feb 4 08:22:26 PST 1998
>Last-Modified:  Wed Feb  4 08:30:04 PST 1998
>Originator:     Tom
>Release:        FreeBSD 2.2.5-STABLE i386
>Organization:
SDF Systems
>Environment:

FreeBSD 2.2.5-STABLE i386

>Description:

/var/yp/Makefile goes through great lengths to use unique temporary
filenames, except for one:  /tmp/ypmake

Two invocations of make will stomp on /tmp/ypmake.  One will exit with a
file not found error, and the other will install a truncated
master.passwd.byname, and all the sudden mail starts to bounce as 75% of
the users disappear...

>How-To-Repeat:

Change your password on a yp client (which invokes rpc.yppassdd) at the
same time will an admin is doing a "make" to update the maps.


>Fix:
	
/var/yp/Makefile needs to postfix some unique info on /tmp/ypmake


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: wpaul 
State-Changed-When: Wed Feb 4 08:22:26 PST 1998 
State-Changed-Why:  
I have modified Makefile.yp in both -current and the 2.2.5 branch so 
that it no longer needs to create /tmp/ypmake. The reason I had that there 
in the first place is kind of dump. In a Makefile, if I say: 

FOO = 'echo $$$$' 

this does not, as you might expect, assign the current PID ($$) to FOO 
and keep it there so that it can be referenced as $(FOO), thus yielding 
the same PID each time. Instead, every time you reference $(FOO), it 
gets re-evaluated, so multiple references to $(FOO) yields different PIDs 
each time, which is not what I want. I tried to work around this by 
writing the PID to a file once so that I could call up the same value 
a couple different times without it changing unexpectedly. 

What I did now was to simply append the two commands that need to use $$ 
together using a semicolon (yp_mkdb -o foo.$$; mv foo.$$ foo) so that 
both commands are executed in the same subshell and thus the PID won't 
change. 

-Bill 
>Unformatted:
