]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #11355 from yuwata/rfe-11343
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jan 2019 14:07:33 +0000 (15:07 +0100)
committerGitHub <noreply@github.com>
Tue, 8 Jan 2019 14:07:33 +0000 (15:07 +0100)
conf-parse: accept whitespaces before comments

23 files changed:
NEWS
hwdb/70-mouse.hwdb
man/systemd-cat.xml
src/basic/btrfs-util.h
src/basic/cgroup-util.h
src/basic/env-util.h
src/basic/extract-word.h
src/basic/stat-util.c
src/basic/unit-name.h
src/core/socket.c
src/fsck/fsck.c
src/journal/cat.c
src/libsystemd/sd-bus/bus-dump.h
src/libsystemd/sd-bus/bus-protocol.h
src/login/logind-inhibit.h
src/resolve/resolved-dns-answer.h
src/shared/json.c
src/shared/json.h
src/shared/loop-util.c
src/udev/udevadm-control.c
src/udev/udevadm-monitor.c
src/udev/udevadm-settle.c
src/udev/udevadm-trigger.c

diff --git a/NEWS b/NEWS
index e04a797c285f7d767b696566e6330b6b69db96eb..9b43907fcba9cad43f53e92ba9b34e6a0a19d5be 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,8 @@ CHANGES WITH 240:
           by systemd-sysusers again. Distributors or system administrators
           may need to create these users and groups if they not exist (or need
           to re-enable DynamicUser= for those units) while upgrading systemd.
+          Also, the clock file for systemd-timesyncd may need to move from
+          /var/lib/private/systemd/timesync/clock to /var/lib/systemd/timesync/clock.
 
         * When unit files are loaded from disk, previously systemd would
           sometimes (depending on the unit loading order) load units from the
index 07364c2c64daa739fcf926002b8076d26f946f9c..3a15ff57ca8258c004d47bd77414d3883f4a89a4 100644 (file)
@@ -310,6 +310,8 @@ mouse:usb:v17efp6050:name:Lenovo Precision USB Mouse:
 
 # Lenovo MOBGUL
 mouse:usb:v17efp601d:name:Primax Lenovo Laser Mouse:
+ MOUSE_DPI=1600@125
+
 # Lenovo MOBGULA
 mouse:usb:v17efp6045:name:Lenovo USB Laser Mouse:
  MOUSE_DPI=1600@125
@@ -331,6 +333,8 @@ mouse:usb:v17efp6044:name:ThinkPad USB Laser Mouse:
 
 # Logitech G5 Laser Mouse
 mouse:usb:v046dpc049:name:Logitech USB Gaming Mouse:
+ MOUSE_DPI=400@500 *800@500 2000@500
+
 # Logitech G500s Laser Gaming Mouse
 mouse:usb:v046dpc24e:name:Logitech G500s Laser Gaming Mouse:
  MOUSE_DPI=400@500 *800@500 2000@500
@@ -384,8 +388,12 @@ mouse:usb:v046dpc539:name:Logitech USB Receiver Mouse:
 # Logitech Wireless Mouse M185
 mouse:usb:v046dp4008:name:Logitech M185:
 mouse:usb:v046dpc52b:name:Logitech Unifying Device. Wireless PID:4008:
+ MOUSE_DPI=1000@125
+
 # Logitech Wireless Mouse M510
 mouse:usb:v046dp1025:name:Logitech M510:
+ MOUSE_DPI=1000@125
+
 # Logitech M705 (marathon mouse)
 mouse:usb:v046dp101b:name:Logitech M705:
 mouse:usb:v046dpc52b:name:Logitech Unifying Device. Wireless PID:101b:
@@ -431,6 +439,8 @@ mouse:bluetooth:v046dpb003:name:Logitech MX1000 mouse:
 # Logitech Anywhere MX
 mouse:usb:v046dpc52b:name:Logitech Unifying Device. Wireless PID:1017:
 mouse:usb:v046dp1017:name:Logitech Anywhere MX:
+ MOUSE_WHEEL_CLICK_ANGLE=20
+
 # Logitech Anywhere MX 2S
 mouse:usb:v046dp406a:name:Logitech MX Anywhere 2S:
  MOUSE_WHEEL_CLICK_ANGLE=20
@@ -466,12 +476,20 @@ mouse:bluetooth:v046dpb019:name:MX Master 2S Mouse:
 
 # Logitech M-BJ58 Optical Mouse
 mouse:usb:v046dpc00e:name:Logitech USB-PS/2 Optical Mouse:
+ MOUSE_DPI=400@125
+
 # Logitech Mini Optical Mouse
 mouse:usb:v046dpc016:name:Logitech Optical USB Mouse:
+ MOUSE_DPI=400@125
+
 # Logitech MX310 Optical Mouse
 mouse:usb:v046dpc01b:name:Logitech USB-PS/2 Optical Mouse:
+ MOUSE_DPI=400@125
+
 # Logitech USB-PS/2 M-BT58
 mouse:usb:v046dpc03e:name:Logitech USB-PS/2 Optical Mouse:
