diff options
Diffstat (limited to 'libutil')
| -rw-r--r-- | libutil/gr_util.c | 2 | ||||
| -rw-r--r-- | libutil/pw_util.c | 19 |
2 files changed, 15 insertions, 6 deletions
diff --git a/libutil/gr_util.c b/libutil/gr_util.c index 0173595..6d96d5e 100644 --- a/libutil/gr_util.c +++ b/libutil/gr_util.c @@ -63,6 +63,7 @@ static const char group_line_format[] = "%s:%s:%ju:"; int gr_init(const char *dir, const char *group) { + if (dir == NULL) { strcpy(group_dir, _PATH_ETC); } else { @@ -88,6 +89,7 @@ gr_init(const char *dir, const char *group) } strcpy(group_file, group); } + initialized = 1; return (0); } 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); |
