summaryrefslogtreecommitdiff
path: root/src/basic
AgeCommit message (Collapse)Author
2015-07-16bitmap: use external iteratorTom Gundersen
Reuse the Iterator object from hashmap.h and expose a similar API. This allows us to do { Iterator i; unsigned n; BITMAP_FOREACH(n, b, i) { Iterator j; unsigned m; BITMAP_FOREACH(m, b, j) { ... } } } without getting confused. Requested by David.
2015-07-15Merge pull request #588 from teg/resolved-nsecDaniel Mack
resolved: add basic NSEC and NSEC3 support
2015-07-14basic: util - add base32hexmem() function similar to hexmem()Tom Gundersen
This implements more of RFC4648.
2015-07-14basic: add a Bitmap implementationTom Gundersen
For when a Hashmap is overkill.
2015-07-14basic: util - fix memleak on error in unbase64mem()Tom Gundersen
2015-07-12basic: util - add base64mem() function similar to hexmem()Tom Gundersen
This implements RFC4648 for a slightly more compact representation of binary data compared to hex (6 bits per character rather than 4).
2015-07-12basic: util - fix errorhandling in unhexmem()Tom Gundersen
We were ignoring failures from unhexchar, which meant that invalid hex characters were being turned into garbage rather than the string rejected. Fix this by making unhexmem return an error code, also change the API slightly, to return the size of the returned memory, reflecting the fact that the memory is a binary blob,and not a string. For convenience, still append a trailing NULL byte to the returned memory (not included in the returned size), allowing callers to treat it as a string without doing a second copy.
2015-07-11Merge pull request #551 from poettering/fopen-temporary-noerrnoDaniel Mack
util: make sure we don't clobber errno in error path
2015-07-11basic: simplify path_is_mount_point() a bitLennart Poettering
This removes two uses of the ternary operator.
2015-07-11util: make sure we don't clobber errno in error pathLennart Poettering
2015-07-09basic/util.c fopen_temporary(): close fd if failedcee1
2015-07-08Merge pull request #500 from zonque/fileioLennart Poettering
fileio: consolidate write_string_file*()
2015-07-07Remove repeated 'the'sZbigniew Jędrzejewski-Szmek
2015-07-06tree-wide: fix write_string_file() user that should not create filesDaniel Mack
The latest consolidation cleanup of write_string_file() revealed some users of that helper which should have used write_string_file_no_create() in the past but didn't. Basically, all existing users that write to files in /sys and /proc should not expect to write to a file which is not yet existant.
2015-07-06fileio: consolidate write_string_file*()Daniel Mack
Merge write_string_file(), write_string_file_no_create() and write_string_file_atomic() into write_string_file() and provide a flags mask that allows combinations of atomic writing, newline appending and automatic file creation. Change all users accordingly.
2015-07-06fileio: add 'enforce_newline' argument to write_string_stream()Daniel Mack
Add a flag to control whether write_string_stream() should always enforce a trailing newline character in the file.
2015-07-06get_process_environ: exit early when there is nothing to readKay Sievers
2015-07-06networkd: be more defensive when writing to ipv4/ipv6 forwarding settingsLennart Poettering
1) never bother with setting the flag for loopback devices 2) if we fail to write the flag due to EROFS (which is likely to happen in containers where /proc/sys is read-only) or any other error, check if the flag already has the right value. If so, don't complain. Closes #469
2015-07-03Merge pull request #473 from ↵Lennart Poettering
richardmaw-codethink/machinectl-import-earlier-than-3-15 util: fall back in rename_noreplace when renameat2 isn't implemented
2015-07-02util: fall back in rename_noreplace when renameat2 isn't implementedRichard Maw
According to README we only need 3.7, and while it may also make sense to bump that requirement when appropriate, it's trivial to fall back when renameat2 is not available.
2015-07-01socket: Set SO_REUSEPORT before bind()Christos Trochalakis
bind() fails if it is called before setting SO_REUSEPORT and another process is already binded to the same addess. A new reuse_port option has been introduced to socket_address_listen() to set the option as part of socket initialization.
2015-06-28util: fix incorrect escape sequence in string_is_safe()Eric Biggers
2015-06-18Merge pull request #294 from teg/hashmap-debug-locking-2David Herrmann
hashmap: debug - lock access to the global hashmap list
2015-06-18hashmap: debug - lock access to the global hashmap listTom Gundersen
This may be used from multi-threaded programs (say through nss-resolve), so we must protect the global list. This is still only relevant for debug builds, so we do not try to handle cases where the locking fail, but simply assert.
2015-06-18Merge pull request #288 from phomes/cgroup-utilLennart Poettering
cgroup-util: actually use the path callback
2015-06-18Merge pull request #289 from michich/hashmap-small-cleanupLennart Poettering
a tiny hashmap cleanup
2015-06-18cgroup-util: actually use the path callbackThomas Hindoe Paaboel Andersen
We allow to specify a callback but then ignore the result. Looks like a trivial typo. From 7b3fd6313c4b07b6f822a9f979d0c22350a401d9#diff-f010fa21ba7b659b519c122743e55604
2015-06-18exit-status: add missing include for SIG* definesMichael Olbrich
Otherwise building fails with glibc 2.16. It works with glibc >= 2.17 because it is implicitly included via macro.h -> sys/param.h -> signal.h
2015-06-17util: Introduce unquote_first_word_and_warnFilipe Brandenburger
It will try to unquot_first_word, but if it runs into escaping problems it will retry it adding UNQUOTE_CUNESCAPE_RELAX to the flags. If it succeeds on the second try, it will log a warning about it. If it fails both times, it will log an error. Add test cases to confirm it behaves as expected.
2015-06-17util: New flag UNQUOTE_UNESCAPE_RELAX for unquote_first_wordFilipe Brandenburger
The new flag UNQUOTE_UNESCAPE_RELAX preserves unrecognized escape sequences verbatim in unquote_first_word, either when it's a trailing backslash (similar to UNQUOTE_RELAX, but in this case keep the extra backslash in the output) or in the middle of a sequence string. Add unit test cases to ensure the new flag works as expected and to prevent regressions from being introduced. Tested with a follow up commit converting config_parse_exec() to start using unquote_first_word, in which case this flags makes it possible to preserve unrecognized escape sequences. Relevant bug: https://bugs.freedesktop.org/show_bug.cgi?id=90794
2015-06-17util: Refactor common cunescape block in unquote_first_wordFilipe Brandenburger
2015-06-17turn kdbus support into a runtime optionKay Sievers
./configure --enable/disable-kdbus can be used to set the default behavior regarding kdbus. If no kdbus kernel support is available, dbus-dameon will be used. With --enable-kdbus, the kernel command line option "kdbus=0" can be used to disable kdbus. With --disable-kdbus, the kernel command line option "kdbus=1" is required to enable kdbus support.
2015-06-17hashmap: allow NULL key in ordered_hashmap_next()Michal Schmidt
There is no reason to require key to be non-NULL. Change test_ordered_hashmap_next() to use trivial_hash_ops in order to test NULL key too.
2015-06-17hashmap: remove _IDX_ITERATOR_NIL definitionMichal Schmidt
It is unused and rightly so. Users of the hashmap API should not care about the idx values or any other Iterator internals. _IDX_ITERATOR_FIRST in hashmap.h is an exception. It is needed for ITERATOR_FIRST.
2015-06-17Merge pull request #246 from smcv/xpg-not-xdgLennart Poettering
Stop talking about the "XDG" version of basename()
2015-06-17Stop talking about the "XDG" version of basename()Simon McVittie
XDG refers to X Desktop Group, a former name for freedesktop.org. This group is responsible for specifications like basedirs, .desktop files and icon naming, but as far as I know, it has never tried to redefine basename(). I think these references were meant to say XPG (X/Open Portability Guide), a precursor of POSIX. POSIX is better-known and less easily confused with XDG, and is how the basename(3) man page describes the libgen.h version of basename(). The other version of basename() is glibc-specific and is described in basename(3) as "the GNU version"; specifically mention that version, to disambiguate.
2015-06-17sd-event: make errors on EPOLL_CTL_DEL pseudo-fatalDavid Herrmann
If we call EPOLL_CTL_DEL, we *REALLY* expect the file-descriptor to be present in that given epoll-set. We actually track such state via our s->io.registered flag, so it better be true. Make sure if that's not true, we treat it similar to assert_return() (ie., print a loud warning).
2015-06-16tmpfiles: silently ignore failed removal of btrfs submount from non-dirTom Gundersen
This fixes: Jun 16 16:00:20 tomegun-x2402 systemd-tmpfiles[233]: rm_rf(/var/lib/machines/.#fedora.lck): Not a directory Jun 16 16:00:20 tomegun-x2402 systemd-tmpfiles[233]: rm_rf(/var/lib/machines/.#Fedora-Cloud-Base-20141203-21.x86_64.raw.lck): Not a directory
2015-06-16Merge pull request #197 from dvdhrm/hashmapMichal Schmidt
hashmap: fix iterators to not skip entries
2015-06-16signal-util: fix incorrect argument of va_startRonny Chevalier
The last argument of the function before the vargs is "old" not "how". warning: second parameter of ‘va_start’ not last named argument
2015-06-15Merge pull request #214 from poettering/signal-rework-2Lennart Poettering
everywhere: port everything to sigprocmask_many() and friends
2015-06-15everywhere: port everything to sigprocmask_many() and friendsLennart Poettering
This ports a lot of manual code over to sigprocmask_many() and friends. Also, we now consistly check for sigprocmask() failures with assert_se(), since the call cannot realistically fail unless there's a programming error. Also encloses a few sd_event_add_signal() calls with (void) when we ignore the return values for it knowingly.
2015-06-15util: when creating temporary file names, allow including extra id string in itLennart Poettering
This adds a "char *extra" parameter to tempfn_xxxxxx(), tempfn_random(), tempfn_ranomd_child(). If non-NULL this string is included in the middle of the newly created file name. This is useful for being able to distuingish the kind of temporary file when we see one. This also adds tests for the three call. For now, we don't make use of this at all, but port all users over.
2015-06-15btrfs-util: when snapshotting make sure we don't descent into subvolumes we ↵Lennart Poettering
just created We already had a safety check in place that we don't end up descending to the original subvolume again, but we also should avoid descending in the newly created one. This is particularly important if we make a snapshot below its source, like we do in "systemd-nspawn --ephemeral -D /". Closes https://bugs.freedesktop.org/show_bug.cgi?id=90803
2015-06-14hashmap: fix iterators to not skip entriesDavid Herrmann
Currently, the HASHMAP iterators stop at the first NULL entry in a hashmap. This is non-obvious and breaks users like sd-device, which legitimately store NULL values in a hashmap. Fix all the iterators by taking a pointer to the value storage, instead of returning it. The iterators now return a boolean that tells whether the end of the list was reached. Current users of HASHMAP_FOREACH() are *NOT* changed to explicitly check for NULL. If it turns out, there were users that inserted NULL into hashmaps, but didn't properly check for it during iteration, then we really want to find those and fix them.
2015-06-11build-sys: split internal basic/ library from shared/Kay Sievers
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/