summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pwd_mkdb
diff options
context:
space:
mode:
authorgordon <gordon@FreeBSD.org>2011-07-06 06:34:08 +0000
committergordon <gordon@FreeBSD.org>2011-07-06 06:34:08 +0000
commit8ac701c9826e188a3f168c8a8b8f7c078648d235 (patch)
tree107bc26305de274c785b4c0383e5e6c76ee7d2d3 /usr.sbin/pwd_mkdb
parenta56bc34bcb01041f2678d50c784cf1676b386aa4 (diff)
downloadFreeBSD-src-8ac701c9826e188a3f168c8a8b8f7c078648d235.zip
FreeBSD-src-8ac701c9826e188a3f168c8a8b8f7c078648d235.tar.gz
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
Diffstat (limited to 'usr.sbin/pwd_mkdb')
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index 2abbcdf..79f91a9 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.c
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c
@@ -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");
OpenPOWER on IntegriCloud