summaryrefslogtreecommitdiffstats
path: root/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'libutil')
-rw-r--r--libutil/pw_util.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/libutil/pw_util.c b/libutil/pw_util.c
index 4bf3001..63c63de 100644
--- a/libutil/pw_util.c
+++ b/libutil/pw_util.c
@@ -437,21 +437,14 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
size_t len;
int eof, readlen;
- if (old_pw == NULL && pw == NULL)
- return (-1);
-
- spw = old_pw;
- /* deleting a user */
+ spw = pw;
if (pw == NULL) {
line = NULL;
- } else {
- if ((line = pw_make(pw)) == NULL)
+ if (old_pw == NULL)
return (-1);
- }
-
- /* adding a user */
- if (spw == NULL)
- spw = pw;
+ spw = old_pw;
+ } else if ((line = pw_make(pw)) == NULL)
+ return (-1);
eof = 0;
len = 0;
@@ -518,7 +511,7 @@ pw_copy(int ffd, int tfd, const struct passwd *pw, struct passwd *old_pw)
*/
*q = t;
- if (fpw == NULL || strcmp(fpw->pw_name, spw->pw_name) != 0) {
+ if (fpw == NULL || fpw->pw_uid != spw->pw_uid) {
/* nope */
if (fpw != NULL)
free(fpw);