Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jul 1999 11:43:58 +0900
From:      yasuf@big.or.jp
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/12828: passwd(1) doesn't recognize comments
Message-ID:  <19990727114358W.yasuf@big.or.jp>

next in thread | raw e-mail | index | archive | help

>Number:         12828
>Category:       bin
>Synopsis:       passwd(1) doesn't recognize comments
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 26 19:50:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Yasuhiro Fukuma
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

FreeBSD smoove.ouchi-net.jp 4.0-CURRENT FreeBSD 4.0-CURRENT #10: Sun Jul  4 13:44:45 JST 1999     yasuf@smoove.ouchi-net.jp:/usr/src/sys/compile/ARMADILLO  i386

>Description:

Passwd(5) manpage says:
|    Lines whose first non-whitespace character is a pound-sign (#) are com-
|    ments, and are ignored.  Blank lines which consist only of spaces, tabs
|    or newlines are also ignored.

but passwd(1) (, chpass(1), etc.) seems not to support these features
correctly.

>How-To-Repeat:

  # tail -3 /etc/master.passwd
  user1:*:9999:9999::0:0:some user:/home/user1:
  # comment
  user2:*:9998:9998::0:0:other user:/home/user2:

  # passwd user1
  Changing local password for user1.
  New password:
  Retype new password:
  passwd: updating the database...
  passwd: done

  # passwd user2
  Changing local password for user2.
  New password:
  Retype new password:
  passwd: /etc/master.passwd: corrupted entry
  passwd: /etc/master.passwd: unchanged

>Fix:
Index: usr.bin/chpass/pw_copy.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/chpass/pw_copy.c,v
retrieving revision 1.7
diff -u -r1.7 pw_copy.c
--- pw_copy.c	1999/04/25 22:37:56	1.7
+++ pw_copy.c	1999/07/23 04:56:26
@@ -85,6 +85,15 @@
 				goto err;
 			continue;
 		}
+		for (p = buf; *p != '\n'; p++)
+			if (*p != ' ' && *p != '\t')
+				break;
+		if (*p == '#' || *p == '\n') {
+			(void)fprintf(to, "%s", buf);
+			if (ferror(to))
+				goto err;
+			continue;
+		}
 		if (!(p = strchr(buf, ':'))) {
 			warnx("%s: corrupted entry", _PATH_MASTERPASSWD);
 			pw_error(NULL, 0, 1);

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990727114358W.yasuf>