This seems to come up in various bugtrackers from time to time: Debian #46049, Debian #711001, RH #133683. But none of these seem to be implemented.
To recap: the Name Service Switch reads /etc/nsswitch.conf
where to look for e.g. services
information:
$ strace -f -e open,stat getent services > /dev/null
[...]
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/libnss_db.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/usr/lib/x86_64-linux-gnu/libdb-5.3.so", O_RDONLY|O_CLOEXEC) = 3
open("/var/lib/misc/DB_CONFIG", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/var/lib/misc/services.db", 0x7ffd79d77060) = -1 ENOENT (No such file or directory)
open("/etc/services", O_RDONLY|O_CLOEXEC) = 3
+++ exited with 0 +++
This libnss_db.so.2
could only be found because I installed libnss-db earlier. So, if one manages to create a Berkeley DB database in /var/lib/misc/services.db
with additional service names, this could work.
Update: with libnss-db
(Debian/unstable here), this is indeed possible:
$ grep ^[A-Z] /etc/default/libnss-db
ETC = /etc/local
DBS = services
VAR_DB = /var/lib/misc
AWK = awk
MAKEDB = makedb --quiet
$ cat /etc/local/services
# Local services
foobar 1234/tcp # Foo
barbaz 4321/udp
$ make
services... done.
$ getent services | wc -l
559
$ getent services foobar barbaz
foobar 1234/tcp
barbaz 4321/udp
And since /etc/local
is not a registered configuration directory, it should not be touched by any upgrade process
Otherwise, these pathnames seem to be hardcoded and can only be changed/extended in a recompile, hence the wishlist tickets mentioned above.
$ strings /lib/x86_64-linux-gnu/libnss_files.so.2 | grep services
/etc/services
Note: there's also an libnss-extrausers package, which seems to provide additional files for NSS, but only for passwd
, shadow
and group
information.
/etc/services
is there a way to say "include services.locale
" so that I only have to change one file between package updates and only need tocat >
the include command? – Foo Bar Apr 21 '15 at 06:00cat /etc/services.local /etc/services.debian >/etc/services
when you change/etc/services.local
. – Gilles 'SO- stop being evil' Apr 21 '15 at 07:54