Commit graph

124 commits

Author SHA1 Message Date
Kay Sievers 51f43b5329 selinux: do not label files in runtime dir
Do not label any files in the udev runtime directory, but only nodes,
links and directories below /dev.

In case the runtime directory falls back to /dev/.udev, label this
directory once at udevd startup, but never anything below it.
2011-04-08 01:09:20 +02:00
Thomas Egerer 6ee9b2cb8c udevd: add 'N:' to optstring in getopt_long 2011-03-31 17:26:37 +02:00
Kay Sievers fc1de713f5 systemd: bind udev control socket in systemd and split udev.service
We should bind the udev socket from systemd, so we are sure
that the abstract namespace socket is always bound by a root
process and there is never a window during an update where
an untrusted process can steal our socket.

Also split the udev.service file, so that the daemon can be
updated/restarted without triggering any coldplug events.
2011-03-23 16:40:23 +01:00
Kay Sievers 4ec9c3e797 use /run/udev/ if possible and fall back to /dev/.udev/ 2011-03-23 02:31:09 +01:00
Kay Sievers 3c6ee19027 udevd: initialize fds, for proper close() on exit 2011-03-23 01:45:21 +01:00
Kay Sievers cf3b3fbcd5 udevd: use facility == LOG_DAEMON when writing to /dev/kmsg
Syslog wants to distinguish the sorce of messages. We should
indicate that this is a userspace message (LOG_DAEMON) and not
a kernel message (LOG_KERNEL).
2011-03-23 01:41:25 +01:00
Kay Sievers 5f59fa0900 move /dev/.udev/ to /dev/.run/udev/ and convert old udev database at udevd startup 2011-03-15 17:26:08 +01:00
Michal Soltys 1a6ab67030 udevd: create static nodes before /dev/null is needed 2010-11-22 13:55:20 +01:00
Kay Sievers fc416258f3 udevd: do not wrongly delay events for devices with swapped names
Renaming network devices might delay events for the other device, which has
the same devpath in the meantime as the original event. Causing a delay until
the timout of the event is reached.

Look at the ifindex/devnum of the devices to check if they are really
the same devices.
2010-10-13 13:08:29 +02:00
Kay Sievers 392ef7a28a udevd: add sd-daemon.c 2010-10-07 14:59:11 +02:00
Luca Tettamanti c61eea9459 Add support for oom_score_adj
/proc/<pid>/oom_adj has been deprecated (kernel v2.6.36) due to the
rework of the badness heuristic; oom_score_adj is the replacement.
Keep a fallback to the old interface for compatibility with older
kernels.

See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=a63d83f427fbce97a6cea0db2e64b0eb8435cd10

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-25 16:50:30 +02:00
Kay Sievers 13f90be7a3 udevd: remove unneeded credential passing from init_notify() 2010-08-25 16:26:54 +02:00
Kay Sievers c25bfbfb1b udevd: add pid to kmsg logs 2010-08-19 08:49:43 +02:00
Yin Kangkai 08f11597f2 udevd: create static device links only when the target exists
For example, not all systems have PROC_KCORE enabled. Avoid a broken symbolic
link in those cases.

