From 05d02af841c1902232470b148dbb6e30850707d5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Oct 2016 23:01:23 -0400 Subject: ./tools/notsd-move --- src/nss-myhostname/Makefile | 48 ++++++++++- src/nss-myhostname/nss-myhostname.c | 16 ++-- src/nss-myhostname/nss-myhostname.xml | 148 ++++++++++++++++++++++++++++++++++ 3 files changed, 203 insertions(+), 9 deletions(-) mode change 120000 => 100644 src/nss-myhostname/Makefile create mode 100644 src/nss-myhostname/nss-myhostname.xml (limited to 'src/nss-myhostname') diff --git a/src/nss-myhostname/Makefile b/src/nss-myhostname/Makefile deleted file mode 120000 index d0b0e8e008..0000000000 --- a/src/nss-myhostname/Makefile +++ /dev/null @@ -1 +0,0 @@ -../Makefile \ No newline at end of file diff --git a/src/nss-myhostname/Makefile b/src/nss-myhostname/Makefile new file mode 100644 index 0000000000..1266394e46 --- /dev/null +++ b/src/nss-myhostname/Makefile @@ -0,0 +1,47 @@ +# -*- Mode: makefile; indent-tabs-mode: t -*- +# +# This file is part of systemd. +# +# Copyright 2010-2012 Lennart Poettering +# Copyright 2010-2012 Kay Sievers +# Copyright 2013 Zbigniew Jędrzejewski-Szmek +# Copyright 2013 David Strauss +# Copyright 2016 Luke Shumaker +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# systemd is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with systemd; If not, see . +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/build-aux/Makefile.head.mk + +ifneq ($(HAVE_MYHOSTNAME),) +libnss_myhostname_la_SOURCES = \ + src/nss-myhostname/nss-myhostname.sym \ + src/nss-myhostname/nss-myhostname.c + +libnss_myhostname_la_LDFLAGS = \ + -module \ + -export-dynamic \ + -avoid-version \ + -shared \ + -shrext .so.2 \ + -Wl,--version-script=$(srcdir)/nss-myhostname.sym + +libnss_myhostname_la_LIBADD = \ + libsystemd-internal.la \ + libsystemd-basic.la + +lib_LTLIBRARIES += \ + libnss_myhostname.la +endif # HAVE_MYHOSTNAME + +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c index 11c27575c0..862ad2fcb5 100644 --- a/src/nss-myhostname/nss-myhostname.c +++ b/src/nss-myhostname/nss-myhostname.c @@ -24,14 +24,14 @@ #include #include -#include "alloc-util.h" -#include "hostname-util.h" -#include "local-addresses.h" -#include "macro.h" -#include "nss-util.h" -#include "signal-util.h" -#include "string-util.h" -#include "util.h" +#include "sd-netlink/local-addresses.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/hostname-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/nss-util.h" +#include "systemd-basic/signal-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/util.h" /* We use 127.0.0.2 as IPv4 address. This has the advantage over * 127.0.0.1 that it can be translated back to the local hostname. For diff --git a/src/nss-myhostname/nss-myhostname.xml b/src/nss-myhostname/nss-myhostname.xml new file mode 100644 index 0000000000..a920ec334f --- /dev/null +++ b/src/nss-myhostname/nss-myhostname.xml @@ -0,0 +1,148 @@ + + + + + + + + + nss-myhostname + systemd + + + + Developer + Lennart + Poettering + lennart@poettering.net + + + + + + nss-myhostname + 8 + + + + nss-myhostname + libnss_myhostname.so.2 + Provide hostname resolution for the locally + configured system hostname. + + + + libnss_myhostname.so.2 + + + + Description + + nss-myhostname is a plug-in module for the GNU Name Service Switch (NSS) functionality of + the GNU C Library (glibc), primarily providing hostname resolution for the locally configured + system hostname as returned by + gethostname2. The precise + hostnames resolved by this module are: + + + The local, configured hostname is resolved to + all locally configured IP addresses ordered by their scope, or + — if none are configured — the IPv4 address 127.0.0.2 (which + is on the local loopback) and the IPv6 address ::1 (which is the + local host). + + The hostnames localhost and + localhost.localdomain (as well as any hostname + ending in .localhost or .localhost.localdomain) + are resolved to the IP addresses 127.0.0.1 and ::1. + + The hostname gateway is + resolved to all current default routing gateway addresses, + ordered by their metric. This assigns a stable hostname to the + current gateway, useful for referencing it independently of the + current network configuration state. + + + Various software relies on an always-resolvable local + hostname. When using dynamic hostnames, this is traditionally + achieved by patching /etc/hosts at the same + time as changing the hostname. This is problematic since it + requires a writable /etc file system and is + fragile because the file might be edited by the administrator at + the same time. With nss-myhostname enabled, + changing /etc/hosts is unnecessary, and on + many systems, the file becomes entirely optional. + + To activate the NSS modules, add myhostname to the line starting with + hosts: in /etc/nsswitch.conf. + + It is recommended to place myhostname last in the nsswitch.conf' + hosts: line to make sure that this mapping is only used as fallback, and that any DNS or + /etc/hosts based mapping takes precedence. + + + + Example + + Here is an example /etc/nsswitch.conf file that enables + nss-myhostname correctly: + +passwd: compat mymachines +group: compat mymachines +shadow: compat + +hosts: files mymachines resolve myhostname +networks: files + +protocols: db files +services: db files +ethers: db files +rpc: db files + +netgroup: nis + + To test, use glibc's getent tool: + + $ getent ahosts `hostname` +::1 STREAM omega +::1 DGRAM +::1 RAW +127.0.0.2 STREAM +127.0.0.2 DGRAM +127.0.0.2 RAW + + In this case, the local hostname is omega. + + + + + See Also + + systemd1, + nss-resolve8, + nss-mymachines8, + nsswitch.conf5, + getent1 + + + + -- cgit v1.2.3-54-g00ecf