tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] bug in mtree -N (and other getid.c consumers)



The simple master.passwd and group file parsers don't know about #
comments.  This produced quite surprising output when I ran:

nmtree -N <dir> -C -f test.mtree -K uname,gname

where test.mtree was:

---
/set type=dir uname=root gname=wheel mode=0755
.
    mail            gname=mail mode=0775
    ..
..
---

and <dir>'s group file contained:

---
# $FreeBSD: head/etc/group 256365 2013-10-12 06:06:53Z rpaulo $
...
mail:*:6:
---

The output was:

---
. type=dir uname=root gname=wheel mode=0755
./mail type=dir uname=root gname=# $FreeBSD mode=0775
---

The following patch rejects comment lines.  It might also be worth
considering vis encoding user and group names or at least rejecting
names including whitespace.

-- Brooks

Index: getid.c
===================================================================
--- getid.c     (revision 256058)
+++ getid.c     (working copy)
@@ -230,6 +230,9 @@
                                ;
                        continue;
                }
+               /* skip comments */
+               if (grline[0] == '#')
+                       continue;
                if (grmatchline(search, gid, name))
                        return 1;
        }
@@ -371,6 +374,9 @@
                                ;
                        continue;
                }
+               /* skip comments */
+               if (pwline[0] == '#')
+                       continue;
                if (pwmatchline(search, uid, name))
                        return 1;
        }

Attachment: pgpWBjyrNx42t.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index