Signed-off-by: Yin Kangkai <kangkai.yin@intel.com>
Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-08 20:35:46 +02:00
Yin Kangkai 40929a0222 udevd: fix unref'ing of device in error path
Signed-off-by: Yin Kangkai <kangkai.yin@intel.com>
Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-08 20:29:13 +02:00
Yin Kangkai 4ab3c463d4 udevd: fix short options in getopt() 2010-08-03 08:11:43 +02:00
Yin Kangkai 1851332c08 udevd: fix some memory leaks in error path
Signed-off-by: Yin Kangkai <kangkai.yin@intel.com>
2010-08-02 12:37:55 +02:00
Kay Sievers 35df38c36a udevd: init_notify() fix abstract namespace name handling 2010-07-11 23:57:11 +02:00
Kay Sievers a65aa40f8a udevd: in case we don't daemonize, send READY message to /sbin/init 2010-06-17 21:52:15 +02:00
Kay Sievers 1182b9470f udevd: set umask before creating files/directories 2010-05-30 23:42:47 +02:00
Kay Sievers c830e98d6a udevd: read debug settings from kernel commandline 2010-05-28 12:07:27 +02:00
Kay Sievers d4c1467f85 udevd: fix comments 2010-05-27 17:45:58 +02:00
Kay Sievers 337d102783 udevd: replace --debug-trace with --children-max 2010-05-27 17:41:51 +02:00
Kay Sievers 87d55ff672 childs -> children 2010-05-27 17:27:56 +02:00
Kay Sievers 88cbfb09ee while (1) -> for (;;) 2010-05-27 15:11:00 +02:00
Bryan Kadzban 4bfa5cf5c3 udevd: fix typo /proc/fd -> /proc/self/fd 2010-05-25 06:56:37 +02:00
Kay Sievers 761dfddcc0 create static nodes provided by kernel modules to allow module autoloading 2010-05-20 17:09:04 +02:00
Kay Sievers cb9a0eeeab udevd: create standard symlinks and handle /lib/udev/devices 2010-05-20 09:04:26 +02:00
Kay Sievers 79e1912b91 udevd: reload config only for *.rules files 2010-05-11 22:59:09 +02:00
Kay Sievers 665ee17def udevd: always try to find an idle worker instead of forking a new one
We special-handle events with a TIMEOUT= set, so they don't get queued
or wait for parent events to finish, to make sure we can handle them
as fast as possible.

With this change we first try to find an idle worker process before
forking a new one.
2010-04-26 12:25:59 +02:00
Kay Sievers 4b06c40935 replace "add|change" with "!remove" 2010-04-12 16:52:41 +02:00
Kay Sievers 6f1892dc7a udevd: inotify - do not parse rules at create but at close
We do not need to get notified about created files, only about moved
ones or files closed-after-writing.
2010-01-13 13:09:02 +01:00
Kay Sievers f46d2e54a8 remove UDEV_RUN environment variable
It handles only RUN but not IMPORT and PROGRAM. There is no sane way
to suppress program execution. Most important programs run with IMPORT
these days. Also events can no longer suppressed with the libudev
netlink messages, so UDEV_RUN does nothing useful and is just
inconsistent.
2009-12-25 15:23:45 +01:00
Kay Sievers 3c1898863f remove remaining support for CONFIG_SYSFS_DEPRECATED 2009-12-15 16:14:14 +01:00
Kay Sievers cdae488a3f remove "ignore_device"
There is no way to ignore an event these days. Libudev events can
not be suppressed. It only prevents RUN keys from being executed,
which results in an inconsistent behavior in current setups.
2009-11-16 15:22:17 +01:00
Kay Sievers 081be002ea udevd: create /dev/.udev/rules.d/ before watching it wit inotify
This should also address:

On Tue, Nov 3, 2009 at 16:21, Marco d'Itri <md@linux.it> wrote:
> udev_rules_new() in udev/udev-rules.c unconditionally creates the
> directory.
> This is a problem because the function is called also by e.g. udevadm
> test, and creating /dev/.udev/ when it does not exist is an unacceptable
> side effect which will break everything else that checks for its
> existence to know if udev is running.
2009-11-04 17:06:52 +01:00
Kay Sievers 26347a4c55 use CLOEXEC flags instead of fcntl() 2009-10-30 12:39:04 +01:00
Kay Sievers 19711e1933 udevd: serialize events for with the same major/minor
On Wed, Oct 7, 2009 at 21:46, Alan Jenkins <sourcejedi.lkml@googlemail.com> wrote:
> Udev would have avoided the race prior to
>
> 82c785e "udevd: remove check for dev_t, DEVPATH_OLD takes care of that"
>
> (the "check" removed here used to serialize events based on the device
> major:minor number).

