systemd/optionally-warn-if-nss-myhostname-is-called.patch
Dr. Werner Fink a6c42807cc Accepting request 172582 from home:fcrozat:branches:Base:System
- Update to release 202:
  + 'systemctl list-jobs' got some polishing. '--type=' argument
    may now be passed more than once. 'systemctl list-sockets' has
    been added.
  + systemd gained a new unit 'systemd-static-nodes.service'
    that generates static device nodes earlier during boot, and
    can run in conjunction with udev.
  + systemd-nspawn now places all containers in the new /machine
    top-level cgroup directory in the name=systemd hierarchy.
  + bootchart can now store its data in the journal.
  + journactl can now take multiple --unit= and --user-unit=
    switches.
  + The cryptsetup logic now understands the "luks.key=" kernel
    command line switch. If a configured key file is missing, it
    will fallback to prompting the user.
- Rebase some patches
- Update handle-SYSTEMCTL_OPTIONS-environment-variable.patch to
  properly handle SYSTEMCTL_OPTIONS

- Fix regression in the default for tmp auto-deletion
  (systemd-tmp-safe-defaults.patch, FATE#314974).

- Add chromebook lid switch as a power switch to logind rule to
  enable suspend on lid close

- Update to release 202:
  + 'systemctl list-jobs' got some polishing. '--type=' argument
    may now be passed more than once. 'systemctl list-sockets' has
    been added.
  + systemd gained a new unit 'systemd-static-nodes.service'

OBS-URL: https://build.opensuse.org/request/show/172582
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=365
2013-04-19 20:31:17 +00:00

110 lines
3.6 KiB
Diff

From: Ludwig Nussel <ludwig.nussel@suse.de>
Date: Fri, 20 May 2011 15:38:46 +0200
Subject: optionally warn if nss-myhostname is called
---
configure.ac | 11 +++++++++++
src/nss-myhostname/nss-myhostname.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/configure.ac b/configure.ac
index 5173783..e58d694 100644
--- a/configure.ac
+++ b/configure.ac
@@ -714,6 +714,17 @@ if test "x$enable_myhostname" != "xno"; then
fi
AM_CONDITIONAL(HAVE_MYHOSTNAME, [test "$have_myhostname" = "yes"])
+if test "x$have_myhostname" != "xno"; then
+ AC_MSG_CHECKING([log warning messages for nss-myhostname])
+ AC_ARG_WITH(nss-my-hostname-warning, AS_HELP_STRING([--with-nss-my-hostname-warning], [log warning to syslog when nss-myhostname is called (default=no)]),[],[with_nss_my_hostname_warning=no])
+ AC_MSG_RESULT([$with_nss_my_hostname_warning])
+
+ if test x$with_nss_my_hostname_warning != xno; then
+ AC_CHECK_HEADERS([syslog.h])
+ AC_DEFINE([LOG_NSS_MY_HOSTNAME_WARNING],[1],[whether to log warning message for nss-myhostname])
+ fi
+fi
+
# ------------------------------------------------------------------------------
AC_ARG_WITH(firmware-path,
AS_HELP_STRING([--with-firmware-path=DIR[[[:DIR[...]]]]],
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c
index 884eb99..dbd9a2d 100644
--- a/src/nss-myhostname/nss-myhostname.c
+++ b/src/nss-myhostname/nss-myhostname.c
@@ -30,6 +30,9 @@
#include <net/if.h>
#include <stdlib.h>
#include <arpa/inet.h>
+#ifdef LOG_NSS_MY_HOSTNAME_WARNING
+#include <syslog.h>
+#endif
#include "ifconf.h"
#include "macro.h"
@@ -44,6 +47,10 @@
#define LOCALADDRESS_IPV6 &in6addr_loopback
#define LOOPBACK_INTERFACE "lo"
+#ifdef LOG_NSS_MY_HOSTNAME_WARNING
+static void warn(const char* hn);
+#endif
+
enum nss_status _nss_myhostname_gethostbyname4_r(
const char *name,
struct gaih_addrtuple **pat,
@@ -115,6 +122,10 @@ enum nss_status _nss_myhostname_gethostbyname4_r(
return NSS_STATUS_NOTFOUND;
}
+#ifdef LOG_NSS_MY_HOSTNAME_WARNING
+ warn(hn);
+#endif
+
/* If this fails, n_addresses is 0. Which is fine */
ifconf_acquire_addresses(&addresses, &n_addresses);
@@ -334,6 +345,10 @@ enum nss_status _nss_myhostname_gethostbyname3_r(
return NSS_STATUS_NOTFOUND;
}
+#ifdef LOG_NSS_MY_HOSTNAME_WARNING
+ warn(hn);
+#endif
+
return fill_in_hostent(hn, af, host, buffer, buflen, errnop, h_errnop, ttlp, canonp);
}
@@ -429,6 +444,10 @@ found:
return NSS_STATUS_UNAVAIL;
}
+#ifdef LOG_NSS_MY_HOSTNAME_WARNING
+ warn(hn);
+#endif
+
return fill_in_hostent(hn, af, host, buffer, buflen, errnop, h_errnop, ttlp, NULL);
}
@@ -448,3 +467,19 @@ enum nss_status _nss_myhostname_gethostbyaddr_r(
errnop, h_errnop,
NULL);
}
+
+#ifdef LOG_NSS_MY_HOSTNAME_WARNING
+static void warn(const char* hn) {
+ if (strstr(program_invocation_short_name, "nscd")) {
+ syslog(LOG_WARNING,
+ "Some application tried to resolve hostname \"%s\" which is not in DNS. Stop nscd to find out which one.\n",
+ hn);
+ } else {
+ syslog(LOG_WARNING,
+ "%s(%u) tried to resolve hostname \"%s\" which is not in DNS. This might be the reason for the delays you experience.\n",
+ program_invocation_short_name,
+ getpid(),
+ hn);
+ }
+}
+#endif