INN commit: branches/2.6 (6 files)

INN Commit rra at isc.org
Fri Mar 26 19:02:37 UTC 2021


    Date: Friday, March 26, 2021 @ 12:02:36
  Author: iulius
Revision: 10552

Add C stubs to a few systemd functions

Integrated from latest rra-c-util upstream version.

Added:
  branches/2.6/lib/sd-daemon.c
    (from rev 10547, trunk/lib/sd-daemon.c)
Modified:
  branches/2.6/MANIFEST
  branches/2.6/include/portable/sd-daemon.h
  branches/2.6/lib/Makefile
  branches/2.6/m4/systemd.m4
  branches/2.6/support/getrra-c-util

------------------------------+
 MANIFEST                     |    1 
 include/portable/sd-daemon.h |   34 +++++++++++++++-----
 lib/Makefile                 |   67 ++++++++++++++++++++++-------------------
 lib/sd-daemon.c              |   41 +++++++++++++++++++++++++
 m4/systemd.m4                |   12 ++++---
 support/getrra-c-util        |    1 
 6 files changed, 111 insertions(+), 45 deletions(-)

Modified: MANIFEST
===================================================================
--- MANIFEST	2021-03-26 18:59:40 UTC (rev 10551)
+++ MANIFEST	2021-03-26 19:02:36 UTC (rev 10552)
@@ -541,6 +541,7 @@
 lib/remopen.c                         Open a remote NNTP connection
 lib/reservedfd.c                      File descriptor reservation
 lib/resource.c                        Get process CPU usage
+lib/sd-daemon.c                       Stubs for systemd library functions
 lib/sendarticle.c                     Send an article, NNTP style
 lib/sendpass.c                        Send NNTP authentication
 lib/sequence.c                        Sequence space arithmetic routines

Modified: include/portable/sd-daemon.h
===================================================================
--- include/portable/sd-daemon.h	2021-03-26 18:59:40 UTC (rev 10551)
+++ include/portable/sd-daemon.h	2021-03-26 19:02:36 UTC (rev 10552)
@@ -2,16 +2,24 @@
  *
  * Portability wrapper around systemd-daemon headers.
  *
- * Currently, only sd_listen_fds and sd_notify are guaranteed to be provided
- * by this interface.  This takes the approach of stubbing out these functions
- * if the libsystemd-daemon library is not available, rather than providing a
- * local implementation, on the grounds that anyone who wants systemd status
- * reporting should be able to build with the systemd libraries.
+ * Currently, only sd_is_socket, sd_listen_fds, sd_notify, and sd_notifyf are
+ * guaranteed to be provided by this interface.  This takes the approach of
+ * stubbing out these functions if the libsystemd-daemon library is not
+ * available, rather than providing a local implementation, on the grounds
+ * that anyone who wants systemd status reporting should be able to build with
+ * the systemd libraries.  In particular, sd_is_socket always returns false
+ * and does not perform its intended function.
  *
+ * The stubs for sd_notify and sd_notifyf provided as functions, rather than
+ * using #define, to allow for the variadic function and to avoid compiler
+ * warnings when they are used without assigning the return value as is
+ * recommended in the sd_notify(3) man page.
+ *
  * The canonical version of this file is maintained in the rra-c-util package,
  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
  *
  * Written by Russ Allbery <eagle at eyrie.org>
+ * Copyright 2021 Russ Allbery <eagle at eyrie.org>
  * Copyright 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -26,13 +34,21 @@
 #ifndef PORTABLE_SD_DAEMON_H
 #define PORTABLE_SD_DAEMON_H 1
 
+#include "config.h"
+#include "portable/macros.h"
+
+BEGIN_DECLS
+
 #ifdef HAVE_SD_NOTIFY
 #    include <systemd/sd-daemon.h>
 #else
-#    define SD_LISTEN_FDS_START        3
-#    define sd_is_socket(fd, f, t, l)  0
-#    define sd_listen_fds(u)           0
-#    define sd_notify(u, s)            0
+#    define SD_LISTEN_FDS_START       3
+#    define sd_is_socket(fd, f, t, l) 0
+#    define sd_listen_fds(u)          0
+int sd_notify(int, const char *);
+int sd_notifyf(int, const char *, ...);
 #endif
 
+END_DECLS
+
 #endif /* !PORTABLE_SD_DAEMON_H */

Modified: lib/Makefile
===================================================================
--- lib/Makefile	2021-03-26 18:59:40 UTC (rev 10551)
+++ lib/Makefile	2021-03-26 19:02:36 UTC (rev 10552)
@@ -30,7 +30,7 @@
 EXTRA_SOURCES = alloca.c asprintf.c fseeko.c ftello.c getaddrinfo.c	   \
 		getnameinfo.c getpagesize.c inet_aton.c inet_ntoa.c	   \
 		inet_ntop.c mkstemp.c pread.c pwrite.c            \
