After upgrading to 12.0 RELEASE the yppasswdd RPC no longer updates passwords successfully. When trying to update a password the following is output: $ passwd fred Changing NIS password for fred New Password: Retype New Password: passwd: pam_chauthtok(): Error in service module A check of /var/log/messages shows one of the following errors depending on whether the -t option was set for nis_yppasswdd_flags in /etc/rc.conf: rename of / to /.hold failed rename of /var to /var/yp.hold failed rename of /var/yp to /var/yp/master.passwd.hold failed The error is in /usr/src/usr.sbin/rpc.yppasswdd/yppasswdd_server.c where dirname() is used twice (line 609 and 832). Both lines have the code: if (pw_init(dirname(passfile), passfile)) { It looks like the implementation of dirname in 12.0 RELEASE has changed to now apply changes to the string passed into the function. The change is to make the call thread safe according to the updated manual entry. The problem here is that the call to dirname() now truncates "passfile" meaning the variable no longer holds the path to the master password file, rather just the directory and hence the error. In order to use dirname() now "passfile" will need to be copied before being passed into dirname().
Created attachment 201374 [details] Fixes issue when rpc.yppasswdd fails to copy master.passwd As of FreeBSD 12.0 rpc.yppasswdd was failing to copy the master.passwd file due to call pw_init truncating the filename value stored in passfile This fix copies the value of passfile to a temporary variable, passdir. This prevents passfile from being truncated while also allowing the necessary directory name to be passed.
(In reply to Edward Fuhr from comment #1) I wish it to be known that this is my own amateur-hour patch, and in no way should this be considered an official patch. I thought the description was for the file and not to replace the blurb previously written up specifying this is NOT an official patch, but my own doing.
(In reply to Edward Fuhr from comment #2) Thanks for looking into this Edward. A quick comment on your patch. I think you have forgotten to initialise "passdir_buf" in "yppasswdproc_update_master_1_svc". I suspect you need to add: /* Hold a copy of the passfile in passdir */ snprintf(passdir_buf, sizeof(passdir_buf), "%s", passfile); passdir = (char *)&passdir_buf; around line 831 in the current file, otherwise passdir_buf will not be initialised with passfile.
I am running into the same problem on a recently installed box running 12.0-stable. I'd like to know if it's to be expected that this bug gets fixed offically any time soon. Thank you
A commit references this bug: Author: markj Date: Mon Jun 3 16:51:07 UTC 2019 New revision: 348547 URL: https://svnweb.freebsd.org/changeset/base/348547 Log: rpc.yppasswdd: Fix dirname(3) usage after r305952. PR: 234972 Submitted by: Edward Fuhr <edward.fuhr@us.fujitsu.com> (original) MFC after: 3 days Changes: head/usr.sbin/rpc.yppasswdd/yppasswdd_server.c
It works. Thanks a lot
A commit references this bug: Author: markj Date: Thu Jun 6 03:01:06 UTC 2019 New revision: 348716 URL: https://svnweb.freebsd.org/changeset/base/348716 Log: MFC r348547: rpc.yppasswdd: Fix dirname(3) usage after r305952. PR: 234972 Changes: _U stable/12/ stable/12/usr.sbin/rpc.yppasswdd/yppasswdd_server.c
Thanks for the report and analysis.