[systemd-commits] 11 commits - man/daemon.xml man/journalctl.xml man/sd_journal_stream_fd.xml man/systemd-udevd.service.xml man/udevadm.xml man/udev.conf.xml NEWS src/core src/kernel-install src/libsystemd-network src/libudev src/shared TODO units/systemd-journal-flush.service.in

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Sat Nov 1 11:44:15 PDT 2014


 NEWS                                      |    9 ++++-
 TODO                                      |    2 -
 man/daemon.xml                            |    6 +--
 man/journalctl.xml                        |    4 +-
 man/sd_journal_stream_fd.xml              |    2 -
 man/systemd-udevd.service.xml             |    4 +-
 man/udev.conf.xml                         |    2 -
 man/udevadm.xml                           |   11 +++++--
 src/core/dbus-unit.c                      |   24 ++++++---------
 src/core/machine-id-setup.c               |   17 +++++++----
 src/kernel-install/90-loaderentry.install |    2 -
 src/libsystemd-network/sd-dhcp6-client.c  |   10 +++---
 src/libudev/libudev-util.c                |   10 ++++--
 src/libudev/libudev.c                     |   46 ++++++++++++++++++------------
 src/shared/calendarspec.c                 |   12 ++++---
 units/systemd-journal-flush.service.in    |    2 -
 16 files changed, 95 insertions(+), 68 deletions(-)

New commits:
commit c008f6ee8df9aa36782378d1a3767543b3635a54
Author: Michael Chapman <mike at very.puzzling.org>
Date:   Wed Oct 29 11:54:07 2014 +1100

    kernel-install/90-loaderentry.install: fix cmdline parsing
    
    A recent commit (2f3a215) changed the parsing of /proc/cmdline to use a
    shell array. Unfortunately, this introduced a bug: "read -ar line"
    populates the shell variable $r, not $line. This breaks installation of
    new loader entries:
    
      # kernel-install add 3.17.1-304.fc21.x86_64 \
          /boot/vmlinuz-3.17.1-304.fc21.x86_64
      Could not determine the kernel command line parameters.
      Please specify the kernel command line in /etc/kernel/cmdline!
    
    This commit alters the read command to correctly populate the $line
    array instead.

diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install
index 6f032b5..d433e00 100644
--- a/src/kernel-install/90-loaderentry.install
+++ b/src/kernel-install/90-loaderentry.install
@@ -47,7 +47,7 @@ if [[ -f /etc/kernel/cmdline ]]; then
 fi
 
 if ! [[ ${BOOT_OPTIONS[*]} ]]; then