-	        reallocarray.c setenv.c                                    \
+	        reallocarray.c sd-daemon.c setenv.c                        \
 		seteuid.c setproctitle.c snprintf.c strcasecmp.c strlcat.c \
 		strlcpy.c strspn.c strtok.c symlink.c
 
@@ -346,11 +346,11 @@
 network.o: network.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \
-  ../include/inn/defines.h ../include/inn/options.h ../include/clibrary.h \
-  ../include/config.h ../include/inn/macros.h \
-  ../include/portable/stdbool.h ../include/portable/socket.h \
-  ../include/portable/macros.h ../include/portable/getaddrinfo.h \
-  ../include/portable/getnameinfo.h ../include/inn/fdflag.h \
+  ../include/inn/defines.h ../include/inn/options.h \
+  ../include/portable/socket.h ../include/portable/macros.h \
+  ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
+  ../include/clibrary.h ../include/config.h ../include/inn/macros.h \
+  ../include/portable/stdbool.h ../include/inn/fdflag.h \
   ../include/inn/portable-socket.h ../include/inn/innconf.h \
   ../include/inn/messages.h ../include/inn/network.h \
   ../include/inn/xmalloc.h ../include/inn/xwrite.h
@@ -357,11 +357,11 @@
 network-innbind.o: network-innbind.c ../include/config.h \
   ../include/inn/defines.h ../include/inn/system.h ../include/inn/macros.h \
   ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \
-  ../include/inn/defines.h ../include/inn/options.h ../include/clibrary.h \
-  ../include/config.h ../include/inn/macros.h \
-  ../include/portable/stdbool.h ../include/portable/socket.h \
-  ../include/portable/macros.h ../include/portable/getaddrinfo.h \
-  ../include/portable/getnameinfo.h ../include/inn/innconf.h \
+  ../include/inn/defines.h ../include/inn/options.h \
+  ../include/portable/socket.h ../include/portable/macros.h \
+  ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
+  ../include/clibrary.h ../include/config.h ../include/inn/macros.h \
+  ../include/portable/stdbool.h ../include/inn/innconf.h \
   ../include/inn/libinn.h ../include/inn/concat.h ../include/inn/xmalloc.h \
   ../include/inn/xwrite.h ../include/inn/messages.h \
   ../include/inn/network.h ../include/inn/portable-socket.h \
@@ -551,11 +551,11 @@
 getaddrinfo.o: getaddrinfo.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \
-  ../include/inn/defines.h ../include/inn/options.h ../include/clibrary.h \
-  ../include/config.h ../include/inn/macros.h \
-  ../include/portable/stdbool.h ../include/portable/socket.h \
-  ../include/portable/macros.h ../include/portable/getaddrinfo.h \
-  ../include/portable/getnameinfo.h
+  ../include/inn/defines.h ../include/inn/options.h \
+  ../include/portable/socket.h ../include/portable/macros.h \
+  ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
+  ../include/clibrary.h ../include/config.h ../include/inn/macros.h \
+  ../include/portable/stdbool.h
 getnameinfo.o: getnameinfo.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \
@@ -571,27 +571,27 @@
 inet_aton.o: inet_aton.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \
-  ../include/inn/defines.h ../include/inn/options.h ../include/clibrary.h \
-  ../include/config.h ../include/inn/macros.h \
-  ../include/portable/stdbool.h ../include/portable/socket.h \
-  ../include/portable/macros.h ../include/portable/getaddrinfo.h \
-  ../include/portable/getnameinfo.h
+  ../include/inn/defines.h ../include/inn/options.h \
+  ../include/portable/socket.h ../include/portable/macros.h \
+  ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
+  ../include/clibrary.h ../include/config.h ../include/inn/macros.h \
+  ../include/portable/stdbool.h
 inet_ntoa.o: inet_ntoa.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \
-  ../include/inn/defines.h ../include/inn/options.h ../include/clibrary.h \
-  ../include/config.h ../include/inn/macros.h \
-  ../include/portable/stdbool.h ../include/portable/socket.h \
-  ../include/portable/macros.h ../include/portable/getaddrinfo.h \
-  ../include/portable/getnameinfo.h
+  ../include/inn/defines.h ../include/inn/options.h \
+  ../include/portable/socket.h ../include/portable/macros.h \
+  ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
+  ../include/clibrary.h ../include/config.h ../include/inn/macros.h \
+  ../include/portable/stdbool.h
 inet_ntop.o: inet_ntop.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \
-  ../include/inn/defines.h ../include/inn/options.h ../include/clibrary.h \
-  ../include/config.h ../include/inn/macros.h \
-  ../include/portable/stdbool.h ../include/portable/socket.h \
-  ../include/portable/macros.h ../include/portable/getaddrinfo.h \
-  ../include/portable/getnameinfo.h
+  ../include/inn/defines.h ../include/inn/options.h \
+  ../include/portable/socket.h ../include/portable/macros.h \
+  ../include/portable/getaddrinfo.h ../include/portable/getnameinfo.h \
+  ../include/clibrary.h ../include/config.h ../include/inn/macros.h \
+  ../include/portable/stdbool.h
 mkstemp.o: mkstemp.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \
