From c22569eeeafa94cf510267071f5b75c4ab714e09 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Wed, 22 Feb 2017 04:46:13 +0530 Subject: [PATCH] udev: Introduce UDEV_PROPAGATE_LOG macro (#5302) As per commit 25e773e "udev: switch to systemd logging functions" Now log_set_max_level() in udev_new() overwites system wide log level. Propagate the udev.conf setting to log_set_max_level() only if udev_new() is called from within udevd or one of its helpers. Introduce a UDEV_PROPAGATE_LOG macro that we set with -D on the gcc command line for all udev binaries we build, but not for any others. The log_set_max_level() call is guarded by an ifdef check for that macro, so that it only effects the various udev binaries. closes: #4525 --- Makefile.am | 23 ++++++++++++++++++++++- src/libudev/libudev.c | 3 +++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 292f63c..c536df7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3914,7 +3914,8 @@ gperf_gperf_sources += \ libudev_core_la_CFLAGS = \ $(AM_CFLAGS) \ $(BLKID_CFLAGS) \ - $(KMOD_CFLAGS) + $(KMOD_CFLAGS) \ + -D UDEV_PROPAGATE_LOG libudev_core_la_LIBADD = \ libsystemd-network.la \ @@ -4089,6 +4090,10 @@ EXTRA_DIST += \ ata_id_SOURCES = \ src/udev/ata_id/ata_id.c +ata_id_CFLAGS = \ + $(AM_CFLAGS) + -D UDEV_PROPAGATE_LOG + ata_id_LDADD = \ libshared.la @@ -4099,6 +4104,10 @@ udevlibexec_PROGRAMS += \ cdrom_id_SOURCES = \ src/udev/cdrom_id/cdrom_id.c +cdrom_id_CFLAGS = \ + $(AM_CFLAGS) + -D UDEV_PROPAGATE_LOG + cdrom_id_LDADD = \ libshared.la @@ -4112,6 +4121,10 @@ dist_udevrules_DATA += \ collect_SOURCES = \ src/udev/collect/collect.c +collect_CFLAGS = \ + $(AM_CFLAGS) + -D UDEV_PROPAGATE_LOG + collect_LDADD = \ libshared.la @@ -4125,6 +4138,10 @@ scsi_id_SOURCES =\ src/udev/scsi_id/scsi.h \ src/udev/scsi_id/scsi_id.h +scsi_id_CFLAGS = \ + $(AM_CFLAGS) + -D UDEV_PROPAGATE_LOG + scsi_id_LDADD = \ libshared.la @@ -4153,6 +4170,10 @@ mtd_probe_SOURCES = \ src/udev/mtd_probe/mtd_probe.h \ src/udev/mtd_probe/probe_smartmedia.c +mtd_probe_CFLAGS = \ + $(AM_CFLAGS) + -D UDEV_PROPAGATE_LOG + dist_udevrules_DATA += \ rules/75-probe_mtd.rules diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c index d8e1328..7c6aeef 100644 --- a/src/libudev/libudev.c +++ b/src/libudev/libudev.c @@ -103,6 +103,8 @@ _public_ struct udev *udev_new(void) { } udev->refcount = 1; +#ifdef UDEV_PROPAGATE_LOG + f = fopen("/etc/udev/udev.conf", "re"); if (f != NULL) { char line[UTIL_LINE_SIZE]; @@ -178,6 +180,7 @@ _public_ struct udev *udev_new(void) { } } } +#endif return udev; } -- 2.7.4