When updating a single entry (i.e. when the `-u' option is given),
do not add the "\xFF" "VERSION" key --- it should only be added once ALL entries have been updated. While I'm here, correct the logic that detects whether or not the user-ID has changed so that it works even if all entries have not yet been updated to the new format. Users missing-in-action were Reported by: tjr, Vallo Kallaste <vallo@estcard.ee>, leafy <leafy@leafy.idv.tw> Sponsored by: DARPA, Network Associates Laboratories
This commit is contained in:
parent
284a57dd1b
commit
257ca75f51
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114159
@ -204,6 +204,8 @@ main(int argc, char *argv[])
|
|||||||
(void)snprintf(buf, sizeof(buf), "%s/%s.tmp", prefix, _MP_DB);
|
(void)snprintf(buf, sizeof(buf), "%s/%s.tmp", prefix, _MP_DB);
|
||||||
(void)snprintf(sbuf, sizeof(sbuf), "%s/%s.tmp", prefix, _SMP_DB);
|
(void)snprintf(sbuf, sizeof(sbuf), "%s/%s.tmp", prefix, _SMP_DB);
|
||||||
if (username) {
|
if (username) {
|
||||||
|
int use_version;
|
||||||
|
|
||||||
(void)snprintf(buf2, sizeof(buf2), "%s/%s", prefix, _MP_DB);
|
(void)snprintf(buf2, sizeof(buf2), "%s/%s", prefix, _MP_DB);
|
||||||
(void)snprintf(sbuf2, sizeof(sbuf2), "%s/%s", prefix, _SMP_DB);
|
(void)snprintf(sbuf2, sizeof(sbuf2), "%s/%s", prefix, _SMP_DB);
|
||||||
|
|
||||||
@ -229,7 +231,14 @@ main(int argc, char *argv[])
|
|||||||
pw_db = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL);
|
pw_db = dbopen(_PATH_MP_DB, O_RDONLY, 0, DB_HASH, NULL);
|
||||||
if (!pw_db)
|
if (!pw_db)
|
||||||
error(_MP_DB);
|
error(_MP_DB);
|
||||||
buf[0] = CURRENT_VERSION(_PW_KEYBYNAME);
|
|
||||||
|
key.data = verskey;
|
||||||
|
key.size = sizeof(verskey)-1;
|
||||||
|
if ((pw_db->get)(pw_db, &key, &data, 0) == 0)
|
||||||
|
use_version = *(unsigned char *)data.data;
|
||||||
|
else
|
||||||
|
use_version = 3;
|
||||||
|
buf[0] = _PW_VERSIONED(_PW_KEYBYNAME, use_version);
|
||||||
len = strlen(username);
|
len = strlen(username);
|
||||||
|
|
||||||
/* Only check that username fits in buffer */
|
/* Only check that username fits in buffer */
|
||||||
@ -245,10 +254,10 @@ main(int argc, char *argv[])
|
|||||||
while (*p++)
|
while (*p++)
|
||||||
;
|
;
|
||||||
|
|
||||||
buf[0] = CURRENT_VERSION(_PW_KEYBYUID);
|
buf[0] = _PW_VERSIONED(_PW_KEYBYUID, use_version);
|
||||||
memmove(buf + 1, p, sizeof(int));
|
memmove(buf + 1, p, sizeof(store));
|
||||||
key.data = (u_char *)buf;
|
key.data = (u_char *)buf;
|
||||||
key.size = sizeof(int) + 1;
|
key.size = sizeof(store) + 1;
|
||||||
|
|
||||||
if ((pw_db->get)(pw_db, &key, &data, 0) == 0) {
|
if ((pw_db->get)(pw_db, &key, &data, 0) == 0) {
|
||||||
/* First field of data.data holds pw_pwname */
|
/* First field of data.data holds pw_pwname */
|
||||||
@ -313,16 +322,23 @@ main(int argc, char *argv[])
|
|||||||
/* In order to transition this file into a machine-independent
|
/* In order to transition this file into a machine-independent
|
||||||
* form, we have to change the format of entries. However, since
|
* form, we have to change the format of entries. However, since
|
||||||
* older binaries will still expect the old MD format entries, we
|
* older binaries will still expect the old MD format entries, we
|
||||||
* create * those as usual and use versioned tags for the new entries.
|
* create those as usual and use versioned tags for the new entries.
|
||||||
*/
|
*/
|
||||||
key.data = verskey;
|
if (username == NULL) {
|
||||||
key.size = sizeof(verskey)-1;
|
/* Do not add the VERSION tag when updating a single
|
||||||
data.data = &version;
|
* user. When operating on `old format' databases, this
|
||||||
data.size = 1;
|
* would result in applications `seeing' only the updated
|
||||||
if ((dp->put)(dp, &key, &data, 0) == -1)
|
* entries.
|
||||||
error("put");
|
*/
|
||||||
if ((dp->put)(sdp, &key, &data, 0) == -1)
|
key.data = verskey;
|
||||||
error("put");
|
key.size = sizeof(verskey)-1;
|
||||||
|
data.data = &version;
|
||||||
|
data.size = 1;
|
||||||
|
if ((dp->put)(dp, &key, &data, 0) == -1)
|
||||||
|
error("put");
|
||||||
|
if ((dp->put)(sdp, &key, &data, 0) == -1)
|
||||||
|
error("put");
|
||||||
|
}
|
||||||
ypcnt = 1;
|
ypcnt = 1;
|
||||||
data.data = (u_char *)buf;
|
data.data = (u_char *)buf;
|
||||||
sdata.data = (u_char *)sbuf;
|
sdata.data = (u_char *)sbuf;
|
||||||
|
Loading…
Reference in New Issue
Block a user