Page MenuHomeFreeBSD

nsswitch.conf: Avoid modification after installation
ClosedPublic

Authored by markj on Mar 10 2025, 5:10 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 30, 7:58 AM
Unknown Object (File)
Mon, Apr 28, 5:30 PM
Unknown Object (File)
Sun, Apr 27, 6:28 AM
Unknown Object (File)
Thu, Apr 24, 4:52 PM
Unknown Object (File)
Mon, Apr 14, 1:54 PM
Unknown Object (File)
Tue, Apr 8, 7:43 PM
Unknown Object (File)
Mon, Apr 7, 1:18 PM
Unknown Object (File)
Mon, Apr 7, 1:17 PM

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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

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

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
183

(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.Mar 10 2025, 6:31 PM

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

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

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
183

Yeah, I quite like that as well - thanks!

This revision is now accepted and ready to land.Mar 11 2025, 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

This revision was automatically updated to reflect the committed changes.
markj marked an inline comment as done.