Skip to contentSkip to conversation

mostly uuidd changes

GIT PULL New Sami Kerola 2 participants 6 messages Oct 3, 2015 – Oct 9, 2015 Util-Linux package

lore
Share & tools
lore
#0 lore raw

Hello,

The changes in this pull are pretty simple apart from one, that replaces use of old libc interfaces with newer. That change is a little bit more hairy than the other, but should work just fine.

FYI if you pull the changes from my repository you will see they are signed using my gpg key FDE9B739. See with git log --show-signature.

----------------------------------------------------------------
The following changes since commit fa8945db4aa0526655655526c3ace8fafaf32f8e:
uuidd: improve socket activation error messaging (2015-10-02 12:38:30 +0200)
are available in the git repository at:
git://github.com/kerolasa/lelux-utiliteetit.git uuidd
for you to fetch changes up to 35d009dafa4cfa5ef67996e35c6a38525a91f354:
uuidd: fix shadow declaration (2015-10-03 19:22:58 +0100)
----------------------------------------------------------------

Sami Kerola (4):
uuidd: slice up the usage text and normalize its layout blkid, uuidd, uuidgen: assume getopt.h and getopt.h are available
uuidd: use signalfd() and setup_timer()
uuidd: fix shadow declaration

 misc-utils/Makemodule.am |   4 +-
 misc-utils/blkid.c       |   6 --
 misc-utils/uuidd.c       | 189 +++++++++++++++++++++++++++++------------------
 misc-utils/uuidgen.c     |   8 --
 4 files changed, 120 insertions(+), 87 deletions(-)
Signature · 1 line
2.6.0
#1 lore raw

PATCH 1/4 uuidd: slice up the usage text and normalize its layout

---
 misc-utils/uuidd.c | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)
