Hi,

While doing something else here I noticed that changing the login name of an
existing user with usermod -l the program gets a segmentation fault.

This looks like it was introduced when millert@ changed pwcache and the fix is
a matter of changing getpwnam(3) to uid_from_user(3).

OK?

Index: user.c
===================================================================
RCS file: /cvs/src/usr.sbin/user/user.c,v
retrieving revision 1.121
diff -u -p -u -r1.121 user.c
--- user.c      13 Sep 2018 15:23:32 -0000      1.121
+++ user.c      26 Sep 2018 09:34:07 -0000
@@ -1369,6 +1369,7 @@ moduser(char *login_name, char *newlogin
        int             ptmpfd;
        int             rval;
        int             i;
+       uid_t   uid;
 
        if (!valid_login(newlogin)) {
                errx(EXIT_FAILURE, "`%s' is not a valid login name", 
login_name);
@@ -1427,7 +1428,8 @@ moduser(char *login_name, char *newlogin
        if (up != NULL) {
                if (up->u_flags & F_USERNAME) {
                        /* if changing name, check new name isn't already in 
use */
-                       if (strcmp(login_name, newlogin) != 0 && 
getpwnam(newlogin) != NULL) {
+                       if (strcmp(login_name, newlogin) != 0 &&
+                           uid_from_user(newlogin, &uid) != -1) {
                                close(ptmpfd);
                                pw_abort();
                                errx(EXIT_FAILURE, "already a `%s' user", 
newlogin);

Reply via email to