Another one we've had at iXsystems for a while -- although the code there uses a file in /etc, which did not strike me as the best way to do it. This allows us to switch between active and passive servers.
Looks ok to me. (I'll admit I don't understand when it is useful, but that's ok.;-)
The one change I might suggest is a sanity check for the strlen() of the "-V" optarg
being <= MAXHOSTNAMELEN.
I see that you use strlcpy(), so the code is safe w.r.t. not overflowing the buffer on
the stack, but it would result in a truncated hostname and confusion later, for the
case where "strlen(optarg) > MAXHOSTNAMELEN.
Thanks for adding the strlen() check. I am going to be nitpicky and suggest an
error message be printed (not sure if the nfsd should fail or just log an error?),
since silently ignoring the "-V" argument could cause confusion too, I think?
I didn't think it should fail, and since it's a daemon I'd have to have logging set up
to really have a meaningful error; that's why I just let it silently ignore it. I can
put out a warnx call easily enough.