From owner-svn-src-all@FreeBSD.ORG Wed Jul 6 06:34:08 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9124D106564A; Wed, 6 Jul 2011 06:34:08 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 807FB8FC12; Wed, 6 Jul 2011 06:34:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p666Y8q4003237; Wed, 6 Jul 2011 06:34:08 GMT (envelope-from gordon@svn.freebsd.org) Received: (from gordon@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p666Y8iu003235; Wed, 6 Jul 2011 06:34:08 GMT (envelope-from gordon@svn.freebsd.org) Message-Id: <201107060634.p666Y8iu003235@svn.freebsd.org> From: Gordon Tetlow Date: Wed, 6 Jul 2011 06:34:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223818 - head/usr.sbin/pwd_mkdb X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2011 06:34:08 -0000 Author: gordon Date: Wed Jul 6 06:34:08 2011 New Revision: 223818 URL: http://svn.freebsd.org/changeset/base/223818 Log: Only increment the ypcnt once per data record. The old implementation was incrementing it twice making it impossible to iterate the table since the records were 1, 3, 5, 7 (or 2, 4, 6, 8 for the v3 records). MFC after: 10 days Modified: head/usr.sbin/pwd_mkdb/pwd_mkdb.c Modified: head/usr.sbin/pwd_mkdb/pwd_mkdb.c ============================================================================== --- head/usr.sbin/pwd_mkdb/pwd_mkdb.c Wed Jul 6 05:42:52 2011 (r223817) +++ head/usr.sbin/pwd_mkdb/pwd_mkdb.c Wed Jul 6 06:34:08 2011 (r223818) @@ -351,14 +351,16 @@ main(int argc, char *argv[]) if ((dp->put)(sdp, &key, &data, 0) == -1) error("put"); } - ypcnt = 1; + ypcnt = 0; data.data = (u_char *)buf; sdata.data = (u_char *)sbuf; key.data = (u_char *)tbuf; for (cnt = 1; scan(fp, &pwd); ++cnt) { if (!is_comment && - (pwd.pw_name[0] == '+' || pwd.pw_name[0] == '-')) + (pwd.pw_name[0] == '+' || pwd.pw_name[0] == '-')) { yp_enabled = 1; + ypcnt++; + } if (is_comment) --cnt; #define COMPACT(e) t = e; while ((*p++ = *t++)); @@ -456,7 +458,6 @@ main(int argc, char *argv[]) tbuf[0] = CURRENT_VERSION(_PW_KEYYPBYNUM); store = htonl(ypcnt); memmove(tbuf + 1, &store, sizeof(store)); - ypcnt++; key.size = sizeof(store) + 1; if ((dp->put)(dp, &key, &data, method) == -1) error("put"); @@ -547,7 +548,6 @@ main(int argc, char *argv[]) tbuf[0] = LEGACY_VERSION(_PW_KEYYPBYNUM); store = HTOL(ypcnt); memmove(tbuf + 1, &store, sizeof(store)); - ypcnt++; key.size = sizeof(store) + 1; if ((dp->put)(dp, &key, &data, method) == -1) error("put");