Hello, I setup a FreeBSD box as NIS master. The 'useradd' and 'usermod' options of the 'pw' command work fine, but there are two problems with the 'userdel' option. 1. 'pw userdel' always fail with error: pw: pw_copy(): No such file or directory Because "GETPWNAM(user)" at line 102 of pwdupd.c seems to have destroyed the 'pwd' global variable. 2. 'pw userdel' does not update "NIS maps" with '-Y' option. Workaround patch for 11-STABLE: diff -u pw_user.c.orig pw_user.c --- pw_user.c.orig 2018-04-16 14:26:59.461462000 +0900 +++ pw_user.c 2018-04-16 14:27:21.843681000 +0900 @@ -963,7 +963,7 @@ else grname[0] = '\0'; - rc = delpwent(pwd); + rc = delpwent(nis ? pw_dup(pwd) : pwd); if (rc == -1) err(EX_IOERR, "user '%s' does not exist", pwd->pw_name); else if (rc != 0) @@ -1024,6 +1024,9 @@ "completely "); } + if (nis && nis_update() == 0) + pw_log(cnf, M_ADD, W_USER, "NIS maps updated"); + return (EXIT_SUCCESS); } Thank you.
Sorry, my patch was incomplete and failed without '-Y' option. The 'pwd' always need to be duplicated. patch: --- pw_user.c.orig 2018-04-16 14:26:59.461462000 +0900 +++ pw_user.c 2018-04-19 13:16:14.015451000 +0900 @@ -963,7 +963,7 @@ else grname[0] = '\0'; - rc = delpwent(pwd); + rc = delpwent(pw_dup(pwd)); if (rc == -1) err(EX_IOERR, "user '%s' does not exist", pwd->pw_name); else if (rc != 0) @@ -1024,6 +1024,9 @@ "completely "); } + if (nis && nis_update() == 0) + pw_log(cnf, M_ADD, W_USER, "NIS maps updated"); + return (EXIT_SUCCESS); } # grep passwd /etc/nsswitch.conf passwd: compat passwd_compat: nis And I add '+:::::::::' line in /etc/master.passwd original 'pw': # pw useradd test -Y (OK) NIS Map update started ... # pw userdel test01 -Y (NG) pw: pw_copy(): No such file or directory # pw useradd test (OK) # pw userdel test (NG) pw: pw_copy(): No such file or directory my old patched 'pw': # ./pw useradd test01 -Y (OK) NIS Map update started ... # ./pw userdel test01 -Y (OK) NIS Map update started ... # ./pw useradd test01 (OK) # ./pw userdel test01 (NG) pw: pw_copy(): No such file or directory new patched 'pw': # ./pw.new useradd test01 -Y (OK) NIS Map update started ... # ./pw.new userdel test01 -Y (OK) NIS Map update started on ... # ./pw.new useradd test01 (OK) # ./pw.new userdel test01 (OK) Thank you.