1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-28 20:25:38 +03:00
Commit Graph

74 Commits

Author SHA1 Message Date
Thomas de Grenier de Latour
9bdcffd738 libudev: enumerate - fix move_later logic
The move_later_prefix variable was reset to zero on each
loop iteration, and thus the move_later entry (if any) was
not added right after changing to another syspath prefix,
but rather after exiting the enumeration loop.
2009-12-30 16:21:59 +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
1d67ec16c4 fix typo in log message priority handling 2009-12-25 14:47:59 +01:00
Kay Sievers
58b533f417 remove remaining support for CONFIG_SYSFS_DEPRECATED 2009-12-24 22:10:40 +01:00
Martin Pitt
b73bf332c2 Speed up udev_enumerate_scan_*
Check property match earlier, to avoid lots of readlink() and stat()
calls when we check property matches.
2009-12-21 15:41:25 +01:00
Kay Sievers
3c1898863f remove remaining support for CONFIG_SYSFS_DEPRECATED 2009-12-15 16:14:14 +01:00
Daniel Elstner
3fac12b9a0 libudev: wrap in extern "C" block for C++
When libudev.h is included from C++ code, wrap the declarations in an
extern "C" { ... } block.  This tells the C++ compiler that symbols
are exported with C linkage and no name-mangling.
2009-12-15 12:49:25 +01:00
Kay Sievers
99eb7c451c util_unlink_secure(): chmod() before chown() 2009-12-08 18:44:45 +01:00
Kay Sievers
79ef2e97d9 libudev: doc - use #NULL 2009-12-03 13:31:27 +01:00
Martin Pitt
54d4f54e85 udev_device_get_parent_with_subsystem_devtype(): Clarify documentation
devtype can be NULL, in which case it is ignored for matching.
2009-12-03 13:25:19 +01:00
Alan Jenkins
88fbff03df udevd: queue-export - remove retry loop
These retry loops are required where create_path() could race with
delete_path().  But only the main udevd process writes to the queue,
so no races will happen here.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2009-10-30 12:39:04 +01:00
Kay Sievers
26347a4c55 use CLOEXEC flags instead of fcntl() 2009-10-30 12:39:04 +01:00
Kay Sievers
6834a44299 break loops if util_create_path() returns error
Dangling symlinks in path components return -ENOENT. Do not retry
to create the file in a loop in such case.
2009-10-28 11:37:20 +01:00
Peter Rajnoha
1230d021bd libudev: allow to store negative values in the udev database 2009-10-20 06:55:42 +09:00
Scott James Remnant
49c3a01d44 util_run_program: *really* restore signal mask before executing event RUN commands
The previous patch was almost, but not quite, correct.  Rather than
restoring the signal mask it actually tried to make an even more
restrictive signal mask (had SIGALRM been blocked when udevd started,
anyway).

Fix it harder.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-09-22 14:39:23 -07:00
Kay Sievers
b6a2637524 put util_create_path() and file creastion in a retry loop
On 8/29/09, Florian Zumbiehl <florz@florz.de> wrote:
> Could it happen that > util_create_path() and util_delete_path()
> do run in parallel for > the same directory? After all, util_create_path()
> does handle > the case where creation of the directory happens in parallel
> to it running, so it doesn't seem all that unlikely to me ...
2009-09-10 02:08:05 +02:00
Kay Sievers
676d294c23 reorder create_path() and node/link creation to be called in a direct sequence 2009-09-10 01:35:48 +02:00
Kay Sievers
6c29f2b942 simplify "symlink name stack"
With well defined and kernel-supplied node names, we no longer need
to support a possible stack of conflicting symlinks and node names.
Only symlinks with identical names can be claimed by multiple devices.

This shrinks the former /dev/.udev/names/ significantly.