misc-utils/uuidd.c +17 -19
index 9d6d08d..76f5e41 100644
@@ -69,28 +69,26 @@ struct uuidd_cxt_t {
 static void __attribute__ ((__noreturn__)) usage(FILE * out)
 {
 	fputs(USAGE_HEADER, out);
-	fprintf(out,
-	      _(" %s [options]\n"), program_invocation_short_name);
-
+	fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
 	fputs(USAGE_SEPARATOR, out);
 	fputs(_("A daemon for generating UUIDs.\n"), out);
-
 	fputs(USAGE_OPTIONS, out);
-	fputs(_(" -p, --pid <path>        path to pid file\n"
-		" -s, --socket <path>     path to socket\n"
-		" -T, --timeout <sec>     specify inactivity timeout\n"
-		" -k, --kill              kill running daemon\n"
-		" -r, --random            test random-based generation\n"
-		" -t, --time              test time-based generation\n"
-		" -n, --uuids <num>       request number of uuids\n"
-		" -P, --no-pid            do not create pid file\n"
-		" -F, --no-fork           do not daemonize using double-fork\n"
-		" -S, --socket-activation do not create listening socket\n"
-		" -d, --debug             run in debugging mode\n"
-		" -q, --quiet             turn on quiet mode\n"
-		" -V, --version           output version information and exit\n"
-		" -h, --help              display this help and exit\n\n"), out);
-
+	fputs(_(" -p, --pid <path>        path to pid file\n"), out);
+	fputs(_(" -s, --socket <path>     path to socket\n"), out);
+	fputs(_(" -T, --timeout <sec>     specify inactivity timeout\n"), out);
+	fputs(_(" -k, --kill              kill running daemon\n"), out);
+	fputs(_(" -r, --random            test random-based generation\n"), out);
+	fputs(_(" -t, --time              test time-based generation\n"), out);
+	fputs(_(" -n, --uuids <num>       request number of uuids\n"), out);
+	fputs(_(" -P, --no-pid            do not create pid file\n"), out);
+	fputs(_(" -F, --no-fork           do not daemonize using double-fork\n"), out);
+	fputs(_(" -S, --socket-activation do not create listening socket\n"), out);
+	fputs(_(" -d, --debug             run in debugging mode\n"), out);
+	fputs(_(" -q, --quiet             turn on quiet mode\n"), out);
+	fputs(USAGE_SEPARATOR, out);
+	fputs(USAGE_HELP, out);
+	fputs(USAGE_VERSION, out);
+	fprintf(out, USAGE_MAN_TAIL("uuidd(8)"));
 	exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
Signature · 1 line
2.6.0
#2 lore raw

PATCH 2/4 blkid, uuidd, uuidgen: assume getopt.h and getopt.h are available

In reply to Sami Kerola

These headers are in use allover this project without issues.

---
 misc-utils/blkid.c   | 6 ------
 misc-utils/uuidd.c   | 8 --------
 misc-utils/uuidgen.c | 8 --------
 3 files changed, 22 deletions(-)
misc-utils/blkid.c +0 -6
index bbe7b62..c0be457 100644
@@ -17,13 +17,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
-#ifdef HAVE_GETOPT_H
 #include <getopt.h>
-#else
-extern int getopt(int argc, char * const argv[], const char *optstring);
-extern char *optarg;
-extern int optind;
-#endif
 
 #define OUTPUT_VALUE_ONLY	(1 << 1)
 #define OUTPUT_DEVICE_ONLY	(1 << 2)
misc-utils/uuidd.c +0 -8
index 76f5e41..e19be52 100644
@@ -9,9 +9,7 @@
  * %End-Header%
  */
 #include <stdio.h>
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
 #include <unistd.h>
 #include <inttypes.h>
 #include <errno.h>
@@ -23,13 +21,7 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <string.h>
-#ifdef HAVE_GETOPT_H
 #include <getopt.h>
-#else
-extern int getopt(int argc, char * const argv[], const char *optstring);
-extern char *optarg;
-extern int optind;
-#endif
 
 #include "uuid.h"
 #include "uuidd.h"
misc-utils/uuidgen.c +0 -8
index 54c5773..40b00ff 100644
@@ -10,16 +10,8 @@
  */
 
 #include <stdio.h>
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
-#ifdef HAVE_GETOPT_H
 #include <getopt.h>
-#else
-extern int getopt(int argc, char * const argv[], const char *optstring);
-extern char *optarg;
-extern int optind;
-#endif
 
 #include "uuid.h"
 #include "nls.h"
Signature · 1 line
2.6.0
#3 lore raw

PATCH 3/4 uuidd: use signalfd() and setup_timer()

In reply to Sami Kerola

Point of this change is to replace use of signal() and alarm() system calls using newer interfaces. Nice side effect is that the point where timer was earlier used cannot be distracted by sending rogue SIGALRM.

---
 misc-utils/Makemodule.am |   4 +-
 misc-utils/uuidd.c       | 135 +++++++++++++++++++++++++++++++++--------------
 2 files changed, 98 insertions(+), 41 deletions(-)
misc-utils/Makemodule.am +2 -2
index e017952..bc1c346 100644
@@ -90,10 +90,10 @@ endif
 if BUILD_UUIDD
 usrsbin_exec_PROGRAMS += uuidd
 dist_man_MANS += misc-utils/uuidd.8
-uuidd_LDADD = $(LDADD) libuuid.la libcommon.la
+uuidd_LDADD = $(LDADD) libuuid.la libcommon.la -lrt
 uuidd_CFLAGS = $(DAEMON_CFLAGS) $(AM_CFLAGS) -I$(ul_libuuid_incdir)
 uuidd_LDFLAGS = $(DAEMON_LDFLAGS) $(AM_LDFLAGS)
-uuidd_SOURCES = misc-utils/uuidd.c
+uuidd_SOURCES = misc-utils/uuidd.c lib/monotonic.c lib/timer.c
 if HAVE_SYSTEMD
 uuidd_LDADD += $(SYSTEMD_LIBS) $(SYSTEMD_DAEMON_LIBS)
 uuidd_CFLAGS += $(SYSTEMD_CFLAGS) $(SYSTEMD_DAEMON_CFLAGS)
misc-utils/uuidd.c +96 -39

236 lines not on this page · raw message

Signature · 1 line
2.6.0
#4 lore raw

PATCH 4/4 uuidd: fix shadow declaration

In reply to Sami Kerola

misc-utils/uuidd.c:384:13: warning: declaration of 'ret' shadows a previous
local [-Wshadow]
misc-utils/uuidd.c:327:6: note: shadowed declaration is here

---
 misc-utils/uuidd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
misc-utils/uuidd.c +5 -5
index c897372..2359f98 100644
@@ -381,15 +381,15 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
 
 #ifdef HAVE_LIBSYSTEMD
 	if (uuidd_cxt->no_sock) {
-		const int ret = sd_listen_fds(0);
+		const int r = sd_listen_fds(0);
 
-		if (ret < 0) {
-			errno = ret * -1;
+		if (r < 0) {
+			errno = r * -1;
 			err(EXIT_FAILURE, _("sd_listen_fds() failed"));
-		} else if (ret == 0)
+		} else if (r == 0)
 			errx(EXIT_FAILURE,
 			     _("no file descriptors received, check systemctl status uuidd.socket"));
-		else if (1 < ret)
+		else if (1 < r)
 			errx(EXIT_FAILURE,
 			     _("too many file descriptors received, check uuidd.socket"));
 		s = SD_LISTEN_FDS_START + 0;
Signature · 1 line
2.6.0
maintainer Applied
#5 lore raw
In reply to Sami Kerola
Quoted 4 lines · Sami Kerola

uuidd: slice up the usage text and normalize its layout blkid, uuidd, uuidgen: assume getopt.h and getopt.h are available
uuidd: use signalfd() and setup_timer()
uuidd: fix shadow declaration

Applied, thanks!

I see we don't have regression tests for uuidd. It would be nice to have something before release ;-)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com