]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
uuidd: improve socket activation error messaging
authorSami Kerola <kerolasa@iki.fi>
Sat, 5 Sep 2015 18:56:36 +0000 (19:56 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 2 Oct 2015 10:38:30 +0000 (12:38 +0200)
Tell more exactly what is wrong and how, and give hint how to recover
when possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
misc-utils/uuidd.c

index 1cbdeef20f0939d8f10f13a86a9769a2f258e4a1..9d6d08d9f04179c507ddce28ac0f031608e349f8 100644 (file)
@@ -360,9 +360,17 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
 
 #ifdef HAVE_LIBSYSTEMD
        if (uuidd_cxt->no_sock) {
-               if (sd_listen_fds(0) != 1)
-                       errx(EXIT_FAILURE, _("no or too many file descriptors received"));
-
+               const int ret = sd_listen_fds(0);
+
+               if (ret < 0) {
+                       errno = ret * -1;
+                       err(EXIT_FAILURE, _("sd_listen_fds() failed"));
+               } else if (ret == 0)
+                       errx(EXIT_FAILURE,
+                            _("no file descriptors received, check systemctl status uuidd.socket"));
+               else if (1 < ret)
+                       errx(EXIT_FAILURE,
+                            _("too many file descriptors received, check uuidd.socket"));
                s = SD_LISTEN_FDS_START + 0;
        }
 #endif