1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-14 15:21:37 +03:00
Commit Graph

59 Commits

Author SHA1 Message Date
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
Kay Sievers
9cc94b1522 libudev: monitor - handle kernel supplied DEVNAME properly 2009-07-04 04:12:06 +02:00
Kay Sievers
fc8933f7f6 build: do not delete .la files 2009-07-04 04:12:06 +02:00
Kay Sievers
456719b6f9 udevadm: test - print list of properties 2009-07-02 22:56:19 +02:00
Kay Sievers
b25a94549c do not exports properties starting with a '.'
Private variables can be marked like:
  ENV{.FOO}="bar"
2009-06-28 02:21:58 +02:00
Kay Sievers
f86ac6e170 libudev: queue - add comments for queue format
udev/udev.pc
2009-06-22 00:32:26 +02:00
Kay Sievers
bc3ebcbdb8 libudev: install in $libdir and move later to $rootlibdir
That way, libudev.la will not get out of sync with the location of the
development so link.
2009-06-17 16:10:06 +02:00
Kay Sievers
6133f3432f cleanup ./configure installation directory options 2009-06-17 02:25:07 +02:00
Kay Sievers
0303f35723 libudev: doc - libudev-docs.sgml -> libudev-doc.xml 2009-06-16 18:54:18 +02:00
Kay Sievers
1a669a7019 libudev: doc - add empty libudev.types 2009-06-16 15:38:40 +02:00
Kay Sievers
80e9638bc8 libudev: remove prefix from .so version variables 2009-06-16 14:56:10 +02:00
Kay Sievers
1b98ae83be libudev: move .so version to libudev Makefile 2009-06-16 14:18:16 +02:00
Kay Sievers
aebaa8a66f libudev: doc - add namespace for index 2009-06-16 03:02:46 +02:00
Kay Sievers
8d6bc73aef libudev: doc - add queue 2009-06-15 20:28:28 +02:00
Kay Sievers
a7c140c723 libudev: doc - add enumerate 2009-06-15 20:04:46 +02:00
Kay Sievers
ce1d6d7fb4 libudev: doc - add section headers 2009-06-15 17:09:43 +02:00