Hi,
when using user mod -u, my machine ran into a segfault and the passwd
file was left locked.
I belief this is due to the changes to getpwnam etc.
Sadly I am unable to figure out, why exactly the call to getpwuid
segfaults. But replacing it with a call to user_from_uid helped.
I could not crash the program with other flags that use getpw{nam,uid}.
Thanks,
Moritz Buhl
Index: user.c
===================================================================
RCS file: /cvs/src/usr.sbin/user/user.c,v
retrieving revision 1.122
diff -u -p -r1.122 user.c
--- user.c 26 Sep 2018 14:54:58 -0000 1.122
+++ user.c 8 Oct 2018 17:00:16 -0000
@@ -1515,7 +1515,8 @@ moduser(char *login_name, char *newlogin
}
if (up->u_flags & F_UID) {
/* check uid isn't already allocated */
- if (!(up->u_flags & F_DUPUID) &&
getpwuid((uid_t)(up->u_uid)) != NULL) {
+ if (!(up->u_flags & F_DUPUID) &&
+ user_from_uid((uid_t)(up->u_uid), 1) != NULL) {
close(ptmpfd);
pw_abort();
errx(EXIT_FAILURE, "uid %u is already in use",
up->u_uid);