summaryrefslogtreecommitdiff
path: root/src/shared
Commit message (Collapse)AuthorAge
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* tree-wide: drop spurious newlines (#8764)Lennart Poettering2018-08-24
| | | | | | | | | Double newlines (i.e. one empty lines) are great to structure code. But let's avoid triple newlines (i.e. two empty lines), quadruple newlines, quintuple newlines, …, that's just spurious whitespace. It's an easy way to drop 121 lines of code, and keeps the coding style of our sources a bit tigther.
* pager: move pager.[ch] src/shared/ → src/basic/Lennart Poettering2018-08-24
| | | | | | | | | pager.[ch] doesn't use any APIs from src/libsystemd/ or src/shared/ hence there's no reason for it to be in src/shared/, let's move it to src/basic/ instead. This enables us to use pager.[ch] APIs from other code in src/basic/, for example pager_have() and suchlike.
* polkit: normalize exit values of polkit_agent_open_if_enabled()Lennart Poettering2018-08-24
| | | | | It's strange eating up the errors here, hence don't. Let's leave this to the caller.
* bus-util: introduce bus_open_system_watch_bind_with_description()Yu Watanabe2018-08-24
| | | | | | Similar to 56fbd7187a5af44a90c258fbeb1f17114f226bb3, this adds bus_open_system_watch_bind_with_description() to set description for busses.
* shared/sleep-config: rename misnamed functionZbigniew Jędrzejewski-Szmek2018-08-24
|
* shared/sleep-config: return a custom message when not enough swap for ↵Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | hibernation $ sudo swapoff -av swapoff /dev/vda4 $ sudo systemctl hibernate Failed to hibernate system via logind: Not enough swap space for hibernation Fixes #6729.
* shared/sleep-fix: fix check if s-then-h is possibleZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | can_sleep() returns 0 if the operation is impossible, but the code assumed that negative is returned in that case, in effect reporting s2h was possible even if hibernation or suspend were not possible.
* shared/sleep-config: get rid of explicit allocation size calculationZbigniew Jędrzejewski-Szmek2018-08-24
|
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* sleep: Add support for setting a disk offset when hibernatingMario Limonciello2018-08-24
| | | | | | | | | | | The Linux kernel is adding support for configuring the offset into a disk. This allows swapfiles to be more usable as users will no longer need to set the offset on their kernel command line. Use this API in systemd when hibernating as well. Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-08-24
|
* bus-util: fix a meaningless assertionYu Watanabe2018-08-24
|
* Rename suspend-to-hibernate to suspend-then-hibernateMario Limonciello2018-08-24
| | | | | Per some discussion with Gnome folks, they would prefer this name as it's more descriptive of what's happening.
* bus-util: add flags for bus_map_all_properties() (#8546)Yu Watanabe2018-08-24
| | | | | | | | | | This adds flags BUS_MAP_STRDUP and BUS_MAP_BOOLEAN_AS_BOOL. If BUS_MAP_STRDUP is set, then each "s" message is duplicated. If BUS_MAP_BOOLEAN_AS_BOOL is set, then each "b" message is written to a bool pointer. Follow-up for #8488. See https://github.com/systemd/systemd/pull/8488#discussion_r175816270.
* tree-wide: tabs suck (#8527)Lennart Poettering2018-08-24
|
* conf-parse: small prettificationLennart Poettering2018-08-24
| | | | | | Let's use first_word() instead of startswith(), it's more explanatory and a bit more correct. Also, let's use the return value instead of adding +9 when looking for the second part of the directive.
* conf-parser: let's explicitly deprecate .include in unit filesLennart Poettering2018-08-24
| | | | | | | | | | | | .include lines are already deprecated somewhat, and for example explicitly not mentioned in the documentation for this reason. Let's get one step further and generatea warning when we encounter them (but still process them). Why are they deprecated? Because they are semantically awful — they complicate stat() based mtime checks for configuration files and they allow arbitrary loops we currently have zero protection against and really shouldn't have to have.
* sleep-config: replace USE() macro with TAKE_PTR() usageLennart Poettering2018-08-24
| | | | | let's use the new generic macor instead of the locally defined, specific one.
* macro: introduce TAKE_PTR() macroLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* shared/conf-parser: fix outdated commentZbigniew Jędrzejewski-Szmek2018-08-24
|
* conf-parser: accept trailing backslash at the end of the file (#8941)Filipe Brandenburger2018-06-28
| | | | | | | | | | | | This makes it behave the same whether there is a blank line or not at the end of the file. This is also consistent with the behavior of the shell on a shell script that ends on a trailing backslash at the last line. Added tests to test_config_parse(), which only pass if the corresponding change to config_parse() is included. (cherry picked from commit 4f29e0db127dce9e1a28af4d7bf88c124ba257b7)
* basic/macros: rename noreturn into _noreturn_ (#8456)Franck Bui2018-06-28
| | | | | | | | | | | | | | | "noreturn" is reserved and can be used in other header files we include: [ 16s] In file included from /usr/include/gcrypt.h:30:0, [ 16s] from ../src/journal/journal-file.h:26, [ 16s] from ../src/journal/journal-vacuum.c:31: [ 16s] /usr/include/gpg-error.h:1544:46: error: expected ‘,’ or ‘;’ before ‘)’ token [ 16s] void gpgrt_log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2); Here we include grcrypt.h (which in turns include gpg-error.h) *after* we "noreturn" was defined in macro.h. (cherry picked from commit 848e863acc51ecfb0f3955c498874588201d9130)
* Prep v238: Fix elogind_daemonize(), it failed due to some misunderstandings ↵Sven Eden2018-06-08
| | | | | | on my side. (cherry picked from commit 1c9629692145891f10a36227749470d87979dd0b)
* Prep v238: Uncomment now needed headers and unmask now needed functions in ↵Sven Eden2018-06-05
| | | | src/shared (5/6)
* Prep v238: Fixed meson.build files in src/shared and src/testSven Eden2018-06-04
|
* pid1: do not initialize join_controllers by defaultZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | We're moving towards unified cgroup hierarchy where this is not necessary. This makes main.c a bit simpler.
* Move config_parse_join_controllers to shared, add testZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | config_parse_join_controllers would free the destination argument on failure, which is contrary to our normal style, where failed parsing has no effect. Moving it to shared also allows a test to be added.
* shared/conf-parser: define a macro for the repeating argument setZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | The arguments have to be indentical everywhere, so let's use a macro to make things more readable. But only in the headers, in the .c files let's keep them verbose so that it's easy to see the argument list.
* bus-util: fix format of NextElapseUSecRealtime= and LastTriggerUSec=Yu Watanabe2018-05-30
| | | | | | | | | | | | | Before this, `systemctl show` for calendar type timer unit outputs something like below. ``` NextElapseUSecRealtime=48y 3w 3d 15h NextElapseUSecMonotonic=0 LastTriggerUSec=48y 3w 3d 3h 41min 44.093095s LastTriggerUSecMonotonic=0 ``` As both NextElapseUSecRealtime= and LastTriggerUSec= are not timespan but timestamp, this makes format these values by `format_timestamp()`.
* coccinelle: O_NDELAY → O_NONBLOCKLennart Poettering2018-05-30
| | | | | | Apparently O_NONBLOCK is the modern name used in most documentation and for most cases in our sources. Let's hence replace the old alias O_NDELAY and stick to O_NONBLOCK everywhere.
* bus-util: add bool property setterJan Klötzke2018-05-30
|
* log: minimize includes in log.hLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | log.h really should only include the bare minimum of other headers, as it is really pulled into pretty much everything else and already in itself one of the most basic pieces of code we have. Let's hence drop inclusion of: 1. sd-id128.h because it's entirely unneeded in current log.h 2. errno.h, dito. 3. sys/signalfd.h which we can replace by a simple struct forward declaration 4. process-util.h which was needed for getpid_cached() which we now hide in a funciton log_emergency_level() instead, which nicely abstracts the details away. 5. sys/socket.h which was needed for struct iovec, but a simple struct forward declaration suffices for that too. Ultimately this actually makes our source tree larger (since users of the functionality above must now include it themselves, log.h won't do that for them), but I think it helps to untangle our web of includes a tiny bit. (Background: I'd like to isolate the generic bits of src/basic/ enough so that we can do a git submodule import into casync for it)
* networkd: add support for wireguard interface typeJörg Thalheim2018-05-30
| | | | More information may be found at wireguard.com.
* networkd: add support for wireguard interface typeJörg Thalheim2018-05-30
| | | | More information may be found at wireguard.com.
* networkd,resolved: make use of watch_bind feature to connect to the busLennart Poettering2018-05-30
| | | | | | | | | | The changes both networkd and resolved to make use of the watch_bind feature of sd-bus to connect to the system bus. This way, both daemons can be started during early boot, and automatically and instantly connect to the system bus as it becomes available. This replaces prior code that used a time-based retry logic to connect to the bus.
* tree-wide: install matches asynchronouslyLennart Poettering2018-05-30
| | | | | | | | | Let's remove a number of synchronization points from our service startups: let's drop synchronous match installation, and let's opt for asynchronous instead. Also, let's use sd_bus_match_signal() instead of sd_bus_add_match() where we can.
* sd-bus: port one use of SO_PEERCRED by getpeercred()Lennart Poettering2018-05-30
|
* pager: let's move static variables up, to the rest of themLennart Poettering2018-05-30
| | | | | let's keep static variables together, and before the function definitions.
* pager,agent: insist that we are called from the main threadLennart Poettering2018-05-30
| | | | | | We maintain static process-wide variables in these subsystems without locking, hence let's refuse operation unless we are called from the main thread (which we do anyway) just as a safety precaution.
* tree-wide: make use of wait_for_terminate_and_check() at various placesLennart Poettering2018-05-30
| | | | | | Using wait_for_terminate_and_check() instead of wait_for_terminate() let's us simplify, shorten and unify the return value checking and logging of waitid(). Hence, let's use it all over the place.
* process-util: add another fork_safe() flag for enabling LOG_ERR/LOG_WARN loggingLennart Poettering2018-05-30
|
* nsflags: add namespace_flag_to_string_many_with_check()Yu Watanabe2018-05-30
| | | | The function will be used in later commits.
* meson: use a convenience lib for journal user sourcesZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | Instead of compiling those files twice, once for libsystemd and once for libshared, compile once as a static archive and then link into both. This reduce the meson target for man=no compile to 1291.
* meson: link libsystemd_static in libshared instead of recompilingZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | This is similar to the great-grandpa commit. This time the number of meson targets compilation without man is reduced from 1347 to 1302.
* Move gcrypt-util to basic/Zbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | | | | We were including gcrypt-util.[ch] by hand in the few places where it was used. Create a convenience library to avoid compiling the same files multiple times. v2: - use a separate static library instead of mergin into libbasic
* meson: link libbasic and libshared_static into libsharedZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | | | | | | | | | gcrypt_util_sources had to be moved because otherwise they appeared twice in libshared.so halfproducts, causing an error. -fvisibility=default is added to libbasic, libshared_static so that the symbols appear properly in the exported symbol list in libshared. The advantage is that files are not compiled twice. When configured with -Dman=false, the ninja target list is reduced from 1588 to 1347 targets. The difference in compilation time is small (<10%). I think this is because of -O0 and ccache and multiple cores, and in different settings the compilation time could be reduced. The main advantage is that errors and warnings are not reported twice.
* meson: rename libsystemd_internal to libsystem_staticZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | | | | We already use the "_static" suffix for libshared_static ("shared" is the name of the library, "static" is the format) and other libs, so let's rename for consistency. Also change libsystemd_static_sources to libsystemd_sources, since the same list is used for both and shorter is better.
* agents: use kill_and_sigcont() where appropriateLennart Poettering2018-05-30
|
* process-util: move fork_agent() to process-util.[ch]Lennart Poettering2018-05-30
| | | | | | It's a relatively small wrapper around safe_fork() now, hence let's move it over, and make its signature even more alike. Also, set a different process name for the polkit and askpw agents.