Commit graph

364 commits

Author SHA1 Message Date
Yu Watanabe d4d690facd udevd: use device_get_action() and device_get_seqnum() 2019-03-12 03:49:53 +09:00
Yu Watanabe d02c6f5461 udev-ctrl: use sd_event and introduce udev_ctrl_start()
Now the new callback function get enum udev_ctrl_msg_type.
So, this commit also drops udev_ctrl_connection and udev_ctrl_msg.
2019-02-20 06:17:42 +09:00
Yu Watanabe 204e9c3e29 udev: drop unused Manager::uevent_event 2019-02-20 06:17:42 +09:00
Yu Watanabe 100bc5bf98 udev-ctrl: make udev_ctrl_new() return negative errno on failure 2019-02-20 06:17:42 +09:00
Lennart Poettering bbd8598f8b
Merge pull request #11589 from yuwata/udevd-is-device-busy
udevd: refactoring is_device_busy()
2019-02-15 12:16:37 +01:00
Yu Watanabe 31cbd20253 udev: check whether systemd is running, and do not use cg_kill() if not
Fixes #11645.
2019-02-13 17:07:56 +01:00
Yu Watanabe 8671411668 udevd: save the result of devnum or ifindex blocker 2019-01-29 14:07:21 +01:00
Yu Watanabe baa461fc05 udevd: always block follwoing events with same devpath
Originally commented as "devices names might have changed/swapped in the meantime",
but may not. For safety, let's block the following events with same
devpath.

This may fix #6514.
2019-01-29 14:04:43 +01:00
Yu Watanabe 0bd0407efc udevd: trivial refactoring of is_device_busy() 2019-01-29 13:53:19 +01:00
Yu Watanabe d30f43eec5 udevd: rename control command SYNC -> PING in log message 2019-01-18 16:10:01 +01:00
Yu Watanabe c809f33719 udev: also update log level for LOG_REALM_SYSTEMD
Now, not a few udevd debug logs come from sd-device or sd-hwdb.
Only setting LOG_REALM_UDEV may not sufficient to debug.
We have already similar code in main() and udevadm.
2019-01-13 07:37:49 +09:00
Yu Watanabe e0b7a5d151 udevd: refuse devices which do not have ACTION property 2019-01-12 09:32:20 +09:00
Yu Watanabe 33ad742a84 udevd: drop unnecessary brackets 2019-01-12 09:32:20 +09:00
Yu Watanabe c0ff3d6cbc udevd: make worker also log ACTION property 2019-01-12 09:32:20 +09:00
Yu Watanabe 25d4f5b071 udevd: reject devices which do not have SEQNUM 2019-01-12 09:32:20 +09:00
Yu Watanabe 956833b417 udevd: provide worker_hash_ops and drop manager_workers_free() 2019-01-12 09:32:20 +09:00
Yu Watanabe d40534643b udevd: use structured initializer at one more place 2019-01-12 09:32:20 +09:00
Yu Watanabe 1f3f6bd007 udevd: use worker_free() on failure in worker_new()
Otherwise, worker_monitor may not unrefed correctly.
2019-01-12 09:32:20 +09:00
Zbigniew Jędrzejewski-Szmek b5af8c8cdf udev: open control and netlink sockets before daemonization
c4b69e990f effectively moved the initalization of socket.
Before that commit:
run → listen_fds → udev_ctrl_new → udev_ctrl_new_from_fd → socket()
After:
run → main_loop → manager_new → udev_ctrl_new_from_fd → socket()

The problem is that main_loop was called after daemonization. Move manager_new
out of main_loop and before daemonization.

Fixes #11314 (hopefully ;)).