+ MOUSE_DPI=400@125
+
 # Logitech TrackMan Marble Wheel USB
 mouse:usb:v046dpc401:name:Logitech USB-PS/2 Trackball:
  MOUSE_DPI=400@125
@@ -486,10 +504,16 @@ mouse:usb:v046dpc045:name:Logitech USB-PS/2 Optical Mouse:
 
 # Logitech MX400 Performance Laser Mouse
 mouse:usb:v046dpc043:name:Logitech USB-PS/2 Optical Mouse:
+ MOUSE_DPI=800@125
+
 # Logitech MX1000 Laser Cordless Mouse
 mouse:usb:v046dpc50e:name:Logitech USB RECEIVER:
+ MOUSE_DPI=800@125
+
 # Logitech Cordless Click! Plus
 mouse:usb:v046dpc50e:name:Logitech USB Receiver:
+ MOUSE_DPI=800@125
+
 # Logitech, Inc. RX 300 Optical Mouse
 mouse:usb:v046dpc040:name:Logitech USB-PS/2 Optical Mouse:
  MOUSE_DPI=800@125
@@ -510,14 +534,24 @@ mouse:usb:v046dpc517:name:Logitech USB Receiver:
 
 # Logitech RX1000 Laser Mouse
 mouse:usb:v046dpc046:name:Logitech USB Optical Mouse:
+ MOUSE_DPI=1000@125
+
 # Logitech M100 Optical Mouse
 mouse:usb:v046dpc05a:name:Logitech USB Optical Mouse:
+ MOUSE_DPI=1000@125
+
 # Logitech USB Laser Mouse M-U0011-O rebranded as "terra Laser"
 mouse:usb:v046dpc065:name:Logitech USB Laser Mouse:
+ MOUSE_DPI=1000@125
+
 # Logitech USB Laser Mouse M-U0007 [M500]
 mouse:usb:v046dpc069:name:Logitech USB Laser Mouse:
+ MOUSE_DPI=1000@125
+
 # Logitech V500 Cordless Notebook Mouse
 mouse:usb:v046dpc510:name:Logitech USB Receiver:
+ MOUSE_DPI=1000@125
+
 # Logitech M560 Wireless Mouse
 mouse:usb:v046dp402d:name:Logitech M560:
 mouse:usb:v046dpc52b:name:Logitech Unifying Device. Wireless PID:402d:
@@ -577,6 +611,8 @@ mouse:usb:v045ep076c:name:Microsoft Microsoft® Comfort Mouse 4500:
 
 # Microsoft Wireless Mobile Mouse 4000
 mouse:usb:v045ep0745:name:Microsoft Microsoft® Nano Transceiver v2.0:
+ MOUSE_DPI=1000@142
+
 # Microsoft Sculpt Ergonomic Mouse
 mouse:usb:v045ep07a5:name:Microsoft Microsoft® 2.4GHz Transceiver v9.0:
  MOUSE_DPI=1000@142
index 72cd196c4e5c5f49086e6bf158f141a7e3038ef1..446fa4ba31bf0692d83fd8ae7d66ad9f7baa332b 100644 (file)
         see <option>--level-prefix=</option> below.</para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--stderr-priority=</option></term>
+
+        <listitem><para>Specifies the default priority level for
+        messages from the process's standard error output (stderr).
+        Usage of this option is the same as the
+        <option>--priority=</option> option, above, and both can be
+        used at once. When both are used, <option>--priority=</option>
+        will specify the default priority for standard output (stdout).
+        </para>
+
+        <para>If <option>--stderr-priority=</option> is not specified,
+        messages from stderr will still be logged, with the same
+        default priority level as stdout.</para>
+
+        <para>Also, note that when stdout and stderr use the same
+        default priority, the messages will be strictly ordered,
+        because one channel is used for both. When the default priority
+        differs, two channels are used, and so stdout messages will not
+        be strictly ordered with respect to stderr messages - though
+        they will tend to be approximately ordered.</para></listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>--level-prefix=</option></term>
 
