Bug 230937 - nfsuserd - missing endpwent() and endgrent() before daemon() & fork()
Summary: nfsuserd - missing endpwent() and endgrent() before daemon() & fork()
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.2-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Mark Johnston
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2018-08-27 13:58 UTC by Peter Eriksson
Modified: 2018-09-04 16:46 UTC (History)
3 users (show)

See Also:


Attachments
Patch to /usr/src/usr.sbin/nfsuserd/nfsuserd.c (337 bytes, patch)
2018-08-27 13:58 UTC, Peter Eriksson
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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