On Wed, Oct 7, 2009 at 22:31, Michael Guntsche <mike@it-loops.com> wrote:
> add      /module/8250_pnp (module)
> remove /devices/platform/serial8250/tty/ttyS0 (tty)
> add      /devices/pnp0/00:05/tty/ttyS0 (tty)
2009-10-08 00:06:23 +02:00
Andrew Church 4daa146bf7 fix wrong parameter size on ioctl FIONREAD
On Wed, Sep 23, 2009 at 23:11, Matthias Schwarzott <zzam@gentoo.org> wrote:
> It is about ioctl failures on amd64:
>   http://bugs.gentoo.org/show_bug.cgi?id=286041
>
> A bad parameter type to an ioctl() call causes udev-146 to generate "error
> getting buffer for inotify" messages in syslog.  The offending code is
> roughly:
>
>    ssize_t nbytes, pos;
>    // ...
>    ioctl(fd, FIONREAD, &nbytes);
>
> where ssize_t is 64 bits on amd64, but the kernel code for FIONREAD (at least
> through gentoo-sources-2.6.31) uses type int:
>
>    p = (void __user *) arg;
>    switch (cmd) {
>    case FIONREAD:
>        // ...
>        ret = put_user(send_len, (int __user *) p);
>
> so the upper 32 bits of "nbytes" are left uninitialized, and the subsequent
> malloc(nbytes) fails unless those 32 bits happen to be zero (or the system has
> a LOT of memory).
2009-09-24 10:53:10 -07:00
Jeremy Kerr d412a68573 util_run_program: restore signal mask before executing event RUN commands
External programs triggered by events (via RUN=) will inherit udev's
signal mask, which is set to block all but SIGALRM. For most utilities,
this is OK, but if we start daemons from RUN=, we run into trouble
(especially as SIGCHLD is blocked).

This change saves the original sigmask when udev starts, and restores it
just before we exec() the external command.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
2009-09-07 12:13:50 +02:00
Kay Sievers cb6268f419 udevd: block for 15 seconds after error when too old kernel is detected
The compat code will go away some day and CONFIG_SYSFS_DEPRECATED
kernels fail in too many setups now to be worth to support them.
2009-08-08 22:59:41 +02:00
Kay Sievers f7c5b04f69 re-enable failed event tracking
It did not work for the last couple of releases.

If RUN{record_failed}+="..." is given, a non-zero execution will mark
the event as failed. Recorded failed events can be re-triggered with:
  udevadm trigger --type=failed

The failed tracking _might_ be useful for things which might not be
ready to be executed at early bootup, but a bit later when the needed
dependencies are available. In many cases though, it indicates that
something is used in a way it should not.
2009-08-06 16:16:26 +02:00
Kay Sievers 820fc48f24 udevd: add timestamp to --debug output 2009-07-17 13:26:46 +02:00
Kay Sievers c380472899 udevd: use bool 2009-07-13 03:33:15 +02:00
Kay Sievers bc113de9a4 udevd: handle SIGCHLD before the worker event message
We may need to handle SIGCHLD before the queued worker message. The last
reference, from the SIGCHLD or the worker message will clean up the worker
context. In case we receive an unexpected SIGCHLD with an error, we let
the event fail and clean up the worker context.
2009-07-13 03:09:05 +02:00
Kay Sievers adda4c682a udevd: make sure a worker finishes event handling before exiting
Persistent network rules write out new rules files. When rules change,
we need to kill all workers to update the in-memory copy of the rules.
We need to make sure, that a worker finshes its work for all device
messages it has accepted, before it exits after a SIGTERM from the main
process.
2009-07-11 18:21:26 +02:00
Kay Sievers a073cfa844 udevd: detach event from worker if we kill a worker
Jul  8 09:36:41 udevd[663]: worker [5491] did not accept message, kill it
Jul  8 09:36:41 udevd[663]: worker [5491] unexpectedly returned with 0
Jul  8 09:36:41 udevd[663]: worker [5551] unexpectedly returned with 0
Jul  8 09:36:41 kernel: [  156.832086] <6>udevd[663]: segfault at 4 ip 00959fbc sp bfbe7b78 error 6 in udevd[94f000+1c000]

https://bugs.launchpad.net/ubuntu/+source/udev/+bug/396957
2009-07-08 14:13:20 +02:00
Kay Sievers 6133f3432f cleanup ./configure installation directory options 2009-06-17 02:25:07 +02:00
Kay Sievers 9060b066d9 move syslog wrapper to libudev 2009-06-09 22:47:48 +02:00
Kay Sievers 12bc9c54f2 udevd: log info for created/killed workers 2009-06-09 18:31:14 +02:00