@@ -616,6 +616,11 @@
   ../include/inn/defines.h ../include/inn/options.h ../include/clibrary.h \
   ../include/config.h ../include/inn/macros.h \
   ../include/portable/stdbool.h
+sd-daemon.o: sd-daemon.c ../include/portable/macros.h \
+  ../include/portable/sd-daemon.h ../include/config.h \
+  ../include/inn/defines.h ../include/inn/system.h ../include/inn/macros.h \
+  ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \
+  ../include/inn/defines.h ../include/inn/options.h
 setenv.o: setenv.c ../include/config.h ../include/inn/defines.h \
   ../include/inn/system.h ../include/inn/macros.h \
   ../include/inn/portable-macros.h ../include/inn/portable-stdbool.h \

Copied: branches/2.6/lib/sd-daemon.c (from rev 10547, trunk/lib/sd-daemon.c)
===================================================================
--- lib/sd-daemon.c	                        (rev 0)
+++ lib/sd-daemon.c	2021-03-26 19:02:36 UTC (rev 10552)
@@ -0,0 +1,41 @@
+/* $Id$
+ *
+ * Stubs for systemd library functions.
+ *
+ * Provides empty stubs for sd_notify and sd_notifyf that do nothing and
+ * return 0, similar to the behavior of the proper library functions if not
+ * run under systemd.  Unsetting the environment (the first argument) is not
+ * supported.
+ *
+ * The canonical version of this file is maintained in the rra-c-util package,
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
+ *
+ * Copyright 2021 Russ Allbery <eagle at eyrie.org>
+ *
+ * Copying and distribution of this file, with or without modification, are
+ * permitted in any medium without royalty provided the copyright notice and
+ * this notice are preserved.  This file is offered as-is, without any
+ * warranty.
+ *
+ * SPDX-License-Identifier: FSFAP
+ */
+
+#include "portable/macros.h"
+#include "portable/sd-daemon.h"
+
+/* Used for unused parameters to silence gcc warnings. */
+#define UNUSED __attribute__((__unused__))
+
+
+int
+sd_notify(int unset_environment UNUSED, const char *state UNUSED)
+{
+    return 0;
+}
+
+
+int
+sd_notifyf(int unset_environment UNUSED, const char *state UNUSED, ...)
+{
+    return 0;
+}

Modified: m4/systemd.m4
===================================================================
--- m4/systemd.m4	2021-03-26 18:59:40 UTC (rev 10551)
+++ m4/systemd.m4	2021-03-26 19:02:36 UTC (rev 10552)
@@ -7,9 +7,10 @@
 dnl to use to control whether to install unit files.
 dnl
 dnl Provides the INN_LIB_SYSTEMD_DAEMON_OPTIONAL macro, which sets
-dnl SYSTEMD_CFLAGS and SYSTEMD_LIBS substitution variables if
-dnl libsystemd-daemon is available and defines HAVE_SD_NOTIFY.  pkg-config
-dnl support for libsystemd-daemon is required for it to be detected.
+dnl SYSTEMD_CFLAGS and SYSTEMD_LIBS substitution variables if libsystemd is
+dnl available and defines HAVE_SD_NOTIFY.  Adds sd-daemon.c to LIBOBJS if
+dnl libsystemd is not available.  pkg-config support for libsystemd-daemon is
+dnl required for it to be detected.
 dnl
 dnl Depends on the Autoconf macros that come with pkg-config.
 dnl
@@ -17,7 +18,7 @@
 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
 dnl
 dnl Written by Russ Allbery <eagle at eyrie.org>
-dnl Copyright 2015 Russ Allbery <eagle at eyrie.org>
+dnl Copyright 2015, 2021 Russ Allbery <eagle at eyrie.org>
 dnl Copyright 2013-2014
 dnl     The Board of Trustees of the Leland Stanford Junior University
 dnl
@@ -55,4 +56,5 @@
     [PKG_CHECK_EXISTS([libsystemd-daemon],
         [PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon])
          AC_DEFINE([HAVE_SD_NOTIFY], 1,
-            [Define if sd_notify is available.])])])])
+            [Define if sd_notify is available.])],
+        [AC_LIBOBJ([sd-daemon])])])])

Modified: support/getrra-c-util
===================================================================
--- support/getrra-c-util	2021-03-26 18:59:40 UTC (rev 10551)
+++ support/getrra-c-util	2021-03-26 19:02:36 UTC (rev 10552)
@@ -273,6 +273,7 @@
 download portable/macros.h include/portable macros.h
 download portable/mkstemp.c lib mkstemp.c
 download portable/reallocarray.c lib reallocarray.c
+download portable/sd-daemon.c lib sd-daemon.c
 download portable/sd-daemon.h include/portable sd-daemon.h
 download portable/setenv.c lib setenv.c
 download portable/seteuid.c lib seteuid.c



More information about the inn-committers mailing list