DH_INSTALLNSS(1)

πŸ“¦
version 1.7build1 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’… DH_INSTALLNSS πŸ’…

okay so bestie, this is dh_installnss(1) from the User Contributed Perl Documentation section of the manual. it's a whole manual page, she's got lore, she's got range, and she's about to make your /etc/nsswitch.conf look right. πŸŽ€


✨ NAME ✨

dh_installnss β€” enable NSS services πŸ¦‹


🌸 SYNOPSIS 🌸

dh_installnss [debhelper options]

πŸ’– DESCRIPTION πŸ’–

so dh_installnss is a debhelper program and her whole job, her entire purpose, her main character moment, is injecting NSS (that's Name Service Switch, iykyk) services into /etc/nsswitch.conf. that's it. that's the gig. πŸ’…


πŸŽ€ FILES πŸŽ€

  • debian/package.nss β€” this file lists the services to inject into /etc/nsswitch.conf when a package is configured, and the ones to remove when a package is removed or purged. bestie behaviour fr fr.

every line in that file (we call each one a directive) should look like this:

db position service action condition

and here's what each field is actually saying:

  • db β€” the NSS database where the service is gonna get added. usually it's "hosts". classic.
  • position β€” where to add the NSS service.

the possible values are "first", "last", "before=service", "after=service", plus these three pseudo-positions: "remove-only", "database-add" and "database-require".

the pseudo-position "remove-only" is for marking services that are NOT gonna be added when the package installs, but WILL be removed when it deinstalls (think legacy services, the exes that never leave 🫠).

the pseudo-position "database-add" is used to request adding a non-standard NSS database to /etc/nsswitch.conf during the package's installation, and removing it during deinstallation. ⚠️ when you use "database-add", every other field in the directive should be left empty. no extras, she's minimalist.

the pseudo-position "database-require" is announcing that one or more services in the nss file are gonna be installed under a non-standard NSS database that some other package added. ⚠️ when you use "database-require", again, all the other fields in the directive should be left empty.

  • service β€” the name of the NSS service to add. iconic, no notes.
  • action β€” optional action specification, and it looks like "[STATE=ACTION]".
  • condition β€” optional set of conditions that better define when a service should (or should not) get installed.

only one kind of condition is defined right now: "skip-if-present=service,service,...".

also, literally anything between a # character and the end of the line gets ignored. comments, we love her. πŸ’œ


🌈 EXAMPLES 🌈

an example debian/nss file could look like this:

hosts before=dns mdns4
hosts before=mdns4 mdns4_minimal [NOTFOUND=return]
hosts remove-only mdns    # In case the user manually added it

so after this package installs, the original configuration of the hosts database in /etc/nsswitch.conf changes from:

hosts:    files dns

to:

hosts:    files mdns4_minimal [NOTFOUND=return] mdns4 dns

the glow up is REAL. ✨


⚠️ CAVEATS ⚠️

πŸ’€ Non-standard NSS databases πŸ’€

okay this is the serious part, listen up bestie, no cap:

directives in a package.nss file can reference a non-standard NSS database only if that database has first been declared with a "database-add" or "database-require" directive in the same file. same file. don't try it anywhere else.

and what counts as a non-standard NSS database? it's all databases that are not defined in /etc/nsswitch.conf as shipped by the package base-files. that's the line.

if a directive references an undeclared non-standard NSS database (like "somedb"), dh_installnss will exit with the error message "Unknown NSS database 'somedb'". πŸ’€

a non-standard NSS database can be declared by at most one installed package. in other words: if the directives in the nss files of two packages, A and B, reference the same non-standard NSS database "somedb", and both packages can be installed at the same time, you gotta implement one of these two solutions:

  1. Package A supplies the "somedb database-add" directive, package B Pre-Depends on A and uses a "somedb database-require" directive.
  2. The shared package C supplies the "somedb database-add" directive, both package A and B Pre-Depend on C and use a "somedb database-require" directive.

pick one, don't freestyle it. πŸ™ˆ


πŸ‘€ SEE ALSO πŸ‘€


πŸ‘‘ AUTHOR πŸ‘‘

Gioele Barabucci <gioele@svario.it> β€” the icon who wrote this, we stan 🫢


and that's a wrap, my love πŸ’– this page is from perl v5.40.1, dated 2025-12-08, and you're officially NSS-pilled now. go forth and slay your nsswitch.conf. πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from