summaryrefslogtreecommitdiff
path: root/src/shared/sleep-config.c
Commit message (Collapse)AuthorAge
* tree-wide: rename config_parse_many to …_nulstrZbigniew Jędrzejewski-Szmek2017-07-05
| | | | In preparation for adding a version which takes a strv.
* Prep v231: Move can_sleep() back to src/shared/sleep-config.cSven Eden2017-06-16
|
* Prep v229: Consolidate system sleep functions.Sven Eden2017-05-22
| | | | | | Move sleep relevant functions from shared/sleep-config.* and login/logind-action.* into login/logind-sleep.* - they aren't used outside of elogind anyway.
* Prep v229: elogind should honor its Sleep configuration.Sven Eden2017-05-19
|
* Prep v229: Add missing fixes from upstream [5/6] src/sharedSven Eden2017-05-17
|
* Prep v228: Add remaining updates from upstream (3/3)Sven Eden2017-04-26
| | | | | Apply remaining fixes and the performed move of utility functions into their own foo-util.[hc] files on the rest of elogind.
* [5/5] Apply missing fixes from upstreamSven Eden2017-03-29
|
* Assorted format fixesZbigniew Jędrzejewski-Szmek2015-01-22
| | | | | Types used for pids and uids in various interfaces are unpredictable. Too bad.
* systemd-sleep: Support sleep.conf.d directories in the usual search pathsJosh Triplett2014-11-29
|
* treewide: more log_*_errno() conversions, multiline callsMichal Schmidt2014-11-28
| | | | | | | | | | | | Basically: find . -name '*.[ch]' | while read f; do perl -i.mmm -e \ 'local $/; local $_=<>; s/log_(debug|info|notice|warning|error|emergency)\("([^"]*)%s"([^;]*),\s*strerror\(-?([->a-zA-Z_]+)\)\);/log_\1_errno(\4, "\2%m"\3);/gms;print;' \ $f; done Plus manual indentation fixups.
* treewide: no need to negate errno for log_*_errno()Michal Schmidt2014-11-28
| | | | It corrrectly handles both positive and negative errno values.
* treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt2014-11-28
| | | | | | | | | | | | | As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
* Reject invalid quoted stringsZbigniew Jędrzejewski-Szmek2014-07-31
| | | | | | | | | | | | | | | | | | | | | | 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
* Let config_parse open file where applicableZbigniew Jędrzejewski-Szmek2014-07-16
| | | | | | | | Special care is needed so that we get an error message if the file failed to parse, but not when it is missing. To avoid duplicating the same error check in every caller, add an additional 'warn' boolean to tell config_parse whether a message should be issued. This makes things both shorter and more robust wrt. to error reporting.
* Constify ConfigTableItem tablesZbigniew Jędrzejewski-Szmek2014-07-15
|
* consistently order cleanup attribute before typeThomas Hindoe Paaboel Andersen2014-06-22
|
* coredump: optionally store coredumps on disk, not in the journalLennart Poettering2014-06-19
| | | | | | | | Introduce a new configuration file /etc/systemd/coredump.conf to configure when to place coredumps in the journal and when on disk. Since the coredumps are quite large, default to storing them only on disk.
* make gcc shut upLennart Poettering2014-02-19
| | | | | | | If -flto is used then gcc will generate a lot more warnings than before, among them a number of use-without-initialization warnings. Most of them without are false positives, but let's make them go away, because it doesn't really matter.
* everywhere: always use O_CLOEXEC where it makes senseLennart Poettering2014-02-13
|
* sleep-config: fix double freeZbigniew Jędrzejewski-Szmek2013-12-31
| | | | | | | | | Before 34a3baa4d 'sleep-config: Dereference pointer before check for NULL' oom conditions would not be detected properly. After that commit, a double free was performed. Rework the whole function to be easier to understand, and also replace strv_split_nulstr with strv_new, since we know the strings anyway.
* sleep-config: Dereference pointer before check for NULLStefan Beller2013-12-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug pointed out by http://css.csail.mit.edu/stack/ (Optimization-unstable code) It is a similar fix as f146f5e159 (2013-12-30, core: Forgot to dereference pointer when checking for NULL) To explain this bug consider the following similar, but simpler code: if (!p) free(*p) Assume the if condition evaluates to true, then we will access *p, which means the compiler can assume p is a valid pointer, so it could dereference p and use the value *p. Assuming p as a valid pointer, !p will be false. But initally we assumed the condition evaluates to true. By this reasoning the optimizing compiler can deduce, we have dead code. ("The if will never be taken, as *p must be valid, because otherwise accessing *p inside the if would segfault") This led to an error message of the static code checker, so I checked the code in question. As we access *modes and *states before the check in the changed line of this patch, I assume the line to be wrong and we actually wanted to check for *modes and *states being both non null.
* sleep-config: fix useless check for swapfile typeDave Reisner2013-12-24
| | | | | | | | | Since 0c6f1f4ea49 the check was useless, because the kernel will ever only write "partition" or "file" there. OTOH, it is possible that "\\040(deleted)" (escaped " (deleted)") will be added for removed files. This should not happen, so add a warning to detect those cases.
* Make hibernation test work for swap filesJan Janssen2013-11-07
| | | | | | Suspend to disk works for swap files too (even if it is located on an ecrypted file system): https://www.kernel.org/doc/Documentation/power/swsusp-and-swap-files.txt
* Use first partition in /proc/swaps for hibernation testZbigniew Jędrzejewski-Szmek2013-09-17
| | | | | | It seems that the kernel uses the first configured partition for hibernation. If it is too full, hibernation will fail. Test that directly.
* Assume that /proc/meminfo can be missingZbigniew Jędrzejewski-Szmek2013-09-16
| | | | | | | Travis tests are failing, probably because /proc/meminfo is not available in the test environment. The same might be true in some virtualized systems, so just treat missing /proc/meminfo as a sign that hibernation is not possible.
* Advertise hibernation only if there's enough free swapZbigniew Jędrzejewski-Szmek2013-09-13
| | | | | | | | | | | | | | | | | | | Condition that is checked is taken from upower: active(anon) < free swap * 0.98 This is really stupid, because the kernel knows the situation better, e.g. there could be two swap files, and then hibernation would be impossible despite passing this check, or the kernel could start supporting compressed swap and/or compressed hibernation images, and then this this check would be too stringent. Nevertheless, until we have something better, this should at least return a true negative if there's no swap. Logging of capabilities in the journal is changed to not strip leading zeros. I consider this more readable anyway. http://cgit.freedesktop.org/upower/tree/src/up-daemon.c#n613 https://bugzilla.redhat.com/show_bug.cgi?id=1007059
* systemd-sleep: it is not an error if the config file is missingZbigniew Jędrzejewski-Szmek2013-05-07
|
* systemd-sleep: add support for freeze and standbyZbigniew Jędrzejewski-Szmek2013-05-06
A new config file /etc/systemd/sleep.conf is added. It is parsed by systemd-sleep and logind. The strings written to /sys/power/disk and /sys/power/state can be configured. This allows people to use different modes of suspend on systems with broken or special hardware. Configuration is shared between systemd-sleep and logind to enable logind to answer the question "can the system be put to sleep" as correctly as possible without actually invoking the action. If the user configured systemd-sleep to only use 'freeze', but current kernel does not support it, logind will properly report that the system cannot be put to sleep. https://bugs.freedesktop.org/show_bug.cgi?id=57793 https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=7e73c5ae6e7991a6c01f6d096ff8afaef4458c36 http://lists.freedesktop.org/archives/systemd-devel/2013-February/009238.html SYSTEM_CONFIG_FILE and USER_CONFIG_FILE defines were removed since they were used in only a few places and with the addition of /etc/systemd/sleep.conf it becomes easier to just append the name of each file to the dir name.