v2: Yu Watanabe
sd_event is initialized in main_loop().
2019-01-10 14:09:15 +09:00
Zbigniew Jędrzejewski-Szmek 44dcf454b6 udevd: drop redundant call to sd_event_get_exit_code
sd_event_loop returns the same thing anyway.
2019-01-10 14:09:01 +09:00
Zbigniew Jędrzejewski-Szmek 88514e7bae
Merge pull request #11244 from yuwata/revert-udev-changes
udev: revert bind/unbind patch and one more
2019-01-03 16:28:30 +01:00
Yu Watanabe ff86c92e30 Revert "udevd: configure a child process name for worker processes"
This reverts commit 49f3ee7e74.
2019-01-02 04:01:07 +09:00
Zbigniew Jędrzejewski-Szmek 681bd2c524 meson: generate version tag from git
$ build/systemctl --version
systemd 239-3555-g6178cbb5b5
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid
$ git tag v240 -m 'v240'
$ ninja -C build
ninja: Entering directory `build'
[76/76] Linking target fuzz-unit-file.
$ build/systemctl --version
systemd 240
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid

This is very useful during development, because a precise version string is
embedded in the build product and displayed during boot, so we don't have to
guess answers for questions like "did I just boot the latest version or the one
from before?".

This change creates an overhead for "noop" builds. On my laptop, 'ninja -C
build' that does nothing goes from 0.1 to 0.5 s. It would be nice to avoid
this, but I think that <1 s is still acceptable.

Fixes #7183.

PACKAGE_VERSION is renamed to GIT_VERSION, to make it obvious that this is the
more dynamically changing version string.

Why save to a file? It would be easy to generate the version tag using
run_command(), but we want to go through a file so that stuff gets rebuilt when
this file changes. If we just defined an variable in meson, ninja wouldn't know
it needs to rebuild things.
2018-12-21 13:43:20 +01:00
Lennart Poettering 95cde1ed24
Merge pull request #11159 from keszybz/udev-typedef
Udev typedef and normal error reporting
2018-12-17 16:19:10 +01:00
Zbigniew Jędrzejewski-Szmek 2e08871534 udev: use typedef for struct udev_event 2018-12-17 09:27:24 +01:00
Zbigniew Jędrzejewski-Szmek 9a07157dd5 udev: use typedef for struct udev_rules 2018-12-17 09:27:21 +01:00
Zbigniew Jędrzejewski-Szmek 1d79128121 udev: make udev_rules_new() return a proper error code 2018-12-14 10:20:43 +01:00
Yu Watanabe 903893237a sd-device: do not change buffer size if the socket is already bound
From the results of CIs in #11076, changing buffer size may cause
issue #10754. So, let's prohibit to change the size if it is already
bound.

This also reverts commit 986ab0d2dc.
2018-12-14 09:33:06 +09:00
Lennart Poettering 49f3ee7e74 udevd: configure a child process name for worker processes 2018-12-01 12:50:45 +01:00
Lennart Poettering ece0fe12ad tree-wide: (void)ify some setsid() and related calls 2018-12-01 12:50:45 +01:00
Lennart Poettering a0ee3d93bb
Merge pull request #10919 from yuwata/sd-device-monitor-fixes
sd-device-monitor: several fixes
2018-11-26 18:08:41 +01:00
Lennart Poettering 49fe5c0996 tree-wide: port various places over to STARTSWITH_SET() 2018-11-26 14:08:46 +01:00
Yu Watanabe 6acf1ccba5 udevd: do not call udev_ctrl_enable_receiving() if the socket is passed from pid1
Before c4b69e990f, if the socket fd is
passed from pid1, `udev_ctrl_enable_receiving()` was not called.
Let's preserve the original logic.
2018-11-26 11:57:48 +09:00
Yu Watanabe 986ab0d2dc udevd: do not set buffer size if the socket is passed from pid1
Before c4b69e990f, if the socket fd is
passed from pid1, `udev_monitor_set_receive_buffer_size()` (now it is
a wrapper of `sd_device_monitor_set_receive_buffer_size()`) was not
called. Let's preserve the original logic.
2018-11-25 20:17:25 +09:00
Yu Watanabe 981fae90df udev: rename udev_rules_unref() to udev_rules_free()
As udev_rules do not have a reference counter.
2018-11-23 00:07:40 +09:00
Zbigniew Jędrzejewski-Szmek d4e98880e9 Also drop a few more unnecessary uses of synthethic errno 2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 886cf317c4 coccinelle: also mark previous synthetic errnos as such 2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 0c5a109a25 udevd: define main through macro
This removes the call to log_close(), and refactors how fork() is done. Now
the parent also goes through normal cleanup. This isn't necessary to use the
macro, but it feels cleaner this way.
2018-11-21 09:14:00 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Yu Watanabe 5ea78a39e5 libudev-list: move libudev-list related definitions to libudev-list-internal.h
This also rename libudev-private.h to libudev-util.h, and cleanups
several unnecessary headers from udev.h and libudev-util.h
2018-11-20 14:38:35 +09:00
Yu Watanabe eb546b3532 udevd: replace udev_device in struct event by sd_device 2018-11-17 21:45:03 +09:00
Yu Watanabe 044497e2a3 udevd: update several log messages 2018-11-17 21:45:03 +09:00
Yu Watanabe ba47b71c2d udevd: decrease indentation 2018-11-17 21:45:03 +09:00
Yu Watanabe d8f462b435 udevd: rename event sources in struct event 2018-11-17 21:45:03 +09:00
Yu Watanabe dc7faf2a6f udevd: capitalize log messages in on_sigchld() 2018-11-17 21:45:03 +09:00
Yu Watanabe e2130348ef udevd: also use sd_device_monitor_start() in worker_main() 2018-11-17 21:45:03 +09:00
Yu Watanabe f00d2b6dd2 udevd: use sd_device_monitor_start() in manager_new() 2018-11-17 21:45:03 +09:00
Yu Watanabe 7f2e3a1409 udevd: replace udev_monitor by sd_device_monitor 2018-11-17 21:45:03 +09:00
Yu Watanabe 7443654e5f udevd: use safe_fork() to spawn worker process 2018-11-17 21:45:03 +09:00
Yu Watanabe abde5ea854 udevd: make worker_process_device() take sd_device instead of udev_device 2018-11-17 21:45:03 +09:00