root@km:~ # grep ^defaultgroup /etc/pw.conf defaultgroup = "user" root@km:~ # pw groupshow user user:*:1000: root@km:~ # pw useradd kabanov root@km:~ # id kabanov uid=1141(kabanov) gid=1141(kabanov) groups=1141(kabanov) root@km:~ # freebsd-version 10.3-RELEASE-p17 root@km:~ # Expected behavior: kabanov's primary group should be "user". Other settings (e.g. defaultshell) are being ignored too.
reproducible on 11.0-STABLE r312369
Created attachment 180987 [details] respect defaultgroup specified in pw.conf Proposed fix: respect defaultgroup specified in pw.conf
(In reply to Eugene Grosbein from comment #2) Eugene, in 10.3 pw.conf seems to be totally ignored, not only the defaultgroup setting. ktrace/kdump does not show pw.conf being opened at all.
Created attachment 180993 [details] Proposed fix Properly initialize cfg variable. Respect defaultgroup if specified in pw.conf.
(In reply to vas from comment #3) Please try new patch. It adds some needed initialisation to variables. Tested with 10.3-STABLE and 11.0-STABLE.
Can you also make a regression test when the refactoring of pw happened we added plenty of regression tests, would be nice to have a regression test for this case.
(In reply to Baptiste Daroussin from comment #6) Where can I read about how to do that?
usr.sbin/pw/tests you will have all the tests. make install will install them in /usr/tests/usr.sbin/pw you would need to install kyua from ports to execute them and access to the documentation: kyua test in that directory would run the tests man 3 atf-sh will give you a bit of documentation. I'm sorry there are not much more documentation, if that is too painful to make a test I will make a test myself afterward. Btw you patch looks good to me so you can anyway consider it approved :)
A commit references this bug: Author: eugen Date: Fri Mar 24 16:18:58 UTC 2017 New revision: 315912 URL: https://svnweb.freebsd.org/changeset/base/315912 Log: Properly initialise with content of pw.conf(5) that was mistakenly ignored. 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 Changes: head/usr.sbin/pw/pw_user.c
A commit references this bug: Author: bapt Date: Sat Mar 25 10:47:58 UTC 2017 New revision: 315935 URL: https://svnweb.freebsd.org/changeset/base/315935 Log: Add a regression test for r31512 fix PR: 217934 MFC after: 1 week Changes: head/usr.sbin/pw/tests/pw_useradd_test.sh
Yes, the proposed fix works on 10.3, thanks!
Take it as I've commited a fix.
(In reply to Baptiste Daroussin from comment #8) Another bug was reported to me in local IRC channel: pw usedmod username -G '' is broken too. It it supposed to remove username from all supplementary groups but does nothing. Please take a look on another patch fixing this: http://www.grosbein.net/freebsd/patches/pw-G.diff
Gentlemen, While we are at it :-) Could someone please add "-Y" to "pw lock"?
(In reply to Eugene Grosbein from comment #13) Looks good to me, maybe this time you can add a regression test? I have added one for the previous change https://svnweb.freebsd.org/changeset/base/315935 if you want an example :)
(In reply to vas from comment #14) forcing us to use/test NIS in 2017 you are being hard with us :)
(In reply to Baptiste Daroussin from comment #16) There is still no viable alternative to NIS in FreeBSD, even in 2017. "-Y" is supported anyway in all other modes of pw :-)
A commit references this bug: Author: bapt Date: Sat Apr 1 09:27:00 UTC 2017 New revision: 316347 URL: https://svnweb.freebsd.org/changeset/base/316347 Log: MFC: r315912 (by eugen@) and r315935 Properly initialise with content of pw.conf(5) that was mistakenly ignored. Also, respect "defaultgroup" if specified there. Add a regression test PR: 217934 Reported by: Victor Sudakov <vas@mpeks.tomsk.su> Changes: _U stable/11/ stable/11/usr.sbin/pw/pw_user.c stable/11/usr.sbin/pw/tests/pw_useradd_test.sh
A commit references this bug: Author: bapt Date: Sat Apr 1 09:29:47 UTC 2017 New revision: 316348 URL: https://svnweb.freebsd.org/changeset/base/316348 Log: MFC: r315912 (by eugen@) and r315935 Properly initialise with content of pw.conf(5) that was mistakenly ignored. Also, respect "defaultgroup" if specified there. Add a regression test PR: 217934 Submitted by: Victor Sudakov <vas@mpeks.tomsk.su> Changes: _U stable/10/ stable/10/usr.sbin/pw/pw_user.c stable/10/usr.sbin/pw/tests/pw_useradd_test.sh
Fix committed and MFC'd. To submitter: please fill another PR for "pw lock -Y" if you still need it. If possible, try to prepare a fix and test it because NIS environment a bit specific.
(In reply to Eugene Grosbein from comment #20) > To submitter: please fill another PR for "pw lock -Y" There is one already: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=87529 Yes, I still need it.