summaryrefslogtreecommitdiff
path: root/src/shared/util.c
AgeCommit message (Collapse)Author
2014-10-09util: avoid double close of fdThomas Hindoe Paaboel Andersen
We could end with a double close if we close the fd loop and flush_fd fails. That would make us goto fail and there we close the fd once again. This patch sets the fd to the return value for safe_close: -1 A fd with negative value will be ignored by the next call to safe_close. CID#996223
2014-10-01shared: util - use nicer idiom to silence CoverityZbigniew Jędrzejewski-Szmek
Change the other spot too.
2014-09-30shared: util - use nicer idiom to silence CoverityTom Gundersen
Suggested by Zbigniew.
2014-09-29util: silence coverityTom Gundersen
Make it clear in the code that ignoring a failed safe_ato?() is intentional.
2014-09-16util: remove a unnecessary checkThomas Hindoe Paaboel Andersen
We only break out of the previous loop if fd >= 0 so there is no use in checking it again. Found by coverity. Fixes: CID#1237577
2014-09-15hashmap: introduce hash_ops to make struct Hashmap smallerMichal Schmidt
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.
2014-09-03localed: remove free_and_copyZbigniew Jędrzejewski-Szmek
It was mostly a duplicate of free_and_strdup().
2014-08-27util: fix minimal race where we might miss SIGTERMs when forking off an agentLennart Poettering
Before forking, block all signals, and unblock them afterwards. This way the child will have them blocked, and we won't lose them.
2014-08-27util: make lookup_uid() globalDavid Herrmann
This is a useful helper, make it global. It will be required for libsystemd-terminal, at minimum.
2014-08-26util: make use of newly added reset_signal_mask() call wherever appropriateLennart Poettering
2014-08-26util: reset signals when we fork off agentsLennart Poettering
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
2014-08-26util: make sure reset_all_signal_handlers() continues with all other signal ↵Lennart Poettering
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...
2014-08-22core: add support for a configurable system-wide start-up timeoutLennart Poettering
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.
2014-08-21util: simplify close_nointr() a bitLennart Poettering
2014-08-20util: return after freeing all members of arrayLukas Nykryn
2014-08-20indentation/spurious whitespace fixesLennart Poettering
2014-08-19sysusers: add another column to sysusers files for the home directoryLennart Poettering
2014-08-15main: minor code modernization for initializing the consoleLennart Poettering
2014-08-15util: make is_localhost() check for 'localdomain' too, so that we can use it ↵Lennart Poettering
for both validating domains and host names
2014-08-15core: Refuse mount on symlinkTimofey Titovets
2014-08-14core: move status line ellipsation to 50% of the lineLennart Poettering
http://lists.freedesktop.org/archives/systemd-devel/2014-July/021591.html
2014-08-11fix a couple of more lazy "return -1"Lennart Poettering
Fix should strictly follow the rule to return negative errno-style error codes from functions, hence let's fix more "return -1"-style lazinesses.
2014-08-11util: avoid considering dpkg temporary files relevant for anythingLennart Poettering
https://bugs.freedesktop.org/show_bug.cgi?id=82453
2014-08-01resolved: read the system /etc/resolv.conf unless we wrote it ourselvesLennart Poettering
This way we integrate nicely with foreign network management stacks, such as NM.
2014-07-31core/load-fragment.c: correct argument sign and split up long linesZbigniew Jędrzejewski-Szmek
With everything on one line they are just harder to read.
2014-07-31Properly report invalid quoted stringsZbigniew Jędrzejewski-Szmek
$ systemd-analyze verify trailing-g.service [./trailing-g.service:2] Trailing garbage, ignoring. trailing-g.service lacks ExecStart setting. Refusing. Error: org.freedesktop.systemd1.LoadFailed: Unit trailing-g.service failed to load: Invalid argument. Failed to create trailing-g.service/start: Invalid argument
2014-07-31Reject invalid quoted stringsZbigniew Jędrzejewski-Szmek
String which ended in an unfinished quote were accepted, potentially with bad memory accesses. Reject anything which ends in a unfished quote, or contains non-whitespace characters right after the closing quote. _FOREACH_WORD now returns the invalid character in *state. But this return value is not checked anywhere yet. Also, make 'word' and 'state' variables const pointers, and rename 'w' to 'word' in various places. Things are easier to read if the same name is used consistently. mbiebl_> am I correct that something like this doesn't work mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-passwd "Unlock EncFS"' mbiebl_> systemd seems to strip of the quotes mbiebl_> systemctl status shows mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-password Unlock EncFS $RootDir $MountPoint mbiebl_> which is pretty weird
2014-07-29resolved: when resolving an address PTR record via llmnr, make a tcp ↵Lennart Poettering
connection by default
2014-07-29time-util: add and use USEC/NSEC_INFINIYKay Sievers
2014-07-27parse_boolean: require exact matchesAnsgar Burchardt
Require exact matches in all cases instead of treating strings starting with 't' ('f') as true (false). This is required for config_parse_protect_system to parse ProtectSystem=full correctly: it uses parse_boolean and only tries a more specific parsing function if that did not return a valid result. Thus "full" was treated as "false" before.
2014-07-16Be more careful when checking for empty filesZbigniew Jędrzejewski-Szmek
If we want to avoid reading a totally empty file, it seems better to check after we have opened the file, not before.
2014-07-11util: fix has cc check and add testZbigniew Jędrzejewski-Szmek
2014-07-07firstboot: get rid of firstboot generator again, introduce ↵Lennart Poettering
ConditionFirstBoot= instead As Zbigniew pointed out a new ConditionFirstBoot= appears like the nicer way to hook in systemd-firstboot.service on first boots (those with /etc unpopulated), so let's do this, and get rid of the generator again.
2014-07-07firstboot: follow lock protocol when changing /etc/shadowLennart Poettering
2014-07-07firstboot: add new component to query basic system settings on first boot, ↵Lennart Poettering
or when creating OS images offline A new tool "systemd-firstboot" can be used either interactively on boot, where it will query basic locale, timezone, hostname, root password information and set it. Or it can be used non-interactively from the command line when prepareing disk images for booting. When used non-inertactively the tool can either copy settings from the host, or take settings on the command line. $ systemd-firstboot --root=/path/to/my/new/root --copy-locale --copy-root-password --hostname=waldi The tool will be automatically invoked (interactively) now on first boot if /etc is found unpopulated. This also creates the infrastructure for generators to be notified via an environment variable whether they are running on the first boot, or not.
2014-07-07util: don't consider tabs special in string_has_cc() anymoreLennart Poettering
Instead, take a list of exceptions to our usual CC check
2014-07-07util: consider 0x7F a control chracter (which it is: DEL)Lennart Poettering
Let's better be safe than sorry.
2014-07-03sd-bus: support connecting to remote hosts, directly into containersLennart Poettering
systemctl -H root@foobar:waldi will now show a list of services running on container "waldi" on host "foobar", using "root" for authenticating at "foobar". Since entereing a container requires priviliges, this will only work correctly for root logins.
2014-07-02util: when unescaping strings, don't allow smuggling in of additional NUL bytesLennart Poettering
Better safe than sorry.
2014-07-02util: generalize is_localhost() and use it everywhere where applicableLennart Poettering
2014-07-02path: add new "systemd-path" utility for querying paths described in ↵Lennart Poettering
file-hierarchy(7) This new tool is based on "sd-path", a new (so far unexported) API for libsystemd, that can hopefully grow into a workable API covering /opt and more one day.
2014-07-01parse_uid: return -ENXIO for -1 uidsKay Sievers
2014-06-30shared/util.c:wait_for_terminate_and_warn(): Add a comment on the return valuesLuke Shumaker
2014-06-30util: fix commentLennart Poettering
2014-06-29util: refuse considering UID 0xFFFF and 0xFFFFFFFF validLennart Poettering
2014-06-24use more _cleanup_ macroRonny Chevalier
2014-06-20util: treat fuse.sshfs as a network filesystemZbigniew Jędrzejewski-Szmek
https://bugs.freedesktop.org/show_bug.cgi?id=73727
2014-06-20util: do not strip /dev prefix twiceZbigniew Jędrzejewski-Szmek
2014-06-20shared: fix search_and_fopen with alternate rootsMichael Marineau
Update for the current behavior of path_strv_resolve which now returns paths relative to the given root, not the full absolute paths.
2014-06-20shared: rename path_strv_canonicalize_absolute functionsMichael Marineau
Since 12ed81d9 path_strv_canonicalize_absolute leaves the search list relative to the given root directory instead of resolving paths to their true location as the name implies. To better reflect this behavior rename to the less strongly worded path_strv_resolve.