-    read -ar line < /proc/cmdline
+    read -a line -r < /proc/cmdline
     for i in "${line[@]}"; do
         [[ "${i#initrd=*}" != "$i" ]] && continue
         BOOT_OPTIONS[${#BOOT_OPTIONS[@]}]="$i"

commit a65b82457735df2ef58736a55846f400124a8dc0
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Nov 1 13:52:14 2014 -0400

    systemd-journal-flush.service: remove "trigger" from description
    
    This service is now synchronous, so "trigger" is misleading.

diff --git a/NEWS b/NEWS
index b8a3776..96f0dd7 100644
--- a/NEWS
+++ b/NEWS
@@ -7,9 +7,10 @@ CHANGES WITH 217:
           show log timestamps in the UTC timezone. journalctl now also
           accepts -n/--lines=all to disable line capping in a pager.
 
-        * journalctl gained a new switch, --flush, that flushes
-          logs from /run/log/journal to /var/log/journal if
-          persistent storage is enabled.
+        * journalctl gained a new switch, --flush, that synchronously
+          flushes logs from /run/log/journal to /var/log/journal if
+          persistent storage is enabled. systemd-journal-flush.service
+          now waits until the operation is complete.
 
         * Services can notify the manager before they start a reload
           (by sending RELOADING=1) or shutdown (by sending
diff --git a/units/systemd-journal-flush.service.in b/units/systemd-journal-flush.service.in
index 2612220..fa29089 100644
--- a/units/systemd-journal-flush.service.in
+++ b/units/systemd-journal-flush.service.in
@@ -6,7 +6,7 @@
 #  (at your option) any later version.
 
 [Unit]
-Description=Trigger Flushing of Journal to Persistent Storage
+Description=Flush Journal to Persistent Storage
 Documentation=man:systemd-journald.service(8) man:journald.conf(5)
 DefaultDependencies=no
 Requires=systemd-journald.service

commit 2a97b03b3b087e724867e7501ae0c1535ee35031
Author: Umut Tezduyar Lindskog <umut.tezduyar at axis.com>
Date:   Wed Oct 29 11:20:02 2014 +0100

    man: explain journalctl --flush correctly

diff --git a/NEWS b/NEWS
index d5d4697..b8a3776 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,10 @@ CHANGES WITH 217:
           show log timestamps in the UTC timezone. journalctl now also
           accepts -n/--lines=all to disable line capping in a pager.
 
+        * journalctl gained a new switch, --flush, that flushes
+          logs from /run/log/journal to /var/log/journal if
+          persistent storage is enabled.
+
         * Services can notify the manager before they start a reload
           (by sending RELOADING=1) or shutdown (by sending
           STOPPING=1). This allows the manager to track and show the
diff --git a/man/journalctl.xml b/man/journalctl.xml
index db2a1e1..0ed3ca3 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -883,9 +883,9 @@
 
                                 <listitem><para>Asks the Journal
                                 daemon to flush any log data stored in
-                                <filename>/run/systemd/log</filename>
+                                <filename>/run/log/journal</filename>
                                 into
-                                <filename>/var/systemd/log</filename>,
+                                <filename>/var/log/journal</filename>,
                                 if persistent storage is enabled. This
                                 call does not return until the
                                 operation is

commit 311f6cf33f6fd50921540875c3e6eb1ffd339124
Author: WaLyong Cho <walyong.cho at samsung.com>
Date:   Thu Oct 30 15:45:15 2014 +0900

    bus: use STR_IN_SET

diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 9b13c6e..2d1862c 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -859,20 +859,16 @@ static int bus_unit_set_transient_property(
                 }
 
                 return 1;
-
-        } else if (streq(name, "Requires") ||
-                   streq(name, "RequiresOverridable") ||
-                   streq(name, "Requisite") ||
-                   streq(name, "RequisiteOverridable") ||
-                   streq(name, "Wants") ||
-                   streq(name, "BindsTo") ||
-                   streq(name, "Conflicts") ||
-                   streq(name, "Before") ||
-                   streq(name, "After") ||
-                   streq(name, "OnFailure") ||
-                   streq(name, "PropagatesReloadTo") ||
-                   streq(name, "ReloadPropagatedFrom") ||
-                   streq(name, "PartOf")) {
+        } else if (STR_IN_SET(name,
+                              "Requires", "RequiresOverridable",
+                              "Requisite", "RequisiteOverridable",
+                              "Wants",
+                              "BindsTo",
+                              "Conflicts",
+                              "Before", "After",
+                              "OnFailure",
+                              "PropagatesReloadTo", "ReloadPropagatedFrom",
+                              "PartOf")) {
 
                 UnitDependency d;
                 const char *other;

commit 86fb9ca7ae49790880d4b3ce523988b01b13d9ae
Author: Jan Synacek <jsynacek at redhat.com>
Date:   Fri Oct 31 10:16:45 2014 +0100

    core: improve error message when machine id is missing

diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index efb074f..ce6d8e0 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -162,7 +162,7 @@ static int generate(char id[34], const char *root) {
 int machine_id_setup(const char *root) {
         const char *etc_machine_id, *run_machine_id;
         _cleanup_close_ int fd = -1;
-        bool writable = false;
+        bool writable = true;
         struct stat st;
         char id[34]; /* 32 + \n + \0 */
         int r;
@@ -186,12 +186,19 @@ int machine_id_setup(const char *root) {
 
                 mkdir_parents(etc_machine_id, 0755);
                 fd = open(etc_machine_id, O_RDWR|O_CREAT|O_CLOEXEC|O_NOCTTY, 0444);
-                if (fd >= 0)
-                        writable = true;
-                else {
+                if (fd < 0) {
+                        int old_errno = errno;
+
                         fd = open(etc_machine_id, O_RDONLY|O_CLOEXEC|O_NOCTTY);
                         if (fd < 0) {
-                                log_error("Cannot open %s: %m", etc_machine_id);
+                                if (old_errno == EROFS && errno == ENOENT)
+                                        log_error("System cannot boot: Missing /etc/machine-id and /etc is mounted read-only.\n"
+                                                  "Booting up is supported only when:\n"
+                                                  "1) /etc/machine-id exists and is populated.\n"
+                                                  "2) /etc/machine-id exists and is empty.\n"
+                                                  "3) /etc/machine-id is missing and /etc is writable.\n");
+                                else
+                                        log_error("Cannot open %s: %m", etc_machine_id);
                                 return -errno;
                         }
 

commit 393b6f28ecec537f05567c4ec8af8c499d0ea226
Author: Dan Williams <dcbw at redhat.com>
Date:   Fri Oct 31 12:20:21 2014 -0500

    sd-dhcp6-client: fix off-by-two error in DUID length
    
    The duid data passed by the caller does not include the DUID type,
    but sd_dhcp6_client_set_duid() was treating it like it did.

diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index fa4f9b5..dbec1a2 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -200,19 +200,19 @@ int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, uint16_t type, uint8_t *du
 
         switch (type) {
         case DHCP6_DUID_LLT:
-                if (duid_len <= sizeof(client->duid.llt))
+                if (duid_len <= sizeof(client->duid.llt) - 2)
                         return -EINVAL;
                 break;
         case DHCP6_DUID_EN:
-                if (duid_len != sizeof(client->duid.en))
+                if (duid_len != sizeof(client->duid.en) - 2)
                         return -EINVAL;
                 break;
         case DHCP6_DUID_LL:
-                if (duid_len <= sizeof(client->duid.ll))
+                if (duid_len <= sizeof(client->duid.ll) - 2)
                         return -EINVAL;
                 break;
         case DHCP6_DUID_UUID:
-                if (duid_len != sizeof(client->duid.uuid))
+                if (duid_len != sizeof(client->duid.uuid) - 2)
                         return -EINVAL;
                 break;
         default:
@@ -222,7 +222,7 @@ int sd_dhcp6_client_set_duid(sd_dhcp6_client *client, uint16_t type, uint8_t *du
 
         client->duid.raw.type = htobe16(type);
         memcpy(&client->duid.raw.data, duid, duid_len);
-        client->duid_len = duid_len;
+        client->duid_len = duid_len + 2;  /* +2 for sizeof(type) */
 
         return 0;
 }

commit 489464d0a2afa82b5db01535be3ea09ab3e71014
Author: Daniele Medri <dmedri at gmail.com>
Date:   Thu Oct 30 12:19:14 2014 +0100

    calendarspec: add constant for weekdays_bits

diff --git a/src/shared/calendarspec.c b/src/shared/calendarspec.c
index 7efcf7b..19ae8a3 100644
--- a/src/shared/calendarspec.c
+++ b/src/shared/calendarspec.c
@@ -24,6 +24,8 @@
 
 #include "calendarspec.h"
 
+#define BITS_WEEKDAYS	127
+
 static void free_chain(CalendarComponent *c) {
         CalendarComponent *n;
 
@@ -120,7 +122,7 @@ static void fix_year(CalendarComponent *c) {
 int calendar_spec_normalize(CalendarSpec *c) {
         assert(c);
 
-        if (c->weekdays_bits <= 0 || c->weekdays_bits >= 127)
+        if (c->weekdays_bits <= 0 || c->weekdays_bits >= BITS_WEEKDAYS)
                 c->weekdays_bits = -1;
 
         fix_year(c->year);
@@ -154,7 +156,7 @@ _pure_ static bool chain_valid(CalendarComponent *c, int from, int to) {
 _pure_ bool calendar_spec_valid(CalendarSpec *c) {
         assert(c);
 
-        if (c->weekdays_bits > 127)
+        if (c->weekdays_bits > BITS_WEEKDAYS)
                 return false;
 
         if (!chain_valid(c->year, 1970, 2199))
@@ -194,7 +196,7 @@ static void format_weekdays(FILE *f, const CalendarSpec *c) {
 
         assert(f);
         assert(c);
-        assert(c->weekdays_bits > 0 && c->weekdays_bits <= 127);
+        assert(c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS);
 
         for (x = 0, l = -1; x < (int) ELEMENTSOF(days); x++) {
 
@@ -259,7 +261,7 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) {
         if (!f)
                 return -ENOMEM;
 
-        if (c->weekdays_bits > 0 && c->weekdays_bits <= 127) {
+        if (c->weekdays_bits > 0 && c->weekdays_bits <= BITS_WEEKDAYS) {
                 format_weekdays(f, c);
                 fputc(' ', f);
         }
@@ -880,7 +882,7 @@ static bool matches_weekday(int weekdays_bits, const struct tm *tm) {
         struct tm t;
         int k;
 
-        if (weekdays_bits < 0 || weekdays_bits >= 127)
+        if (weekdays_bits < 0 || weekdays_bits >= BITS_WEEKDAYS)
                 return true;
 
         t = *tm;

commit e03234a16047dc635d13f7118fc9fcf243744b51
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Nov 1 14:36:29 2014 -0400

    man: describe all log levels in udevadm(8)
    
    https://bugs.freedesktop.org/show_bug.cgi?id=85657

diff --git a/man/udevadm.xml b/man/udevadm.xml
index b85d9a9..fd17f40 100644
--- a/man/udevadm.xml
+++ b/man/udevadm.xml
@@ -368,9 +368,14 @@
           <term><option>-l</option></term>
           <term><option>--log-priority=<replaceable>value</replaceable></option></term>
           <listitem>
-            <para>Set the internal log level of systemd-udevd. Valid values are the numerical
-            syslog priorities or their textual representations: <option>err</option>,
-            <option>info</option> and <option>debug</option>.</para>
+            <para>Set the internal log level of
+            <filename>systemd-udevd</filename>. Valid values are the
+            numerical syslog priorities or their textual
+            representations: <option>emerg</option>,
+            <option>alert</option>, <option>crit</option>,
+            <option>err</option>, <option>warning</option>,
+            <option>notice</option>, <option>info</option>, and
+            <option>debug</option>.</para>
           </listitem>
         </varlistentry>
         <varlistentry>

commit f47ad59316ddbfce0b24edac752222d300ed0da4
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Nov 1 14:33:01 2014 -0400

    Use log "level" instead of "priority"
    
    The term "priority" is misleading because higher levels have lower
    priority. "Level" is clearer and shorter.
    
    This commit touches only the textual descriptions, not function and variable
    names themselves. "Priority" is used in various command-line switches and
    protocol constants, so completly getting rid of "priority" is hard.
    
    I also left "priority" in various places where the clarity suffered
    when it was removed.

diff --git a/NEWS b/NEWS
index 82a1948..d5d4697 100644
--- a/NEWS
+++ b/NEWS
@@ -1971,8 +1971,8 @@ CHANGES WITH 207:
           certain paths from operation.
 
         * journald will now automatically flush all messages to disk
-          as soon as a message of the log priorities CRIT, ALERT or
-          EMERG is received.
+          as soon as a message at the log level CRIT, ALERT or EMERG
+          is received.
 
         Contributions from: Andrew Cook, Brandon Philips, Christian
         Hesse, Christoph Junghans, Colin Walters, Daniel Schaal,
diff --git a/TODO b/TODO
index af26a5c..92d08de 100644
--- a/TODO
+++ b/TODO
@@ -364,8 +364,6 @@ Features:
 
 * think about window-manager-run-as-user-service problem: exit 0 → activate shutdown.target; exit != 0 → restart service
 
-* use "log level" rather than "log priority" everywhere
-
 * merge unit_kill_common() and unit_kill_context()
 
 * introduce ExecCondition= in services
diff --git a/man/daemon.xml b/man/daemon.xml
index 99c75a7..5d3a990 100644
--- a/man/daemon.xml
+++ b/man/daemon.xml
@@ -328,14 +328,14 @@
                                 to simply log to standard error via
                                 <function>fprintf()</function>, which
                                 is then forwarded to syslog by the
-                                init system. If log priorities are
+                                init system. If log levels are
                                 necessary, these can be encoded by
                                 prefixing individual log lines with
                                 strings like <literal><4></literal> (for log
-                                priority 4 "WARNING" in the syslog
+                                level 4 "WARNING" in the syslog
                                 priority scheme), following a similar
                                 style as the Linux kernel's
-                                <function>printk()</function> priority
+                                <function>printk()</function> level
                                 system. For details, see
                                 <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>
                                 and
diff --git a/man/sd_journal_stream_fd.xml b/man/sd_journal_stream_fd.xml
index c9ce7cd..045b3fb 100644
--- a/man/sd_journal_stream_fd.xml
+++ b/man/sd_journal_stream_fd.xml
@@ -90,7 +90,7 @@
                 <filename>syslog.h</filename>, see
                 <citerefentry project='man-pages'><refentrytitle>syslog</refentrytitle><manvolnum>3</manvolnum></citerefentry>
                 for details. The third argument is a boolean: if true
-                kernel-style log priority level prefixes (such as
+                kernel-style log level prefixes (such as
                 <constant>SD_WARNING</constant>) are interpreted, see
                 <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>
                 for more information.</para>
diff --git a/man/systemd-udevd.service.xml b/man/systemd-udevd.service.xml
index ab5c163..05a178c 100644
--- a/man/systemd-udevd.service.xml
+++ b/man/systemd-udevd.service.xml
@@ -134,7 +134,7 @@
       <varlistentry>
         <term><varname>$UDEV_LOG=</varname></term>
         <listitem>
-          <para>Set the logging priority.</para>
+          <para>Set the log level.</para>
         </listitem>
       </varlistentry>
     </variablelist>
@@ -148,7 +148,7 @@
         <term><varname>udev.log-priority=</varname></term>
         <term><varname>rd.udev.log-priority=</varname></term>
         <listitem>
-          <para>Set the logging priority.</para>
+          <para>Set the log level.</para>
         </listitem>
       </varlistentry>
       <varlistentry>
diff --git a/man/udev.conf.xml b/man/udev.conf.xml
index 16ad41e..988129f 100644
--- a/man/udev.conf.xml
+++ b/man/udev.conf.xml
@@ -69,7 +69,7 @@
         <term><varname>udev_log</varname></term>
 
         <listitem>
-          <para>The logging priority. Valid values are the numerical
+          <para>The log level. Valid values are the numerical
           syslog priorities or their textual representations:
           <option>err</option>, <option>info</option> and
           <option>debug</option>.</para>
diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c
index 8464427..f4f285c 100644
--- a/src/libudev/libudev.c
+++ b/src/libudev/libudev.c
@@ -79,7 +79,7 @@ static void log_stderr(struct udev *udev,
  * @udev: udev library context
  *
  * Retrieve stored data pointer from library context. This might be useful
- * to access from callbacks like a custom logging function.
+ * to access from callbacks like a custom log function.
  *
  * Returns: stored userdata
  **/
@@ -197,7 +197,7 @@ _public_ struct udev *udev_new(void)
 
                                 prio = util_log_priority(val);
                                 if (prio < 0)
-                                        udev_err(udev, "/etc/udev/udev.conf:%u: invalid logging level '%s', ignoring.\n", line_nr, val);
+                                        udev_err(udev, "/etc/udev/udev.conf:%u: invalid log level '%s', ignoring.\n", line_nr, val);
                                 else
                                         udev_set_log_priority(udev, prio);
                                 continue;
@@ -212,7 +212,7 @@ _public_ struct udev *udev_new(void)
 
                 prio = util_log_priority(env);
                 if (prio < 0)
-                        udev_err(udev, "$UDEV_LOG specifies invalid logging level '%s', ignoring.\n", env);
+                        udev_err(udev, "$UDEV_LOG specifies invalid log level '%s', ignoring.\n", env);
                 else
                         udev_set_log_priority(udev, prio);
         }
@@ -260,11 +260,11 @@ _public_ struct udev *udev_unref(struct udev *udev)
 /**
  * udev_set_log_fn:
  * @udev: udev library context
- * @log_fn: function to be called for logging messages
+ * @log_fn: function to be called for log messages
  *
  * The built-in logging writes to stderr. It can be
  * overridden by a custom function, to plug log messages
- * into the users' logging functionality.
+ * into the users' log functionality.
  *
  **/
 _public_ void udev_set_log_fn(struct udev *udev,
@@ -273,17 +273,16 @@ _public_ void udev_set_log_fn(struct udev *udev,
                                     const char *format, va_list args))
 {
         udev->log_fn = log_fn;
-        udev_dbg(udev, "custom logging function %p registered\n", log_fn);
+        udev_dbg(udev, "custom log function %p registered\n", log_fn);
 }
 
 /**
  * udev_get_log_priority:
  * @udev: udev library context
  *
- * The initial logging priority is read from the udev config file
- * at startup.
+ * The initial log level is read from the udev config file at startup.
  *
- * Returns: the current logging priority
+ * Returns: the current log level
  **/
 _public_ int udev_get_log_priority(struct udev *udev)
 {
@@ -293,10 +292,9 @@ _public_ int udev_get_log_priority(struct udev *udev)
 /**
  * udev_set_log_priority:
  * @udev: udev library context
- * @priority: the new logging priority
+ * @priority: the new log priority
  *
- * Set the current logging priority. The value controls which messages
- * are logged.
+ * Set the log level. This value controls which messages are logged.
  **/
 _public_ void udev_set_log_priority(struct udev *udev, int priority)
 {

commit ee7122c0ec6aa11f02e9e8d94254b353f12d2c14
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Nov 1 12:06:41 2014 -0400

    libudev: do not accept invalid log levels
    
    Invalid log levels lead to a assert failure later on.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=85657

diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c
index f3fdf3b..0bc10f3 100644
--- a/src/libudev/libudev-util.c
+++ b/src/libudev/libudev-util.c
@@ -159,9 +159,13 @@ int util_log_priority(const char *priority)
         char *endptr;
         int prio;
 
-        prio = strtol(priority, &endptr, 10);
-        if (endptr[0] == '\0' || isspace(endptr[0]))
-                return prio;
+        prio = strtoul(priority, &endptr, 10);
+        if (endptr[0] == '\0' || isspace(endptr[0])) {
+                if (prio >= 0 && prio <= 7)
+                        return prio;
+                else
+                        return -ERANGE;
+        }
 
         return log_level_from_string(priority);
 }
diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c
index 7803863..8464427 100644
--- a/src/libudev/libudev.c
+++ b/src/libudev/libudev.c
@@ -193,7 +193,13 @@ _public_ struct udev *udev_new(void)
                         }
 
                         if (streq(key, "udev_log")) {
-                                udev_set_log_priority(udev, util_log_priority(val));
+                                int prio;
+
+                                prio = util_log_priority(val);
+                                if (prio < 0)
+                                        udev_err(udev, "/etc/udev/udev.conf:%u: invalid logging level '%s', ignoring.\n", line_nr, val);
+                                else
+                                        udev_set_log_priority(udev, prio);
                                 continue;
                         }
                 }
@@ -201,8 +207,15 @@ _public_ struct udev *udev_new(void)
 
         /* environment overrides config */
         env = secure_getenv("UDEV_LOG");
-        if (env != NULL)
-                udev_set_log_priority(udev, util_log_priority(env));
+        if (env != NULL) {
+                int prio;
+
+                prio = util_log_priority(env);
+                if (prio < 0)
+                        udev_err(udev, "$UDEV_LOG specifies invalid logging level '%s', ignoring.\n", env);
+                else
+                        udev_set_log_priority(udev, prio);
+        }
 
         return udev;
 }

commit fe756ed9ec2c0fa33c30b1d9a33d745dc1593aed
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Nov 1 11:32:44 2014 -0400

    libudev: modernization
    
    This brings udev logging style a bit closer to normal systemd convention.

diff --git a/src/libudev/libudev.c b/src/libudev/libudev.c
index e2ab960..7803863 100644
--- a/src/libudev/libudev.c
+++ b/src/libudev/libudev.c
@@ -119,7 +119,7 @@ _public_ struct udev *udev_new(void)
 {
         struct udev *udev;
         const char *env;
-        FILE *f;
+        _cleanup_free_ FILE *f = NULL;
 
         udev = new0(struct udev, 1);
         if (udev == NULL)
@@ -132,7 +132,7 @@ _public_ struct udev *udev_new(void)
         f = fopen("/etc/udev/udev.conf", "re");
         if (f != NULL) {
                 char line[UTIL_LINE_SIZE];
-                int line_nr = 0;
+                unsigned line_nr = 0;
 
                 while (fgets(line, sizeof(line), f)) {
                         size_t len;
@@ -153,7 +153,7 @@ _public_ struct udev *udev_new(void)
                         /* split key/value */
                         val = strchr(key, '=');
                         if (val == NULL) {
-                                udev_err(udev, "missing <key>=<value> in /etc/udev/udev.conf[%i]; skip line\n", line_nr);
+                                udev_err(udev, "/etc/udev/udev.conf:%u: missing assignment,  skipping line.\n", line_nr);
                                 continue;
                         }
                         val[0] = '\0';
@@ -185,7 +185,7 @@ _public_ struct udev *udev_new(void)
                         /* unquote */
                         if (val[0] == '"' || val[0] == '\'') {
                                 if (val[len-1] != val[0]) {
-                                        udev_err(udev, "inconsistent quoting in /etc/udev/udev.conf[%i]; skip line\n", line_nr);
+                                        udev_err(udev, "/etc/udev/udev.conf:%u: inconsistent quoting, skipping line.\n", line_nr);
                                         continue;
                                 }
                                 val[len-1] = '\0';
@@ -197,7 +197,6 @@ _public_ struct udev *udev_new(void)
                                 continue;
                         }
                 }
-                fclose(f);
         }
 
         /* environment overrides config */



More information about the systemd-commits mailing list