In r113596, version 4 of entries have been added but pwd_mkdb have

been generating both new (machine independent) and legacy version
entries (endianness sensitive).

The base system have been using the new format for quite some time,
so disable the generation by default.

An interim option, -l, have been added to re-enable old behavior.
The -l, -B and -L options are considered deprecated and will be
removed in FreeBSD 12.0 release.
This commit is contained in:
Xin LI 2015-06-04 07:24:56 +00:00
parent 9afc11b224
commit 3e08b16eca
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=283981
2 changed files with 39 additions and 8 deletions

View File

@ -36,7 +36,7 @@
.Nd "generate the password databases" .Nd "generate the password databases"
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl BCiLNp .Op Fl BCilLNp
.Op Fl d Ar directory .Op Fl d Ar directory
.Op Fl s Ar cachesize .Op Fl s Ar cachesize
.Op Fl u Ar username .Op Fl u Ar username
@ -61,14 +61,10 @@ different from the historic Version 7 style format.
.Pp .Pp
The options are as follows: The options are as follows:
.Bl -tag -width flag .Bl -tag -width flag
.It Fl B
Store data in big-endian format.
.It Fl C .It Fl C
Check if the password file is in the correct format. Check if the password file is in the correct format.
Do not Do not
change, add, or remove any files. change, add, or remove any files.
.It Fl L
Store data in little-endian format.
.It Fl N .It Fl N
Tell Tell
.Nm .Nm
@ -116,6 +112,34 @@ encrypted password and the insecure version has an asterisk (``*'')
The databases are used by the C library password routines (see The databases are used by the C library password routines (see
.Xr getpwent 3 ) . .Xr getpwent 3 ) .
.Pp .Pp
By default,
the
.Nm
utility generates new,
machine independent format
.Pq v4
entries only.
For compatibility with
.Fx 5.0
and earlier releases,
the
.Fl l
option may be specified,
which enables generation of legacy format
.Pq v3
entries.
The legacy format entries are endianness dependent.
.Pp
The following options may be specified and will affect the
generation of legacy entries.
.Pp
.Bl -tag -width flag
.It Fl B
Store data in big-endian format.
.It Fl L
Store data in little-endian format.
.El
.Pp
The The
.Nm .Nm
utility exits zero on success, non-zero on failure. utility exits zero on success, non-zero on failure.

View File

@ -112,15 +112,15 @@ main(int argc, char *argv[])
char sbuf2[MAXPATHLEN]; char sbuf2[MAXPATHLEN];
char *username; char *username;
u_int method, methoduid; u_int method, methoduid;
int Cflag, dflag, iflag; int Cflag, dflag, iflag, lflag;
int nblock = 0; int nblock = 0;
iflag = dflag = Cflag = 0; iflag = dflag = Cflag = lflag = 0;
strcpy(prefix, _PATH_PWD); strcpy(prefix, _PATH_PWD);
makeold = 0; makeold = 0;
username = NULL; username = NULL;
oldfp = NULL; oldfp = NULL;
while ((ch = getopt(argc, argv, "BCLNd:ips:u:v")) != -1) while ((ch = getopt(argc, argv, "BCLlNd:ips:u:v")) != -1)
switch(ch) { switch(ch) {
case 'B': /* big-endian output */ case 'B': /* big-endian output */
openinfo.lorder = BIG_ENDIAN; openinfo.lorder = BIG_ENDIAN;
@ -128,6 +128,9 @@ main(int argc, char *argv[])
case 'C': /* verify only */ case 'C': /* verify only */
Cflag = 1; Cflag = 1;
break; break;
case 'l': /* generate legacy entries */
lflag = 1;
break;
case 'L': /* little-endian output */ case 'L': /* little-endian output */
openinfo.lorder = LITTLE_ENDIAN; openinfo.lorder = LITTLE_ENDIAN;
break; break;
@ -465,6 +468,7 @@ main(int argc, char *argv[])
error("put"); error("put");
} }
if (lflag) {
/* Create insecure data. (legacy version) */ /* Create insecure data. (legacy version) */
p = buf; p = buf;
COMPACT(pwd.pw_name); COMPACT(pwd.pw_name);
@ -555,6 +559,7 @@ main(int argc, char *argv[])
error("put"); error("put");
} }
} }
}
/* Create original format password file entry */ /* Create original format password file entry */
if (is_comment && makeold){ /* copy comments */ if (is_comment && makeold){ /* copy comments */
if (fprintf(oldfp, "%s\n", line) < 0) if (fprintf(oldfp, "%s\n", line) < 0)
@ -583,6 +588,7 @@ main(int argc, char *argv[])
error("put"); error("put");
if ((sdp->put)(sdp, &key, &data, method) == -1) if ((sdp->put)(sdp, &key, &data, method) == -1)
error("put"); error("put");
if (lflag) {
tbuf[0] = LEGACY_VERSION(_PW_KEYYPENABLED); tbuf[0] = LEGACY_VERSION(_PW_KEYYPENABLED);
key.size = 1; key.size = 1;
if ((dp->put)(dp, &key, &data, method) == -1) if ((dp->put)(dp, &key, &data, method) == -1)
@ -590,6 +596,7 @@ main(int argc, char *argv[])
if ((sdp->put)(sdp, &key, &data, method) == -1) if ((sdp->put)(sdp, &key, &data, method) == -1)
error("put"); error("put");
} }
}
if ((dp->close)(dp) == -1) if ((dp->close)(dp) == -1)
error("close"); error("close");