From andre.albsmeier@mchp.siemens.de  Mon Jun 26 22:52:41 2000
Return-Path: <andre.albsmeier@mchp.siemens.de>
Received: from goliath.siemens.de (goliath.siemens.de [194.138.37.131])
	by hub.freebsd.org (Postfix) with ESMTP id 061F537BE31
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 26 Jun 2000 22:52:39 -0700 (PDT)
	(envelope-from andre.albsmeier@mchp.siemens.de)
Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14])
	by goliath.siemens.de (8.10.1/8.10.1) with ESMTP id e5R5qaB27876
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Jun 2000 07:52:36 +0200 (MET DST)
Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.42.7])
	by mail1.siemens.de (8.10.1/8.10.1) with ESMTP id e5R5qZC21833
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Jun 2000 07:52:35 +0200 (MET DST)
Received: (from localhost)
	by curry.mchp.siemens.de (8.10.2/8.10.2) id e5R5qZV80092
	for FreeBSD-gnats-submit@freebsd.org; Tue, 27 Jun 2000 07:52:35 +0200 (CEST)
Message-Id: <200006270552.e5R5qZ429053@curry.mchp.siemens.de>
Date: Tue, 27 Jun 2000 07:52:35 +0200 (CEST)
From: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
To: FreeBSD-gnats-submit@freebsd.org
Subject: NIS passwd and group maps do not clean out comments (2nd part)
X-Send-Pr-Version: 3.2

>Number:         19538
>Category:       misc
>Synopsis:       NIS passwd and group maps do not clean out comments (2nd part)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    brian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 26 23:00:01 PDT 2000
>Closed-Date:    Wed Jun 28 06:54:02 PDT 2000
>Last-Modified:  Wed Jun 28 06:54:33 PDT 2000
>Originator:     Andre Albsmeier
>Release:        FreeBSD 3.4-STABLE i386
>Organization:
>Environment:

All FreeBSD versions after June 21st.

>Description:

PR misc/14269 contained a fix for usr.sbin/ypserv/Makefile.yp to allow
comments in passwd and group files. However, even with the patch in there
we still get errors when putting comments in master.passwd. We can get rid
of these by changing the master.passwd.byname: and the master.passwd.byuid:
rules in the same way as Walt Howard did it in PR misc/14269 with the passwd
and group rules:

--- Makefile.yp.ORI	Wed Jun 21 16:39:04 2000
+++ Makefile.yp	Wed Jun 21 16:39:32 2000
@@ -541,7 +541,8 @@
 	@echo "Master.passwd source file not found -- skipping"
 .else
 	$(CAT) $(MASTER) | \
-	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
+	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
+		print $$1"\t"$$0 }' $^ \
 		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
 		$(RMV) $(TMP) $@
 	@$(DBLOAD) -c
@@ -556,7 +557,8 @@
 	@echo "Master.passwd source file not found -- skipping"
 .else
 	$(CAT) $(MASTER) | \
-	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
+	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
+		print $$3"\t"$$0 }' $^ \
 		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
 		$(RMV) $(TMP) $@
 	@$(DBLOAD) -c




In case that $(PASSWD) is being generated from $(MASTER) by the
$(PASSWD): $(MASTER) rule, we will find things like

#::::::
# Blah blah::::::
#::::::

in the resulting $(PASSWD). Although these are being ignored properly
when bulding the maps, we can strip them out with the following,
additional patch:

--- Makefile.yp	Wed Jun 21 16:52:01 2000
+++ Makefile.yp.new	Wed Jun 21 16:52:37 2000
@@ -466,11 +466,11 @@
 	@echo "Creating new $@ file from $(MASTER)..."
 	@if [ ! $(UNSECURE) ]; then \
 	$(RCAT) $(MASTER) | \
-	$(AWK) -F: '{if ($$1 != "+") \
+	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
 		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
 		> $(PASSWD) ; \
 	else $(RCAT) $(MASTER) | \
-	$(AWK) -F: '{if ($$1 != "+") \
+	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
 		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
 		> $(PASSWD) ; fi
 

>How-To-Repeat:

Insert comments into master.passwd and let passwd get built from
it. Watch the error messages (1st patch) and examine the resulting
passwd (2. patch).


>Fix:
	
This patch combines the two above for easy commiting.

--- Makefile.yp.ORI	Tue Jun 27 07:47:54 2000
+++ Makefile.yp	Tue Jun 27 07:47:57 2000
@@ -466,11 +466,11 @@
 	@echo "Creating new $@ file from $(MASTER)..."
 	@if [ ! $(UNSECURE) ]; then \
 	$(RCAT) $(MASTER) | \
-	$(AWK) -F: '{if ($$1 != "+") \
+	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
 		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
 		> $(PASSWD) ; \
 	else $(RCAT) $(MASTER) | \
-	$(AWK) -F: '{if ($$1 != "+") \
+	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
 		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
 		> $(PASSWD) ; fi
 
@@ -541,7 +541,8 @@
 	@echo "Master.passwd source file not found -- skipping"
 .else
 	$(CAT) $(MASTER) | \
-	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
+	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
+		print $$1"\t"$$0 }' $^ \
 		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
 		$(RMV) $(TMP) $@
 	@$(DBLOAD) -c
@@ -556,7 +557,8 @@
 	@echo "Master.passwd source file not found -- skipping"
 .else
 	$(CAT) $(MASTER) | \
-	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
+	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
+		print $$3"\t"$$0 }' $^ \
 		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
 		$(RMV) $(TMP) $@
 	@$(DBLOAD) -c

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: brian 
Responsible-Changed-When: Tue Jun 27 08:41:46 PDT 2000 
Responsible-Changed-Why:  
I did the first bit, I'll do this too (soon) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19538 
State-Changed-From-To: open->closed 
State-Changed-By: brian 
State-Changed-When: Wed Jun 28 06:54:02 PDT 2000 
State-Changed-Why:  
Fixed in -current.  Will mfc soon. 

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