summaryrefslogtreecommitdiff
path: root/src/shared
Commit message (Collapse)AuthorAge
...
* hashmap, set: remove unused functionsMichal Schmidt2014-09-15
| | | | | | | | | | | | The following hashmap_* and set_* functions/macros have never had any users in systemd's history: *_iterate_backwards *_iterate_skip *_last *_FOREACH_BACKWARDS Remove this dead code.
* hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt2014-09-15
| | | | | | | | | It is redundant to store 'hash' and 'compare' function pointers in struct Hashmap separately. The functions always comprise a pair. Store a single pointer to struct hash_ops instead. systemd keeps hundreds of hashmaps, so this saves a little bit of memory.
* exit-status: add new exit code for custom endpoint errorsDaniel Mack2014-09-08
|
* exit-status: fix URL in commentDaniel Mack2014-09-05
| | | | The LSB sites have moved, so update the URL.
* localed: remove free_and_copyZbigniew Jędrzejewski-Szmek2014-09-03
| | | | It was mostly a duplicate of free_and_strdup().
* base-file-system: always generate error messages locallyLennart Poettering2014-09-03
| | | | | | | | Functions either should generate error messages for everything they do themselves, or for nothing and let the caller do it. But they certainly shouldn't generate errors for some messages but not for others. Since the function in this case is one that generates messages on its own, it really should do that for everything, not just for some things, hence.
* base_filesystem_create: do not try to create "/root" if it existsHarald Hoyer2014-09-03
| | | | | | | | | | | The check, if the directory/file already exists is only executed, if there is a symlink target specified. In case of "/root", there is none, so it is unconditionally tried to create the directory. In case of a readonly filesystem, errno != EEXIST, but errno == EROFS, so base_filesystem_create() and switch_root does not succeed. This patch checks for existance not only in the symlink case.
* config-parser: fix mem leakThomas Hindoe Paaboel Andersen2014-08-31
|
* missing: add IFF_MULTI_QUEUETom Gundersen2014-08-31
| | | | | | This was added in 3.8, but we should building with 3.7 headers. Reported by Samuli Suominen <ssuominen@gentoo.org>.
* cgroup-util: shorten cg_path_get_sessionZbigniew Jędrzejewski-Szmek2014-08-30
|
* Fix a few more typosRuben Kerkhof2014-08-30
|
* use the switch_root function in shutdownHarald Hoyer2014-08-28
| | | | | | removes code duplication also move switch-root to shared
* macro: use unique variable names for math-macrosDavid Herrmann2014-08-28
| | | | | | | | | | | | | Similar to container_of(), we now use unique variable names for the bascic math macros MAX, MIN, CLAMP, LESS_BY. Furthermore, unit tests are added to verify they work as expected. For a rationale, see: commit fb835651aff79a1e7fc5795086c9b26e59a8e6ca Author: David Herrmann <dh.herrmann@gmail.com> Date: Fri Aug 22 14:41:37 2014 +0200 shared: make container_of() use unique variable names
* util: fix minimal race where we might miss SIGTERMs when forking off an agentLennart Poettering2014-08-27
| | | | | Before forking, block all signals, and unblock them afterwards. This way the child will have them blocked, and we won't lose them.
* util: make lookup_uid() globalDavid Herrmann2014-08-27
| | | | | This is a useful helper, make it global. It will be required for libsystemd-terminal, at minimum.
* shared: make container_of() use unique variable namesDavid Herrmann2014-08-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you stack container_of() macros, you will get warnings due to shadowing variables of the parent context. To avoid this, use unique names for variables. Two new helpers are added: UNIQ: This evaluates to a truly unique value never returned by any evaluation of this macro. It's a shortcut for __COUNTER__. UNIQ_T: Takes two arguments and concatenates them. It is a shortcut for CONCATENATE, but meant to defined typed local variables. As you usually want to use variables that you just defined, you need to reference the same unique value at least two times. However, UNIQ returns a new value on each evaluation, therefore, you have to pass the unique values into the macro like this: #define my_macro(a, b) __max_macro(UNIQ, UNIQ, (a), (b)) #define __my_macro(uniqa, uniqb, a, b) ({ typeof(a) UNIQ_T(A, uniqa) = (a); typeof(b) UNIQ_T(B, uniqb) = (b); MY_UNSAFE_MACRO(UNIQ_T(A, uniqa), UNIQ_T(B, uniqb)); }) This way, MY_UNSAFE_MACRO() can safely evaluate it's arguments multiple times as they are local variables. But you can also stack invocations to the macro my_macro() without clashing names. This is the same as if you did: #define my_macro(a, b) __max_macro(__COUNTER__, __COUNTER__, (a), (b)) #define __my_macro(prefixa, prefixb, a, b) ({ typeof(a) CONCATENATE(A, prefixa) = (a); typeof(b) CONCATENATE(B, prefixb) = (b); MY_UNSAFE_MACRO(CONCATENATE(A, prefixa), CONCATENATE(B, prefixb)); }) ...but in my opinion, the first macro is easier to write and read. This patch starts by converting container_of() to use this new helper. Other macros may follow (like MIN, MAX, CLAMP, ...).
* shared: drop UNIQUE()David Herrmann2014-08-27
| | | | | | | | | | | | | The UNIQUE() macro works fine if used in un-stacked macros. However, once you stack them like: MAX(MIN(a, b), CLAMP(MAX(c, d), e, f)) you will get warnings due to shadowing other variables. gcc uses the last line of a macro expansion as value for __LINE__, therefore, we cannot even avoid this by splitting the expressions across lines. Remove the only user of UNIQUE() so we introduce a new helper in follow-ups.
* systemctl: fix broken list-unit-files with --rootLukas Nykryn2014-08-27
|
* util: make use of newly added reset_signal_mask() call wherever appropriateLennart Poettering2014-08-26
|
* util: reset signals when we fork off agentsLennart Poettering2014-08-26
| | | | | | | | | | | If we invoke agents, we should make sure we actually can kill them again. I mean, it's probably not our job to cleanup the signals if our tools are invoked in weird contexts, but at least we should make sure, that the subprocesses we invoke and intend to control work as intended. Also see: http://lists.freedesktop.org/archives/systemd-devel/2014-August/022460.html
* util: make sure reset_all_signal_handlers() continues with all other signal ↵Lennart Poettering2014-08-26
| | | | | | | handlers when one sigaction() fails After all, we usually don't check for failures here, and it is better to do as much as we can...
* missing: add BPF_XORMichael Olbrich2014-08-26
| | | | BPF_XOR was introduced in kernel 3.7
* Revert "systemctl: fix broken list-unit-files with --root"Lennart Poettering2014-08-26
| | | | | | | This reverts commit 41a451cc2901a5deb985aea4cc8de204a22e5612. This breaks checks for masking of units file, since we invoke null_or_empty_path() on the resulting path.
* systemctl: fix broken list-unit-files with --rootLukas Nykryn2014-08-25
| | | | | | | | This patch modifies unit_file_get_list which will now return hashmap of structures where f->path is *without* root_dir prefix. This change should be ok, because current code either does not use root_dir at all or calls basename() on the f->path.
* core: add support for a configurable system-wide start-up timeoutLennart Poettering2014-08-22
| | | | | | | | | | | | | | | | | | | When this system-wide start-up timeout is hit we execute one of the failure actions already implemented for services that fail. This should not only be useful on embedded devices, but also on laptops which have the power-button reachable when the lid is closed. This devices, when in a backpack might get powered on by accident due to the easily reachable power button. We want to make sure that the system turns itself off if it starts up due this after a while. When the system manages to fully start-up logind will suspend the machine by default if the lid is closed. However, in some cases we don't even get as far as logind, and the boot hangs much earlier, for example because we ask for a LUKS password that nobody ever enters. Yeah, this is a real-life problem on my Yoga 13, which has one of those easily accessible power buttons, even if the device is closed.
* missing.h: add a cpp warning for __NR_memfd_create on MIPSDaniel Mack2014-08-22
|
* missing.h: add fake __NR_memfd_create for MIPSDaniel Mack2014-08-22
| | | | | We don't have the correct __NR_memfd_create syscall number yet, so set it to 0xffffffff for now to prevent compile time errors.
* shared: add MAXSIZE() and use it in resolvedDavid Herrmann2014-08-22
| | | | | | | | | | | The MAXSIZE() macro takes two types and returns the size of the larger one. It is much simpler to use than MAX(sizeof(A), sizeof(B)) and also avoids any compiler-extensions, unlike CONST_MAX() and MAX() (which are needed to avoid evaluating arguments more than once). This was suggested by Daniele Nicolodi <daniele@grinta.net>. Also make resolved use this macro instead of CONST_MAX(). This enhances readability quite a bit.
* install: simplify usage of _cleanup_ macrosLennart Poettering2014-08-21
|
* service,strv: introduce strv_find_startswith() and make use of itLennart Poettering2014-08-21
| | | | | | | Unlike strv_find_prefix() the new call will return a pointer to the suffix of the item we found, instead of the whole item. This is more closer inline with what startswith() does, and allows us to simplify a couple of invocations.
* util: make asynchronous_close() really work like an asynchronous version of ↵Lennart Poettering2014-08-21
| | | | | | | safe_close() Save/restore errno, like we do in safe_close(). And don't fork a thread if the parameter is already negative.
* util: simplify close_nointr() a bitLennart Poettering2014-08-21
|
* util: change return value of startswith() to non-constLennart Poettering2014-08-21
| | | | | | | | This way we can use it on non-const strings, and don't end up with a const'ified result. This is similar to libc's strstr() which also takes a const string but returns a non-const one.
* util: return after freeing all members of arrayLukas Nykryn2014-08-20
|
* systemctl: fail in the case that no unit files were foundLukas Nykryn2014-08-20
| | | | | | | | | | | | | Previously systemctl died with message -bash-4.2# systemctl --root /rawhi list-unit-files (src/systemctl/systemctl.c:868) Out of memory. in the case that no unit files were found in the --root or the directory did not exist. So lets return ENOENT in the case that --root does not exist and empty list in the case that there are no unit files.
* indentation/spurious whitespace fixesLennart Poettering2014-08-20
|
* memfd: escape the comm field we get from PR_GET_NAME, but assume everything ↵Lennart Poettering2014-08-19
| | | | else is proper UTF8
* memfd: skip utf-8 escaping if we use a name that was passed inDaniel Mack2014-08-19
| | | | | | If a name was passed in as function argument, trust it, and don't do utf-8 encoding for them. Callers are obliged to check the names themselves, and escape them in case they use anything they got from the outside world.
* memfd: reduce name escaping logic to utf-8 checksDaniel Mack2014-08-19
| | | | | | | | | | | As memfds are now created by proper kernel API, and not by our functions, we can't rely on names being escaped/unescaped according to our current logic. Thus, the only safe way is to remove the escaping and when reading names, just escape names that are not properly encoded in UTF-8. Also, remove assert(name) lines from the memfd creation functions, as we explictly allow name to be NULL.
* memfd: simplify APILennart Poettering2014-08-19
| | | | | | | | | | | Now, that the memfd stuff is not exported anymore, we can simplify a few things: Use assert() instead of assert_return(), since this is used internally only, and we should be less permissive then. No need to pass an allocated fd back by call-by-reference, we can just directly return it.
* Revert "socket: introduce SELinuxLabelViaNet option"Lennart Poettering2014-08-19
| | | | | | This reverts commit cf8bd44339b00330fdbc91041d6731ba8aba9fec. Needs more discussion on the mailing list.
* tmpfiles: add new 'r' line type to add UIDs/GIDs to the pool to allocate ↵Lennart Poettering2014-08-19
| | | | | | | | UIDs/GIDs from This way we can guarantee a limited amount of compatibility with login.defs, by generate an appopriate "r" line out of it, on package installation.
* socket: introduce SELinuxLabelViaNet optionMichal Sekletar2014-08-19
| | | | | | | | | | This makes possible to spawn service instances triggered by socket with MLS/MCS SELinux labels which are created based on information provided by connected peer. Implementation of label_get_child_label derived from xinetd. Reviewed-by: Paul Moore <pmoore@redhat.com>
* util: remove unused FOREACH_WORD_SEPARATOR_QUOTEDLennart Poettering2014-08-19
|
* sysusers: add another column to sysusers files for the home directoryLennart Poettering2014-08-19
|
* hashmap: try to use the existing 64bit hash functions for dev_t if it is 64bitLennart Poettering2014-08-19
|
* util: try to be a bit more NFS compatible when checking whether an FS is ↵Lennart Poettering2014-08-18
| | | | | | writable https://bugs.freedesktop.org/show_bug.cgi?id=81169
* memfd: internalize functions, drop sd_memfd typeDaniel Mack2014-08-18
| | | | | | Remove the sd_ prefix from internal functions and get rid of the sd_memfd type. As a memfd is now just a native file descriptor, we can get rid of our own wrapper type, and also use close() and dup() on them directly.
* memfd: use _cleanup_ if applicableDavid Herrmann2014-08-18
| | | | We now have a sd_memfd_freep helper, use it if applicable.
* memfd: map unsealed files as MAP_SHAREDDavid Herrmann2014-08-18
| | | | | | | We need to map sealed files as MAP_PRIVATE so far as the kernel treats MAP_SHARED as writable mapping (you can run mprotect(PROT_WRITE) at any time on those). However, unsealed files must be mapped as MAP_SHARED. Otherwise, we never end up writing to the real file.