Also the /dev/{block,char}/MAJ:MIN" links are excluded from the name
stack - they are unique and can not conflict.
2009-09-09 18:49:07 +02:00
Kay Sievers
78715f65c9 fix randonm findings from llvm-clang-analyzer
Thanks to Lennart for the log file!
2009-09-08 22:11:04 +02:00
Florian Zumbiehl
04d4a6f858 util_run_program(): fix possible buffer overflow #2
I'm not sure how likely it is for UTIL_PATH_SIZE to have an odd value
(maybe it has right now? :-), but I guess making this universally correct
doesn't hurt ...
2009-09-08 21:42:21 +02:00
Kay Sievers
f55083ce34 util_run_program(): skip multiple spaces in argv creation 2009-09-07 12:13:50 +02: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
Florian Zumbiehl
9e6273c713 udev_queue_get_seqnum_sequence_is_finished(): fix possible file handle leak 2009-09-07 12:13:50 +02:00
Florian Zumbiehl
8cfcf9980a udev_util_encode_string(): fix possible buffer overflow 2009-09-01 12:54:21 +02:00
Kay Sievers
0652604912 libudev-util.c: get_sys_link() - return error for empty link target 2009-09-01 12:39:57 +02:00
Florian Zumbiehl
32ecabb15d util_resolve_sys_link(): fix possible buffer overflow 2009-09-01 12:38:16 +02:00
Florian Zumbiehl
4c21b7156d util_create_path(): fix possible out of bounds array access 2009-08-30 21:40:13 +02:00
Florian Zumbiehl
b0de6a6327 util_delete_path(): handle multiple leading slashes 2009-08-29 16:50:43 +02:00
Kay Sievers
28da1a6186 util_create_path(): fix errno usage
Based on a patch from: Florian Zumbiehl <florz@florz.de>
2009-08-29 16:38:01 +02:00
Florian Zumbiehl
72c0373f79 util_lookup_group(): fix memory leak if realloc() fails 2009-08-29 16:25:47 +02:00
Florian Zumbiehl
f46b9c2628 util_delete_path(): use util_strscpy() 2009-08-29 16:17:54 +02:00
Kay Sievers
39087d3bdd util_unlink_secure(): chmod() before chown()
Suggested by Florian Zumbiehl <florz@florz.de>.
2009-08-29 16:10:24 +02:00
Kay Sievers
4851d131d6 assign errno for getgrnam_r()/getpwnam_r()
On Mon, Aug 24, 2009 at 19:50, Lennart Poettering<lennart@poettering.net> wrote:
> One little comment here: on POSIX getrnam_r() doesn't touch
> errno. Instead it returns the error value as return value.
2009-08-25 21:09:22 +02:00
Kay Sievers
2ffc9cc191 change database file names
With very deeply nested devices, We can not use a single file
name to carry an entire DEVPATH. Use <subsystem>:<sysname> as
the database filename, which should also simplify the handling
of devices moving around, as these values will not change but
still be unique.

For the name stack we use the <maj>:<min> now as the filename.

> On Tue, Aug 18, 2009 at 09:59:56AM -0400, Ric Wheeler wrote:
> The first is that udev grumbles during boot about "file name too long"
> like the following:
>
> Aug 17 06:49:58 megadeth udevd-event[20447]: unable to create db file
> '/dev/.udev/db/\x2fdevices\x2fpci0000:00\x2f0000:00:04.0\x2f0000:17:00.0\x2f0000:18:0a.0\x2f0000:1f:00.0\x2fhost11\x2fport-11:0\x2fexpander-11:0\x2fport-11:0:0\x2fexpander-11:1\x2fport-11:1:0\x2fexpander-11:2\x2fport-11:2:17\x2fexpander-11:3\x2fport-11:3:1\x2fend_device-11:3:1\x2fbsg\x2fend_device-11:3:1':
> File name too long
2009-08-19 20:49:49 +02:00
Daniel Mierswa
8eefdffb6b don't compare a non-existing function with NULL
Obviously someone forgot something here or didn't use -ansi. Either way,
index is nowhere declared so I assume the current behaviour is to check
against the index() function coming from somewhere in the POSIX headers.
The comparison doesn't make sense then.

Signed-off-by: Daniel Mierswa <impulze@impulze.org>
2009-08-18 02:00:39 +02:00
Alan Jenkins
214a6c791c fix spelling
Fix spelling in docbook comments, code comments, and a local variable
name.  Thanks to "ispell -h" for docbook HTML and "scspell" for source
code.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2009-08-08 15:42:05 +02:00
Diego Elio 'Flameeyes' Pettenò
bd2dab9ce5 Fix building of documentation when doing out-of-source builds.
Since gtk-mkhtml is executed in a sub-directory of the build directory, and
make does not know of that, the $(buildir) variable will still be "." and
the $(srcdir) will not properly be found. For this reason, use the absolute
variants for the two functions, which won't be changing.
2009-08-07 21:54:35 +02:00
Diego Elio 'Flameeyes' Pettenò
59d93adb29 Merge libudev, udev, and the unconditional extras in a single Makefile.am.
Instead of using multiple recursive Makefile.am files, use a single
Makefile.am that sets and builds all the basic suite of libraries and
binaries for udev. This reduces the number of files in the source tree, and
also reduces drastically the build time when using parallel-make.

