]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Properly initialise with content of pw.conf(5) that was mistakenly ignored.
authorEugene Grosbein <eugen@FreeBSD.org>
Fri, 24 Mar 2017 16:18:57 +0000 (16:18 +0000)
committerEugene Grosbein <eugen@FreeBSD.org>
Fri, 24 Mar 2017 16:18:57 +0000 (16:18 +0000)
Also, respect "defaultgroup" if specified there.

PR: 217934
Reported by: Victor Sudakov <vas@mpeks.tomsk.su>
Reviewed by: bapt
Approved by: bapt, vsevolod (mentor)
MFC after: 1 week

pw/pw_user.c

index 8cffac98b558bf27bbfc4ce942d77841420785fc..5466becfb585282db5413c085cfc4aed933d1a1c 100644 (file)
@@ -1177,7 +1177,7 @@ pw_user_add(int argc, char **argv, char *arg1)
        char line[_PASSWORD_LEN+1], path[MAXPATHLEN];
        char *gecos, *homedir, *skel, *walk, *userid, *groupid, *grname;
        char *default_passwd, *name, *p;
        char line[_PASSWORD_LEN+1], path[MAXPATHLEN];
        char *gecos, *homedir, *skel, *walk, *userid, *groupid, *grname;
        char *default_passwd, *name, *p;
-       const char *cfg;
+       const char *cfg = NULL;
        login_cap_t *lc;
        FILE *pfp, *fp;
        intmax_t id = -1;
        login_cap_t *lc;
        FILE *pfp, *fp;
        intmax_t id = -1;
@@ -1356,6 +1356,9 @@ pw_user_add(int argc, char **argv, char *arg1)
        if (GETPWNAM(name) != NULL)
                errx(EX_DATAERR, "login name `%s' already exists", name);
 
        if (GETPWNAM(name) != NULL)
                errx(EX_DATAERR, "login name `%s' already exists", name);
 
+       if (!grname)
+               grname = cmdcnf->default_group;
+
        pwd = &fakeuser;
        pwd->pw_name = name;
        pwd->pw_class = cmdcnf->default_class ? cmdcnf->default_class : "";
        pwd = &fakeuser;
        pwd->pw_name = name;
        pwd->pw_class = cmdcnf->default_class ? cmdcnf->default_class : "";
@@ -1485,7 +1488,7 @@ pw_user_mod(int argc, char **argv, char *arg1)
        struct group *grp;
        StringList *groups = NULL;
        char args[] = "C:qn:u:c:d:e:p:g:G:mM:l:k:s:w:L:h:H:NPYy:";
        struct group *grp;
        StringList *groups = NULL;
        char args[] = "C:qn:u:c:d:e:p:g:G:mM:l:k:s:w:L:h:H:NPYy:";
-       const char *cfg;
+       const char *cfg = NULL;
        char *gecos, *homedir, *grname, *name, *newname, *walk, *skel, *shell;
        char *passwd, *class, *nispasswd;
        login_cap_t *lc;
        char *gecos, *homedir, *grname, *name, *newname, *walk, *skel, *shell;
        char *passwd, *class, *nispasswd;
        login_cap_t *lc;