Page MenuHomeFreeBSD

nsswitch.conf: Avoid modification after installation
AcceptedPublic

Authored by markj on Mon, Mar 10, 5:10 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Mar 10, 7:44 PM
Unknown Object (File)
Mon, Mar 10, 4:17 PM
Unknown Object (File)
Mon, Mar 10, 2:12 PM
Subscribers

Details

Summary

To implement WITHOUT_NIS, we have a hack in the build which modifies the
installed nsswitch.conf to remove NIS compat providers and databases.
This hack operates on the installed nsswitch.conf, which means that the
installed file size won't match that listed in the metalog.

One option would be to maintain two copies of nsswitch.conf, one for
each configuration, but that would result in duplication and I don't see
a clear way around that.

Instead, stage a copy of nsswitch.conf in the libc objdir, and modify
that one before installing, so that the version recorded in the metalog
matches what actually gets installed.

PR: 209718
Sponsored by: Klara, Inc.
Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 62866
Build 59750: arc lint + arc unit

Event Timeline

markj requested review of this revision.Mon, Mar 10, 5:10 AM
lib/libc/net/Makefile.inc
182

I somewhat wonder if this should actually be .PHONY -- we don't have a good way to record dependencies on build options, so toggling between WITH and WITHOUT won't regenerate this without manual intervention, presumably

lib/libc/net/Makefile.inc
182

(Realizing that this is a more general problem, but for this speciifc case it could be considered a regression since it previously only mattered the value of the knob at install time)

I think this is a fine short term approach (IMO it's no worse than the existing modify-nsswitch-conf target).

That said maybe we can accommodate @kevans comment with something like

.if ${MK_NIS} != "no"
CONFS+=net/nsswitch.conf
.else
${.OBJDIR}/nsswitch.conf

all: ${.OBJDIR}/nsswitch.conf
...

i.e., if NIS is not turned off we add the unmodified conf file, and if it is turned off we use the extra build stuff?

This revision is now accepted and ready to land.Mon, Mar 10, 6:31 PM

Try to avoid breaking incremental rebuilds if WITHOUT_NIS flips in between
successive builds.

This revision now requires review to proceed.Tue, Mar 11, 11:20 AM
markj added inline comments.
lib/libc/net/Makefile.inc
182

I took Ed's suggestion since it lets us avoid doing unnecessary work during incremental builds, which seems like good practice even though it's quite negligible in this case.

kevans added inline comments.
lib/libc/net/Makefile.inc
182

Yeah, I quite like that as well - thanks!

This revision is now accepted and ready to land.Tue, Mar 11, 12:03 PM

This could be done with sed < ${LIBC_SRCTOP}/net/nsswitch.conf > ${.TARGET} rather than the in-place sed, but not a big deal