With this setup, all the compile steps will be executed in parallel, and
just the linking stage will be (partially) serialised on the libraries
creation.
2009-08-07 19:15:28 +02:00
Kay Sievers
43c42ca454 libudev: silent gcc warning: may be used uninitialized in this function 2009-08-06 15:37:55 +02:00
Kay Sievers
fc206fbe3e update a few years of copyright 2009-08-01 09:39:18 -04:00
Eric W. Biederman
504a553e78 fix util_lookup_group to handle large groups
I have recently been getting the above message on fc11 and
I have traced it down to a bug in util_lookup_group.

As of 145 util_lookup_group reads:

gid_t util_lookup_group(struct udev *udev, const char *group)
{
	char *endptr;
	int buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
	char buf[buflen];
	struct group grbuf;
	struct group *gr;
	gid_t gid = 0;

	if (strcmp(group, "root") == 0)
		return 0;
	gid = strtoul(group, &endptr, 10);
	if (endptr[0] == '\0')
		return gid;

	errno = 0;
	getgrnam_r(group, &grbuf, buf, buflen, &gr);
	if (gr != NULL)
		return gr->gr_gid;
	if (errno == 0 || errno == ENOENT || errno == ESRCH)
		err(udev, "specified group '%s' unknown\n", group);
	else
		err(udev, "error resolving group '%s': %m\n", group);
	return 0;
}

The errno value from getgrnam_r here is ERANGE which is documented as
"Insufficient buffer space supplied".

When I call get getgrnam_r with a large enough buffer everything
works.  Indicating that the problem is that sysconf is returning
a value too small.

A quick google search tells me that sysconf(_S_GETGR_R_SIZE_MAX)
is documented as:

> sysconf(_S_GETGR_R_SIZE_MAX) returns either -1 or a good
> suggested starting value for buflen.  It does not return the
> worst case possible for buflen.

In my case I have a group with about 50 users in /etc/group
and that is what triggered the problem in udev and caused
all of the udevs group lookups to fail.

The following patch which dynamically allocates the group member buffer
should fix this problem.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2009-08-01 09:23:50 -04:00
Lennart Poettering
3bf768245b enumeration: move ALSA control devices to the end of the enumerated devices of each card
Generally ALSA control devices should be the last ones to be processed
for ACL changes and similar operations because they can then be used as
indicators that ACL management finished for all device nodes of a
specific card.

This patch simple moves each controlC device behind all the pcmC devices
(and similar).
2009-07-28 03:10:05 +02:00
Kay Sievers
2a827c959a make: build internal tools against libudev-private.la 2009-07-25 20:37:45 +02:00
Kay Sievers
cf5bd04073 udevadm: trigger - add --sysname-match=
$ udevadm trigger -n -v --subsystem-match=usb --sysname-match=2-1.1*
  /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1
  /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1.1
  /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1.1/2-1.1.1:1.0
  /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1.2
  /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1.2/2-1.1.2:1.0
  /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1.2/2-1.1.2:1.1
  /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.1/2-1.1:1.0
2009-07-23 00:02:28 +02:00
Kay Sievers
820fc48f24 udevd: add timestamp to --debug output 2009-07-17 13:26:46 +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
871a36bd7e libudev: enumerate - sort with qsort()
On machines with many thousands of devices:
  $ time find /sys -name uevent | wc -l
  74876

  real      0m33.171s
  user      0m3.329s
  sys       0m29.719s

the current udevtrigger spends minutes sorting the device list:
  $ time /sbin/udevadm trigger --dry-run

  real      4m56.739s
  user      4m45.743s
  sys       0m7.862s

with qsort() it looks better:
  $ time udev/udevadm trigger --dry-run

  real      0m6.495s
  user      0m0.473s
  sys       0m5.923s
2009-07-08 02:04:49 +02:00
Kay Sievers
a71369b0db libudev: device - free values before updating them 2009-07-08 02:02:40 +02:00
Kay Sievers
257bb4cdac use MIN() MAX() from param.h 2009-07-07 19:30:19 +02:00
Kay Sievers
182c9b1584 build: add *exec* to the internal rootlibdir name
Automake like variables with *exec* in the directory names,
to decide, that it isn't *data*:
  http://www.gnu.org/software/hello/manual/automake/The-Two-Parts-of-Install.html#The-Two-Parts-of-Install
2009-07-05 23:56:24 +02:00