CORRECTED SUMMARY: Comments and blank lines in netgroup file?

From: Manavendra K. Thakur (
Date: Tue Jul 02 1991 - 04:36:57 CDT


I goofed when I summarized the sed command I put in /var/yp/Makefile
to strip out blank lines and handle comment characters. Much to my
chagrin, what I listed in my previous summary does not actually work.
(This has NOT been a good week so far.)

As a way of making amends, I'll pass on another tidbit I learned after
sending out my summary: the ethers.time target strips leading zeroes
(as it should) while creating the ethers.byaddr map but not while
creating the ethers.byname map. You can fix this easily by invoking
$(STDETHERS) on $(DIR)/ethers before passing the results to awk and
makedbm. (As a guide, follow the lines that create the ethers.byaddr
map. The change to the Makefile is really pretty trivial.)

Anyway, here is the corrected version of my summary about the netgroup

I recently asked:

> What is a valid comment character in the ASCII netgroup file that
> defines the NIS netgroup map?
> And can you have blank lines in the ASCII netgroup file?

Just about everyone who responded said that no, there isn't any real
comment character for makedbm but that one can simply run sed to
truncate lines at pound signs and to strip out blank lines.

Duhhh... what else could be simpler? I should have figured this
without bothering the net. Sorry folks; I should have remembered that
there's no documentation like the code itself!

Here is the way I ended up modifying my /var/yp/Makefile such that it
does the right thing with empty lines and pound signs:

netgroup.time: $(DIR)/netgroup
        @(sed -e '/^#/d' -e 's/#.*$$//' -e 's/[ ][ ]*$$//' \
            -e '/^$$/d' $(DIR)/netgroup $(CHKPIPE)) | \
            $(MAKEDBM) - $(YPDBDIR)/$(DOM)/netgroup
        @($(REVNETGROUP) < $(DIR)/netgroup -u $(CHKPIPE))| $(MAKEDBM) - $(YPDBDIR)/$(DOM)/netgroup.byuser
        @($(REVNETGROUP) < $(DIR)/netgroup -h $(CHKPIPE))| $(MAKEDBM) - $(YPDBDIR)/$(DOM)/netgroup.byhost
                . (etc)

Note that you don't need to run sed before the invocation of
$(REVNETGROUP) in the next lines, since /usr/etc/yp/revnetgroup seems
smart enough to automatically skip over blank lines and pound signs.
This is true as of at least SunOS 4.1.1.

Note also that you can use similar lines for any other target in

(Why makedbm can't take care of this for all its input and make
everyone's life easier, I don't understand.)

Thanks to the following people for guiding me out of my confusion:

Claus Assmann <>
era@niwot.scd.ucar.EDU (Ed Arnold)
Hannu Visti <> (Liam Quin)
stern@sunne.East.Sun.COM (Hal Stern - Consultant) (Roberto Gomez)
kevin@fourx.Aus.Sun.COM (Kevin Sheehan {Consulting Poster Child}) ( Birger Wathne) (Rand S. Huntzinger) (Sheryl Coppenger)

Manavendra K. Thakur Internet:
Systems Programmer, High Energy Division BITNET: thakur@cfa.BITNET
Harvard-Smithsonian Center for DECNET: CFA::thakur
Astrophysics UUCP: ...!uunet!mit-eddie!thakur

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:21 CDT