diff options
author | bapt <bapt@FreeBSD.org> | 2012-06-19 11:39:56 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2012-06-19 11:39:56 +0000 |
commit | 4d9f5b822708da832e0145d2dc2777d35a95d910 (patch) | |
tree | 31d0873a13c63ebfd8b1787bdd41f701e55b99da /lib/libutil/pw_util.c | |
parent | a6f2f68675028467a1e9515b5a3c1dafa286d2c2 (diff) | |
download | FreeBSD-src-4d9f5b822708da832e0145d2dc2777d35a95d910.zip FreeBSD-src-4d9f5b822708da832e0145d2dc2777d35a95d910.tar.gz |
Revert user comparison back to user names as some user can share uids (root/toor
for example)
get the username information from old_pw structures to still allow renaming of a
user.
Reported by: Claude Buisson <clbuisson@orange.fr>
Approved by: des (mentor)
MFC after: 3 weeks
Diffstat (limited to 'lib/libutil/pw_util.c')
-rw-r--r-- | lib/libutil/pw_util.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c index 63c63de..4bf3001 100644 --- a/lib/libutil/pw_util.c +++ b/lib/libutil/pw_util.c @@ -437,14 +437,21 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw) size_t len; int eof, readlen; - spw = pw; + if (old_pw == NULL && pw == NULL) + return (-1); + + spw = old_pw; + /* deleting a user */ if (pw == NULL) { line = NULL; - if (old_pw == NULL) + } else { + if ((line = pw_make(pw)) == NULL) return (-1); - spw = old_pw; - } else if ((line = pw_make(pw)) == NULL) - return (-1); + } + + /* adding a user */ + if (spw == NULL) + spw = pw; eof = 0; len = 0; @@ -511,7 +518,7 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw) */ *q = t; - if (fpw == NULL || fpw->pw_uid != spw->pw_uid) { + if (fpw == NULL || strcmp(fpw->pw_name, spw->pw_name) != 0) { /* nope */ if (fpw != NULL) free(fpw); |