Bug 230937

Summary: nfsuserd - missing endpwent() and endgrent() before daemon() & fork()
Product: Base System Reporter: Peter Eriksson <peter.x.eriksson>
Component: binAssignee: Mark Johnston <markj>
Status: Closed FIXED    
Severity: Affects Some People CC: emaste, markj, rmacklem
Priority: --- Keywords: patch
Version: 11.2-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch to /usr/src/usr.sbin/nfsuserd/nfsuserd.c none

Description Peter Eriksson 2018-08-27 13:58:04 UTC
Created attachment 196598 [details]
Patch to /usr/src/usr.sbin/nfsuserd/nfsuserd.c

We are using a (own developed) DB based backend for nsswitch in order to improve speed for our file servers. After upgrading to 11.2 we noticed that we had problems on one of them in that initially on a newly booted server NFS clients correctly saw user & group names but then after a short while the client started reporting "nobody" instead.

Investigating this issue it seemed to be connected to the cache timeout as specified for the nfsuserd daemon (we used 10 minutes). Any uid -> name or gid -> name lookups after the timeout limit would just return "nobody".

Looking at the source code for nfsuserd.c I noticed missing endpwent() and endgrent() calls during the initial cache priming of users & groups and before the slave workers processes were forked off, and adding those made this work nicely again. 

Please find enclosed a (very) simple patch that adds those missing calls.
Comment 1 Rick Macklem freebsd_committer freebsd_triage 2018-08-27 20:39:47 UTC
Patch looks fine to me. Unfortunately the timing is bad to commit it to
head/current. It is in code freeze and I'll won't be able to do any commits
for at least 2 weeks starting Wednesday (moving across Canada to BC).

Maybe someone else could ask re@ for permission to commit it?

If not, I will do so when I can.

Thanks for submitting the patch, rick
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2018-08-27 20:43:48 UTC
(In reply to Rick Macklem from comment #1)
I'd be happy to get it in head/ provided that you're not expecting any extra testing from me.
Comment 3 Rick Macklem freebsd_committer freebsd_triage 2018-08-27 22:01:05 UTC
If you'd like to commit it that sounds fine to me. I gave it a quick test and it is a very straightforward patch.
Comment 4 commit-hook freebsd_committer freebsd_triage 2018-08-28 15:18:25 UTC
A commit references this bug:

Author: markj
Date: Tue Aug 28 15:18:14 UTC 2018
New revision: 338350
URL: https://svnweb.freebsd.org/changeset/base/338350

Log:
  Add missing endpwent() and endgrent() calls to nfsuserd(8).

  PR:		230937
  Submitted by:	Peter Eriksson <peter@ifm.liu.se>
  Reviewed by:	rmacklem
  Approved by:	re (gjb)
  MFC after:	1 week

Changes:
  head/usr.sbin/nfsuserd/nfsuserd.c
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-09-04 16:45:37 UTC
A commit references this bug:

Author: markj
Date: Tue Sep  4 16:45:09 UTC 2018
New revision: 338455
URL: https://svnweb.freebsd.org/changeset/base/338455

Log:
  MFC r338350:
  Add missing endpwent() and endgrent() calls to nfsuserd(8).

  PR:	230937

Changes:
_U  stable/11/
  stable/11/usr.sbin/nfsuserd/nfsuserd.c