index 085aca4dbcb271353d65023ec1cb838b2c571fec..7d848a75d36169caa152aa0cfdb6d2aa8767008c 100644 (file)
@@ -28,17 +28,17 @@ typedef struct BtrfsQuotaInfo {
 } BtrfsQuotaInfo;
 
 typedef enum BtrfsSnapshotFlags {
-        BTRFS_SNAPSHOT_FALLBACK_COPY = 1,        /* If the source isn't a subvolume, reflink everything */
-        BTRFS_SNAPSHOT_READ_ONLY = 2,
-        BTRFS_SNAPSHOT_RECURSIVE = 4,
-        BTRFS_SNAPSHOT_QUOTA = 8,
-        BTRFS_SNAPSHOT_FALLBACK_DIRECTORY = 16,  /* If the destination doesn't support subvolumes, reflink/copy instead */
-        BTRFS_SNAPSHOT_FALLBACK_IMMUTABLE = 32,  /* When we can't create a subvolume, use the FS_IMMUTABLE attribute for indicating read-only */
+        BTRFS_SNAPSHOT_FALLBACK_COPY      = 1 << 0, /* If the source isn't a subvolume, reflink everything */
+        BTRFS_SNAPSHOT_READ_ONLY          = 1 << 1,
+        BTRFS_SNAPSHOT_RECURSIVE          = 1 << 2,
+        BTRFS_SNAPSHOT_QUOTA              = 1 << 3,
+        BTRFS_SNAPSHOT_FALLBACK_DIRECTORY = 1 << 4, /* If the destination doesn't support subvolumes, reflink/copy instead */
+        BTRFS_SNAPSHOT_FALLBACK_IMMUTABLE = 1 << 5, /* When we can't create a subvolume, use the FS_IMMUTABLE attribute for indicating read-only */
 } BtrfsSnapshotFlags;
 
 typedef enum BtrfsRemoveFlags {
-        BTRFS_REMOVE_RECURSIVE = 1,
-        BTRFS_REMOVE_QUOTA = 2,
+        BTRFS_REMOVE_RECURSIVE = 1 << 0,
+        BTRFS_REMOVE_QUOTA     = 1 << 1,
 } BtrfsRemoveFlags;
 
 int btrfs_is_filesystem(int fd);
index 220c8d381fe77adef67df24b3d9c414c3000f461..119b493dc633fa2202cbd86e95b1f9ef8a3b220f 100644 (file)
@@ -162,9 +162,9 @@ int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d);
 int cg_read_subgroup(DIR *d, char **fn);
 
 typedef enum CGroupFlags {
-        CGROUP_SIGCONT     = 1,
-        CGROUP_IGNORE_SELF = 2,
-        CGROUP_REMOVE      = 4,
+        CGROUP_SIGCONT     = 1 << 0,
+        CGROUP_IGNORE_SELF = 1 << 1,
+        CGROUP_REMOVE      = 1 << 2,
 } CGroupFlags;
 
 typedef void (*cg_kill_log_func_t)(pid_t pid, int sig, void *userdata);
index 4d21ea6bef5febe9bdbbb9daacd7a0b95980495e..d54f99658bddaebdcaa54437629ba6126e483c13 100644 (file)
@@ -13,9 +13,9 @@ bool env_value_is_valid(const char *e);
 bool env_assignment_is_valid(const char *e);
 
 enum {
-        REPLACE_ENV_USE_ENVIRONMENT = 1u,
-        REPLACE_ENV_ALLOW_BRACELESS = 2u,
-        REPLACE_ENV_ALLOW_EXTENDED  = 4u,
+        REPLACE_ENV_USE_ENVIRONMENT = 1 << 0,
+        REPLACE_ENV_ALLOW_BRACELESS = 1 << 1,
+        REPLACE_ENV_ALLOW_EXTENDED  = 1 << 2,
 };
 
 char *replace_env_n(const char *format, size_t n, char **env, unsigned flags);
index 8c63b7c306b690be57b6d19545881675ba54c4e2..705ebbe95bbf38bb41567a2a077b73e39094dd6f 100644 (file)
@@ -4,12 +4,12 @@
 #include "macro.h"
 
 typedef enum ExtractFlags {
-        EXTRACT_RELAX                    = 1,
-        EXTRACT_CUNESCAPE                = 2,
-        EXTRACT_CUNESCAPE_RELAX          = 4,
-        EXTRACT_QUOTES                   = 8,
-        EXTRACT_DONT_COALESCE_SEPARATORS = 16,
-        EXTRACT_RETAIN_ESCAPE            = 32,
+        EXTRACT_RELAX                    = 1 << 0,
+        EXTRACT_CUNESCAPE                = 1 << 1,
+        EXTRACT_CUNESCAPE_RELAX          = 1 << 2,
+        EXTRACT_QUOTES                   = 1 << 3,
+        EXTRACT_DONT_COALESCE_SEPARATORS = 1 << 4,
+        EXTRACT_RETAIN_ESCAPE            = 1 << 5,
 } ExtractFlags;
 
 int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags);
