Commit graph

17 commits

Author SHA1 Message Date
Lennart Poettering ee104e11e3 user-util: move UID/GID related macros from macro.h to user-util.h 2015-10-27 13:25:57 +01:00
Lennart Poettering 8b43440b7e util-lib: move string table stuff into its own string-table.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering f4f15635ec util-lib: move a number of fs operations into fs-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering 6bedfcbb29 util-lib: split string parsing related calls from util.[ch] into parse-util.[ch] 2015-10-27 13:25:55 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Lennart Poettering e53fc357a9 tree-wide: remove a number of invocations of strerror() and replace by %m
Let's clean up our tree a bit, and reduce invocations of the
thread-unsafe strerror() by replacing it with printf()'s %m specifier.
2015-09-30 22:26:16 +02:00
Lennart Poettering dacd6cee76 tree-wide: port everything over to fflush_and_check()
Some places invoked fflush() directly with their own manual error
checking, let's unify all that by using fflush_and_check().

This also unifies the general error paths of fflush()+rename() file
writers.
2015-07-29 20:31:07 +02:00
Tom Gundersen ccc1002a1c sd-device: ensure update_properties_buf() is a noop on failure
Don't clobber the sd_device struct, and don't leak memory when memory allocation fails.
2015-06-01 16:28:58 +02:00
Martin Pitt d854ba50a8 sd-device: fix invalid property strv pointers
In device_update_properties_bufs(), the strv is built from pointers into the
single nul-terminated buf_nulstr string, to avoid allocating the key=value
strings twice. However, we must not do that while building and
GREEDY_REALLOC0()'ing buf_nulstr, as each time when this actually reallocates
memory the pointers we wrote into buf_strv so far become invalid.

So change the logic to first completely build the new buf_nulstr, and then
iterate over it to pick out the pointers to the individual key=value strings
for properties_strv.

This fixes invalid environment for udev callouts.
2015-06-01 12:04:37 +02:00
Tom Gundersen 0e3e605613 sd-device: fix device_get_properties_strv()
A NULL pointer was inserted as the first element of the strv.

This had the effect of always passing the empty environment to processes
spawned by udev.

Reported by Michał Bartoszkiewicz.
2015-05-27 23:30:02 +02:00
Tom Gundersen 107f2e2526 udevd: fix REMOVE handling
This reverts b67f944. Lazy loading of device properties does not work for devices
that are received over netlink, as these are sealed. Reinstate the unconditional
loading of the device db.

Reported by: Mantas Mikulėnas <grawity@gmail.com>.
2015-04-23 22:31:25 +02:00
Tom Gundersen de9b34b6d4 sd-device: don't use alloca() within loops
I shall not use alloca() within loops
 I shall not use alloca() within loops
 I shall not use alloca() within loops
 I shall not use alloca() within loops
...
2015-04-05 12:17:29 +02:00
Tom Gundersen 401cb61499 sd-device,udevd: fix spelling /ammend/amend/ 2015-04-03 22:51:09 +02:00
Tom Gundersen 4df4fd1127 sd-device: fix deserialization from netlink
Use the standard FOREACH_WORD* macros.

The current code was broken in the devlink case so the last one received
was being dropped, causing https://bugs.freedesktop.org/show_bug.cgi?id=89894
2015-04-03 22:17:52 +02:00
Tom Gundersen aa20f49a1c sd-device: get_properties_{nulstr,strv} - don't recreate the buffer unnecessarily 2015-04-03 22:17:41 +02:00
Tom Gundersen 57fa1d094c libsystemd: add sd-device library
This provides equivalent functionality to libudev-device, but in the
systemd style. The public API only caters to creating sd_device objects
from for devices that already exist in /sys, there is no support for
listening for monitoring events or creating devices received over
the udev netlink protocol.

The private API contains the necessary functionality to make sd-device
a drop-in replacement for libudev-device, but which we would not
otherwise want to export.
2015-04-02 00:18:27 +02:00