diff options
| author | Simon J. Gerraty <sjg@FreeBSD.org> | 2012-11-04 02:52:03 +0000 |
|---|---|---|
| committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2012-11-04 02:52:03 +0000 |
| commit | 27e9e8ad199ef568950a4a74fd896c98f8b76b33 (patch) | |
| tree | 39860234c3deda7de976cccc795de42ae7b0aa77 /libutil/pw_util.c | |
| parent | 24470f8655c1a497d884cc8938b132c24e933d8b (diff) | |
| parent | 32215e1fded83eb454a0ec2522dbd53877e5a384 (diff) | |
| download | pw-darwin-27e9e8ad199ef568950a4a74fd896c98f8b76b33.tar.gz pw-darwin-27e9e8ad199ef568950a4a74fd896c98f8b76b33.zip | |
Sync from head
Diffstat (limited to 'libutil/pw_util.c')
| -rw-r--r-- | libutil/pw_util.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/libutil/pw_util.c b/libutil/pw_util.c index 63c63de..4bf3001 100644 --- a/libutil/pw_util.c +++ b/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); |