index 57700e2388a1b8e0d671c2ba8ed093f88181b30c..0af869cf652e2720241ee9d6f526c0c8e0cba9e5 100644 (file)
@@ -338,7 +338,6 @@ int device_path_make_major_minor(mode_t mode, dev_t devno, char **ret) {
                 return -ENOMEM;
 
         return 0;
-
 }
 
 int device_path_make_canonical(mode_t mode, dev_t devno, char **ret) {
index d373f03aca59ee6ac8cb23803ff12b6588f0b2c9..0629db3f67c3e8cc1d2422f2359aa831a81720e8 100644 (file)
@@ -9,9 +9,9 @@
 #define UNIT_NAME_MAX 256
 
 typedef enum UnitNameFlags {
-        UNIT_NAME_PLAIN = 1,      /* Allow foo.service */
-        UNIT_NAME_INSTANCE = 2,   /* Allow foo@bar.service */
-        UNIT_NAME_TEMPLATE = 4,   /* Allow foo@.service */
+        UNIT_NAME_PLAIN    = 1 << 0, /* Allow foo.service */
+        UNIT_NAME_INSTANCE = 1 << 1, /* Allow foo@bar.service */
+        UNIT_NAME_TEMPLATE = 1 << 2, /* Allow foo@.service */
         UNIT_NAME_ANY = UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE,
 } UnitNameFlags;
 
@@ -50,8 +50,8 @@ int unit_name_from_path_instance(const char *prefix, const char *path, const cha
 int unit_name_to_path(const char *name, char **ret);
 
 typedef enum UnitNameMangle {
-        UNIT_NAME_MANGLE_GLOB = 1,
-        UNIT_NAME_MANGLE_WARN = 2,
+        UNIT_NAME_MANGLE_GLOB = 1 << 0,
+        UNIT_NAME_MANGLE_WARN = 1 << 1,
 } UnitNameMangle;
 
 int unit_name_mangle_with_suffix(const char *name, UnitNameMangle flags, const char *suffix, char **ret);
index dd126a7f21b7d06fe27f2ea3c9fde6452c63ef17..dd7e5d91fae86e45a3a16582f851610f050c872b 100644 (file)
@@ -561,7 +561,7 @@ int socket_acquire_peer(Socket *s, int fd, SocketPeer **p) {
 
         r = getpeername(fd, &sa.peer.sa, &salen);
         if (r < 0)
-                return log_error_errno(errno, "getpeername failed: %m");
+                return log_unit_error_errno(UNIT(s), errno, "getpeername failed: %m");
 
         if (!IN_SET(sa.peer.sa.sa_family, AF_INET, AF_INET6, AF_VSOCK)) {
                 *p = NULL;
@@ -1465,6 +1465,17 @@ static int socket_address_listen_do(
                         label);
 }
 
+static int log_address_error_errno(Unit *u, const SocketAddress *address, int error, const char *fmt) {
+        _cleanup_free_ char *t = NULL;
+
+        (void) socket_address_print(address, &t);
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+        return log_unit_error_errno(u, error, fmt, strna(t));
+#pragma GCC diagnostic pop
+}
+
 static int socket_address_listen_in_cgroup(
                 Socket *s,
                 const SocketAddress *address,
@@ -1503,13 +1514,13 @@ static int socket_address_listen_in_cgroup(
 
                 fd = socket_address_listen_do(s, address, label);
                 if (fd < 0) {
-                        log_unit_error_errno(UNIT(s), fd, "Failed to create listening socket: %m");
+                        log_address_error_errno(UNIT(s), address, fd, "Failed to create listening socket (%s): %m");
                         _exit(EXIT_FAILURE);
                 }
 
                 r = send_one_fd(pair[1], fd, 0);
                 if (r < 0) {
-                        log_unit_error_errno(UNIT(s), r, "Failed to send listening socket to parent: %m");
+                        log_address_error_errno(UNIT(s), address, r, "Failed to send listening socket (%s) to parent: %m");
                         _exit(EXIT_FAILURE);
                 }
 
@@ -1527,19 +1538,22 @@ static int socket_address_listen_in_cgroup(
         }
 
         if (fd < 0)
-                return log_unit_error_errno(UNIT(s), fd, "Failed to receive listening socket: %m");
+                return log_address_error_errno(UNIT(s), address, fd, "Failed to receive listening socket (%s): %m");
 
         return fd;
 
 shortcut:
         fd = socket_address_listen_do(s, address, label);
         if (fd < 0)
-                return log_error_errno(fd, "Failed to create listening socket: %m");
+                return log_address_error_errno(UNIT(s), address, fd, "Failed to create listening socket (%s): %m");
 
         return fd;
 }
 
-static int socket_open_fds(Socket *s) {
+DEFINE_TRIVIAL_CLEANUP_FUNC(Socket *, socket_close_fds);
+
+static int socket_open_fds(Socket *_s) {
+        _cleanup_(socket_close_fdsp) Socket *s = _s;
         _cleanup_(mac_selinux_freep) char *label = NULL;
         bool know_label = false;
         SocketPort *p;
@@ -1562,7 +1576,7 @@ static int socket_open_fds(Socket *s) {
 
                                 r = socket_determine_selinux_label(s, &label);
                                 if (r < 0)
-                                        goto rollback;
+                                        return log_unit_error_errno(UNIT(s), r, "Failed to determine SELinux label: %m");
 
                                 know_label = true;
                         }
@@ -1584,7 +1598,7 @@ static int socket_open_fds(Socket *s) {
 
                         r = socket_address_listen_in_cgroup(s, &p->address, label);
                         if (r < 0)
-                                goto rollback;
+                                return r;
 
                         p->fd = r;
                         socket_apply_socket_options(s, p->fd);
@@ -1593,39 +1607,38 @@ static int socket_open_fds(Socket *s) {
 
                 case SOCKET_SPECIAL:
 
-                        p->fd = special_address_create(p->path, s->writable);
-                        if (p->fd < 0) {
-                                r = p->fd;
-                                goto rollback;
-                        }
+                        r = special_address_create(p->path, s->writable);
+                        if (r < 0)
+                                return log_unit_error_errno(UNIT(s), r, "Failed to open special file %s: %m", p->path);
+
+                        p->fd = r;
                         break;
 
                 case SOCKET_FIFO:
 
-                        p->fd = fifo_address_create(
+                        r = fifo_address_create(
                                         p->path,
                                         s->directory_mode,
                                         s->socket_mode);
-                        if (p->fd < 0) {
-                                r = p->fd;
-                                goto rollback;
-                        }
+                        if (r < 0)
+                                return log_unit_error_errno(UNIT(s), r, "Failed to open FIFO %s: %m", p->path);
 
+                        p->fd = r;
                         socket_apply_fifo_options(s, p->fd);
                         socket_symlink(s);
                         break;
 
                 case SOCKET_MQUEUE:
 
-                        p->fd = mq_address_create(
+                        r = mq_address_create(
                                         p->path,
                                         s->socket_mode,
                                         s->mq_maxmsg,
                                         s->mq_msgsize);
-                        if (p->fd < 0) {
-                                r = p->fd;
-                                goto rollback;
-                        }
+                        if (r < 0)
+                                return log_unit_error_errno(UNIT(s), r, "Failed to open message queue %s: %m", p->path);
+
+                        p->fd = r;
                         break;
 
                 case SOCKET_USB_FUNCTION: {
@@ -1633,19 +1646,19 @@ static int socket_open_fds(Socket *s) {
 
                         ep = path_make_absolute("ep0", p->path);
 
-                        p->fd = usbffs_address_create(ep);
-                        if (p->fd < 0) {
-                                r = p->fd;
-                                goto rollback;
-                        }
+                        r = usbffs_address_create(ep);
+                        if (r < 0)
+                                return r;
+
+                        p->fd = r;
 
                         r = usbffs_write_descs(p->fd, SERVICE(UNIT_DEREF(s->service)));
                         if (r < 0)
-                                goto rollback;
+                                return r;
 
                         r = usbffs_dispatch_eps(p);
                         if (r < 0)
-                                goto rollback;
+                                return r;
 
                         break;
                 }
@@ -1654,11 +1667,8 @@ static int socket_open_fds(Socket *s) {
                 }
         }
 
+        s = NULL;
         return 0;
-
-rollback:
-        socket_close_fds(s);
-        return r;
 }
 
 static void socket_unwatch_fds(Socket *s) {
@@ -2521,14 +2531,14 @@ static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
 
                 copy = fdset_put_dup(fds, p->fd);
                 if (copy < 0)
-                        return log_warning_errno(copy, "Failed to serialize socket fd: %m");
+                        return log_unit_warning_errno(u, copy, "Failed to serialize socket fd: %m");
 
                 if (p->type == SOCKET_SOCKET) {
                         _cleanup_free_ char *t = NULL;
 
                         r = socket_address_print(&p->address, &t);
                         if (r < 0)
-                                return log_error_errno(r, "Failed to format socket address: %m");
+                                return log_unit_error_errno(u, r, "Failed to format socket address: %m");
 
                         if (socket_address_family(&p->address) == AF_NETLINK)
                                 (void) serialize_item_format(f, "netlink", "%i %s", copy, t);
index ba39f596fc75b4a320a5ec3d127fc927cd3d14b0..524327c4da04c87e6d38561e5731baef57756c37 100644 (file)
@@ -414,7 +414,7 @@ static int run(int argc, char *argv[]) {
         exit_status = wait_for_terminate_and_check("fsck", pid, WAIT_LOG_ABNORMAL);
         if (exit_status < 0)
                 return exit_status;
-        if (exit_status & ~1) {
+        if ((exit_status & ~FSCK_ERROR_CORRECTED) != FSCK_SUCCESS) {
                 log_error("fsck failed with exit status %i.", exit_status);
 
                 if ((exit_status & FSCK_SYSTEM_SHOULD_REBOOT) && root_directory) {
index a84350fbc9284e9d4f145b092ddcd7fad3e2836a..9900bd2e863fa73ad607e52abbaa974b0cc7e1be 100644 (file)
@@ -20,6 +20,7 @@
 
 static const char *arg_identifier = NULL;
 static int arg_priority = LOG_INFO;
+static int arg_stderr_priority = -1;
 static bool arg_level_prefix = true;
 
 static int help(void) {
@@ -32,11 +33,12 @@ static int help(void) {
 
         printf("%s [OPTIONS...] {COMMAND} ...\n\n"
                "Execute process with stdout/stderr connected to the journal.\n\n"
-               "  -h --help               Show this help\n"
-               "     --version            Show package version\n"
-               "  -t --identifier=STRING  Set syslog identifier\n"
-               "  -p --priority=PRIORITY  Set priority value (0..7)\n"
-               "     --level-prefix=BOOL  Control whether level prefix shall be parsed\n"
+               "  -h --help                      Show this help\n"
+               "     --version                   Show package version\n"
+               "  -t --identifier=STRING         Set syslog identifier\n"
+               "  -p --priority=PRIORITY         Set priority value (0..7)\n"
+               "     --stderr-priority=PRIORITY  Set priority value (0..7) used for stderr\n"
+               "     --level-prefix=BOOL         Control whether level prefix shall be parsed\n"
                "\nSee the %s for details.\n"
                , program_invocation_short_name
                , link
@@ -49,15 +51,17 @@ static int parse_argv(int argc, char *argv[]) {
 
         enum {
                 ARG_VERSION = 0x100,
+                ARG_STDERR_PRIORITY,
                 ARG_LEVEL_PREFIX
         };
 
         static const struct option options[] = {
-                { "help",         no_argument,       NULL, 'h'              },
-                { "version",      no_argument,       NULL, ARG_VERSION      },
-                { "identifier",   required_argument, NULL, 't'              },
-                { "priority",     required_argument, NULL, 'p'              },
-                { "level-prefix", required_argument, NULL, ARG_LEVEL_PREFIX },
+                { "help",            no_argument,       NULL, 'h'                 },
+                { "version",         no_argument,       NULL, ARG_VERSION         },
+                { "identifier",      required_argument, NULL, 't'                 },
+                { "priority",        required_argument, NULL, 'p'                 },
+                { "stderr-priority", required_argument, NULL, ARG_STDERR_PRIORITY },
+                { "level-prefix",    required_argument, NULL, ARG_LEVEL_PREFIX    },
                 {}
         };
 
@@ -91,6 +95,13 @@ static int parse_argv(int argc, char *argv[]) {
                                                        "Failed to parse priority value.");
                         break;
 
+                case ARG_STDERR_PRIORITY:
+                        arg_stderr_priority = log_level_from_string(optarg);
+                        if (arg_stderr_priority < 0)
+                                return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                       "Failed to parse stderr priority value.");
+                        break;
+
                 case ARG_LEVEL_PREFIX: {
                         int k;
 
@@ -113,7 +124,7 @@ static int parse_argv(int argc, char *argv[]) {
 }
 
 static int run(int argc, char *argv[]) {
-        _cleanup_close_ int  fd = -1, saved_stderr = -1;
+        _cleanup_close_ int outfd = -1, errfd = -1, saved_stderr = -1;
         int r;
 
         log_parse_environment();
@@ -123,14 +134,21 @@ static int run(int argc, char *argv[]) {
         if (r <= 0)
                 return r;
 
-        fd = sd_journal_stream_fd(arg_identifier, arg_priority, arg_level_prefix);
-        if (fd < 0)
-                return log_error_errno(fd, "Failed to create stream fd: %m");
+        outfd = sd_journal_stream_fd(arg_identifier, arg_priority, arg_level_prefix);
+        if (outfd < 0)
+                return log_error_errno(outfd, "Failed to create stream fd: %m");
+
+        if (arg_stderr_priority >= 0 && arg_stderr_priority != arg_priority) {
+                errfd = sd_journal_stream_fd(arg_identifier, arg_stderr_priority, arg_level_prefix);
+                if (errfd < 0)
+                        return log_error_errno(errfd, "Failed to create stream fd: %m");
+        }
 
         saved_stderr = fcntl(STDERR_FILENO, F_DUPFD_CLOEXEC, 3);
 
-        r = rearrange_stdio(STDIN_FILENO, fd, fd); /* Invalidates fd on succcess + error! */
-        TAKE_FD(fd);
+        r = rearrange_stdio(STDIN_FILENO, outfd, errfd < 0 ? outfd : errfd); /* Invalidates fd on succcess + error! */
+        TAKE_FD(outfd);
+        TAKE_FD(errfd);
         if (r < 0)
                 return log_error_errno(r, "Failed to rearrange stdout/stderr: %m");
 
index 373a86dd4ff0485c38ff6efda14e1a39fc77038d..a1b67c6b14f8692dc4b23d5226dc06ffb85c485b 100644 (file)
@@ -7,8 +7,8 @@
 #include "sd-bus.h"
 
 enum {
-        BUS_MESSAGE_DUMP_WITH_HEADER = 1,
-        BUS_MESSAGE_DUMP_SUBTREE_ONLY = 2,
+        BUS_MESSAGE_DUMP_WITH_HEADER  = 1 << 0,
+        BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1 << 1,
 };
 
 int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags);
index a5f4724aa9b56f765bf5a09d9346490192bfee8d..d01fd8e6a3fd71f3c91b3d141e8d3dc94a1b11b1 100644 (file)
@@ -54,9 +54,9 @@ enum {
 /* Flags */
 
 enum {
-        BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
-        BUS_MESSAGE_NO_AUTO_START = 2,
-        BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 4,
+        BUS_MESSAGE_NO_REPLY_EXPECTED               = 1 << 0,
+        BUS_MESSAGE_NO_AUTO_START                   = 1 << 1,
+        BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 1 << 2,
 };
 
 /* Header fields */
@@ -78,9 +78,9 @@ enum {
 /* RequestName parameters */
 
 enum  {
-        BUS_NAME_ALLOW_REPLACEMENT = 1,
-        BUS_NAME_REPLACE_EXISTING = 2,
-        BUS_NAME_DO_NOT_QUEUE = 4
+        BUS_NAME_ALLOW_REPLACEMENT = 1 << 0,
+        BUS_NAME_REPLACE_EXISTING  = 1 << 1,
+        BUS_NAME_DO_NOT_QUEUE      = 1 << 2,
 };
 
 /* RequestName returns */
index d358a4855921e14a28884faad950969e7f241f33..650587106da77d1b61ca0f099fc8d31ce385f888 100644 (file)
@@ -4,15 +4,15 @@
 typedef struct Inhibitor Inhibitor;
 
 typedef enum InhibitWhat {
-        INHIBIT_SHUTDOWN = 1,
-        INHIBIT_SLEEP = 2,
-        INHIBIT_IDLE = 4,
-        INHIBIT_HANDLE_POWER_KEY = 8,
-        INHIBIT_HANDLE_SUSPEND_KEY = 16,
-        INHIBIT_HANDLE_HIBERNATE_KEY = 32,
-        INHIBIT_HANDLE_LID_SWITCH = 64,
-        _INHIBIT_WHAT_MAX = 128,
-        _INHIBIT_WHAT_INVALID = -1
+        INHIBIT_SHUTDOWN             = 1 << 0,
+        INHIBIT_SLEEP                = 1 << 1,
+        INHIBIT_IDLE                 = 1 << 2,
+        INHIBIT_HANDLE_POWER_KEY     = 1 << 3,
+        INHIBIT_HANDLE_SUSPEND_KEY   = 1 << 4,
+        INHIBIT_HANDLE_HIBERNATE_KEY = 1 << 5,
+        INHIBIT_HANDLE_LID_SWITCH    = 1 << 6,
+        _INHIBIT_WHAT_MAX            = 1 << 7,
+        _INHIBIT_WHAT_INVALID        = -1
 } InhibitWhat;
 
 typedef enum InhibitMode {
index 97514c34089f4cbb09f206d965b37752c0451a07..47fc80e2b0258e3167853384643631f97f10fa32 100644 (file)
@@ -15,11 +15,11 @@ typedef struct DnsAnswerItem DnsAnswerItem;
  * Note that we usually encode the empty DnsAnswer object as a simple NULL. */
 
 typedef enum DnsAnswerFlags {
-        DNS_ANSWER_AUTHENTICATED = 1 /* Item has been authenticated */
-        DNS_ANSWER_CACHEABLE     = 2,  /* Item is subject to caching */
-        DNS_ANSWER_SHARED_OWNER  = 4,  /* For mDNS: RRset may be owner by multiple peers */
-        DNS_ANSWER_CACHE_FLUSH   = 8,  /* For mDNS: sets cache-flush bit in the rrclass of response records */
-        DNS_ANSWER_GOODBYE       = 16, /* For mDNS: item is subject to disappear */
+        DNS_ANSWER_AUTHENTICATED = 1 << 0, /* Item has been authenticated */
+        DNS_ANSWER_CACHEABLE     = 1 << 1, /* Item is subject to caching */
+        DNS_ANSWER_SHARED_OWNER  = 1 << 2, /* For mDNS: RRset may be owner by multiple peers */
+        DNS_ANSWER_CACHE_FLUSH   = 1 << 3, /* For mDNS: sets cache-flush bit in the rrclass of response records */
+        DNS_ANSWER_GOODBYE       = 1 << 4, /* For mDNS: item is subject to disappear */
 } DnsAnswerFlags;
 
 struct DnsAnswerItem {
index 59c4617592caa1834ddb5e949f8a0a16c87de84e..3786ff12b84648ada1cab7c7c158ba7156405c0e 100644 (file)
@@ -979,6 +979,8 @@ bool json_variant_has_type(JsonVariant *v, JsonVariantType type) {
         JsonVariantType rt;
 
         v = json_variant_dereference(v);
+        if (!v)
+                return false;
 
         rt = json_variant_type(v);
         if (rt == type)
@@ -3140,10 +3142,7 @@ int json_log_internal(
         va_list ap;
         int r;
 
-        if (error < 0)
-                error = -error;
-
-        errno = error;
+        errno = ERRNO_VALUE(error);
 
         va_start(ap, format);
         (void) vsnprintf(buffer, sizeof buffer, format, ap);
index 4eba91c27204d39952eb7bc726aa50ef36cf9363..f8e035cda19f132d24158deaef448642dff6098d 100644 (file)
@@ -1,5 +1,4 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
-
 #pragma once
 
 #include <stdbool.h>
@@ -154,7 +153,7 @@ typedef enum JsonFormatFlags {
         JSON_FORMAT_NEWLINE    = 1 << 0, /* suffix with newline */
         JSON_FORMAT_PRETTY     = 1 << 1, /* add internal whitespace to appeal to human readers */
         JSON_FORMAT_COLOR      = 1 << 2, /* insert ANSI color sequences */
-        JSON_FORMAT_COLOR_AUTO = 1 << 3, /* insetr ANSI color sequences if colors_enabled() says so */
+        JSON_FORMAT_COLOR_AUTO = 1 << 3, /* insert ANSI color sequences if colors_enabled() says so */
         JSON_FORMAT_SOURCE     = 1 << 4, /* prefix with source filename/line/column */
         JSON_FORMAT_SSE        = 1 << 5, /* prefix/suffix with W3C server-sent events */
         JSON_FORMAT_SEQ        = 1 << 6, /* prefix/suffix with RFC 7464 application/json-seq */
index 872c25c3dc7f9237fc7ad48e5bc14effd446f62a..bf426eb8bca4d2d3a65e13f8d3186ec4b5685182 100644 (file)
@@ -45,11 +45,11 @@ int loop_device_make(int fd, int open_flags, LoopDevice **ret) {
                 *d = (LoopDevice) {
                         .fd = copy,
                         .nr = -1,
+                        .relinquished = true, /* It's not allocated by us, don't destroy it when this object is freed */
                 };
 
                 *ret = d;
-
-                return 0;
+                return d->fd;
         }
 
         r = stat_verify_regular(&st);
@@ -88,8 +88,7 @@ int loop_device_make(int fd, int open_flags, LoopDevice **ret) {
         };
 
         *ret = d;
-
-        return (*ret)->fd;
+        return d->fd;
 }
 
 int loop_device_make_by_path(const char *path, int open_flags, LoopDevice **ret) {
index d9320418cf8ec7382fe3faa1344e72771bf1c6f8..cb9b4cc89ee869506c5109925be0fd2622be186e 100644 (file)
@@ -26,6 +26,7 @@
 #include "udevadm.h"
 #include "udev-ctrl.h"
 #include "util.h"
+#include "virt.h"
 
 static int help(void) {
         printf("%s control OPTION\n\n"
@@ -70,6 +71,11 @@ int control_main(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 return r;
 
+        if (running_in_chroot() > 0) {
+                log_info("Running in chroot, ignoring request.");
+                return 0;
+        }
+
         if (argc <= 1)
                 log_error("Option missing");
 
index f7737d079089db6f347c4f2bf51d6856b7db25a7..f1b3e25cdda4d6a81664c8a85bff4adaa2c9e42d 100644 (file)
@@ -17,6 +17,7 @@
 #include "signal-util.h"
 #include "string-util.h"
 #include "udevadm.h"
+#include "virt.h"
 
 static bool arg_show_property = false;
 static bool arg_print_kernel = false;
@@ -210,6 +211,11 @@ int monitor_main(int argc, char *argv[], void *userdata) {
         if (r <= 0)
                 goto finalize;
 
+        if (running_in_chroot() > 0) {
+                log_info("Running in chroot, ignoring request.");
+                return 0;
+        }
+
         /* Callers are expecting to see events as they happen: Line buffering */
         setlinebuf(stdout);
 
index 4ae237d430b97a720858b260a824f95c166f6b36..9b05e9acf06592c9252d13a6d1f7992b0eb7667b 100644 (file)
@@ -18,6 +18,7 @@
 #include "udevadm.h"
 #include "udev-ctrl.h"
 #include "util.h"
+#include "virt.h"
 
 static usec_t arg_timeout = 120 * USEC_PER_SEC;
 static const char *arg_exists = NULL;
@@ -88,6 +89,11 @@ int settle_main(int argc, char *argv[], void *userdata) {
         if (r <= 0)
                 return r;
 
+        if (running_in_chroot() > 0) {
+                log_info("Running in chroot, ignoring request.");
+                return 0;
+        }
+
         deadline = now(CLOCK_MONOTONIC) + arg_timeout;
 
         /* guarantee that the udev daemon isn't pre-processing */
index f13a08f3f93a347182e171b10932a61bee4f6dee..aa9ebd5ac575c1a680f032652f39e53659099425 100644 (file)
@@ -15,6 +15,7 @@
 #include "strv.h"
 #include "udevadm.h"
 #include "udevadm-util.h"
+#include "virt.h"
 
 static bool arg_verbose = false;
 static bool arg_dry_run = false;
@@ -158,6 +159,11 @@ int trigger_main(int argc, char *argv[], void *userdata) {
         bool settle = false;
         int c, r;
 
+        if (running_in_chroot() > 0) {
+                log_info("Running in chroot, ignoring request.");
+                return 0;
+        }
+
         r = sd_device_enumerator_new(&e);
         if (r < 0)
                 return r;