summaryrefslogtreecommitdiff
path: root/src/shared
Commit message (Collapse)AuthorAge
* timedatectl: add 'show' command to display machine-readable outputYu Watanabe2018-08-24
| | | | Closes #9249.
* tree-wide: drop !! casts to booleansZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | They are not needed, because anything that is non-zero is converted to true. C11: > 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the > value compares equal to 0; otherwise, the result is 1. https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c
* conf-parser: simplify conf_parse_path()Yu Watanabe2018-08-24
| | | | Follow-up for 97651797e83d0548aef9f808657d3518d89e5aee.
* tree-wide: unify how we define bit mak enumsLennart Poettering2018-08-24
| | | | | | Let's always write "1 << 0", "1 << 1" and so on, except where we need more than 31 flag bits, where we write "UINT64(1) << 0", and so on to force 64bit values.
* conf-parser: add config_parse_permille()Marc Kleine-Budde2018-08-24
|
* tree-wide: fix a number of log calls that use %m but have no errno setLennart Poettering2018-08-24
| | | | | | | | This is mostly fall-out from d1a1f0aaf0d2f08c60d1e0d32e646439d99f58dc, however some cases are older bugs. There might be more issues lurking, this was a simple grep for "%m" across the tree, with all lines removed that mention "errno" at all.
* udev: add helper udev_device_new_from_stat_rdev()Lennart Poettering2018-08-24
| | | | | | This is a simple wrapper around udev_device_new_from_devnum(), and uses the data from a struct stat's .st_rdev field to derive the udev_device object.
* shared/bus-util: use the new cleanup functionality to avoid a memleakZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the async callbacks didn't get a chance to finish properly, we'd leak memory. The output from test-bus-util with additional log line in the callbacks to show what is happening: $ build/test-bus-util /* test_name_async (0) */ Bus test-bus: changing state UNSET → OPENING Bus test-bus: changing state OPENING → AUTHENTICATING Bus test-bus: changing state AUTHENTICATING → HELLO Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RequestName cookie=2 reply_cookie=0 signature=su error-name=n/a error-message=n/a Got message type=method_return sender=org.freedesktop.DBus destination=:1.732 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1 signature=s error-name=n/a error-message=n/a Bus test-bus: changing state HELLO → RUNNING Bus test-bus: changing state RUNNING → CLOSED request_name_destroy_callback n_ref=1 /* test_name_async (20) */ Bus test-bus: changing state UNSET → OPENING Bus test-bus: changing state OPENING → AUTHENTICATING Bus test-bus: changing state AUTHENTICATING → HELLO stage 0: sd_bus_process returned 1 Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RequestName cookie=2 reply_cookie=0 signature=su error-name=n/a error-message=n/a stage 1: sd_bus_process returned 1 Got message type=method_return sender=org.freedesktop.DBus destination=:1.733 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=1 signature=s error-name=n/a error-message=n/a Bus test-bus: changing state HELLO → RUNNING stage 2: sd_bus_process returned 1 Got message type=signal sender=org.freedesktop.DBus.Local destination=n/a path=/org/freedesktop/DBus/Local interface=org.freedesktop.DBus.Local member=Connected cookie=4294967295 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a stage 3: sd_bus_process returned 1 Got message type=signal sender=org.freedesktop.DBus destination=:1.733 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=4294967295 reply_cookie=0 signature=s error-name=n/a error-message=n/a stage 4: sd_bus_process returned 1 Got message type=error sender=org.freedesktop.DBus destination=:1.733 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=2 signature=s error-name=org.freedesktop.DBus.Error.AccessDenied error-message=Request to own name refused by policy Unable to request name, will retry after reloading DBus configuration: Request to own name refused by policy Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=ReloadConfig cookie=3 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a request_name_destroy_callback n_ref=2 stage 5: sd_bus_process returned 1 Got message type=method_return sender=org.freedesktop.DBus destination=:1.733 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=3 signature= error-name=n/a error-message=n/a Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RequestName cookie=4 reply_cookie=0 signature=su error-name=n/a error-message=n/a request_name_destroy_callback n_ref=1 stage 6: sd_bus_process returned 1 Got message type=error sender=org.freedesktop.DBus destination=:1.733 path=n/a interface=n/a member=n/a cookie=4294967295 reply_cookie=4 signature=s error-name=org.freedesktop.DBus.Error.AccessDenied error-message=Request to own name refused by policy Unable to request name, failing connection: Request to own name refused by policy Bus test-bus: changing state RUNNING → CLOSING stage 7: sd_bus_process returned 1 Bus test-bus: changing state CLOSING → CLOSED stage 8: sd_bus_process returned 1 stage 9: sd_bus_process returned -104 Processing failed: Connection reset by peer
* bus-util: avoid unneeded initalization to zeroZbigniew Jędrzejewski-Szmek2018-08-24
|
* conf-parser: fix memleak (#9177)Yu Watanabe2018-08-24
| | | | | | Fixes CID#1391437. Closes #9180.
* conf-parser: remove redundant utf8-validity checkYu Watanabe2018-08-24
|
* conf-parse: use free_and_replace()Yu Watanabe2018-08-24
| | | | Also removes unnecessary empty lines.
* conf-parser: reject utf8-invalid linesYu Watanabe2018-08-24
|
* conf-parse: use path_simplify_and_warn() in config_parse_path()Yu Watanabe2018-08-24
|
* path-util: introduce path_simplify()Yu Watanabe2018-08-24
| | | | | | | | The function is similar to path_kill_slashes() but also removes initial './', trailing '/.', and '/./' in the path. When the second argument of path_simplify() is false, then it behaves as the same as path_kill_slashes(). Hence, this also replaces path_kill_slashes() with path_simplify().
* Use const char* for timestamp strings which we don't plan to modifyZbigniew Jędrzejewski-Szmek2018-08-24
| | | | Makes the intent a bit clearer.
* conf-parser: introduce DEFINE_CONFIG_PARSE*() macrosYu Watanabe2018-08-24
| | | | | | | | This introduces several macros for defining config parsers. Also this fixes errno in DEFINE_CONFIG_PARSE_ENUM() and _ENUMV() and makes the log level lower when a duplicated item is specified to the settings parsed by the function defined by DEFINE_CONFIG_PARSE_ENUMV().
* tree-wide: fix typo in comments and NEWSYu Watanabe2018-08-24
|
* conf-parser: add a bit more whitespaceLennart Poettering2018-08-24
| | | | | | | | We usually seperate case statements within a switch from each other by empty lines. We also often add an empty line after multi-line function prototypes, let's do so here too Also, no trailing ; after }...
* journalctl: add with-unit modeLuca Boccassi2018-08-24
| | | | | | | | | | When dealing with a large number of template instances, for example when launching daemons per VRF, it is hard for operators to correlate log lines to arguments. Add a new with-unit mode which, if available, prefixes unit and user unit names when displaying its log messages instead of the syslog identifier. It will also use the full timestamp with timezones, like the short-full mode.
* machined: move bus_reply_pair_array() into generic utilitiesLennart Poettering2018-08-24
| | | | This way, we can reuse it in portabled.
* fileio: accept FILE* in addition to path in parse_env_file()Lennart Poettering2018-08-24
| | | | | | | Most our other parsing functions do this, let's do this here too, internally we accept that anyway. Also, the closely related load_env_file() and load_env_file_pairs() also do this, so let's be systematic.
* load-fragment: allow to specify RestrictNamespaces= multiple timesYu Watanabe2018-08-24
| | | | | If multiple RestrictNamespaces= settings are set, then merge the settings. This also drops supporting "~yes" and "~no".
* nsflsgs: drop namespace_flag_{from,to}_string()Yu Watanabe2018-08-24
| | | | | | This also drops namespace_flag_to_string_many_with_check(), and renames namespace_flag_{from,to}_string_many() to namespace_flags_{from,to}_string().
* nsflags: drop namespace_flag_to_string_many_with_check()Yu Watanabe2018-08-24
| | | | | We always ignore the unused bits. So, it is not necessary to check them.
* timesync,shared: move logic requesting bus name to sharedYu Watanabe2018-08-24
| | | | | Preparation for setting DynamicUser= to other services which request bus names.
* conf-parser: make use of free_and_replace() at one more placeLennart Poettering2018-08-24
|
* config-parser: introduce new CONFIG_PARSER_PROTOTYPE() macroLennart Poettering2018-08-24
| | | | | | | | | | | | | | This builds on the previous GENERIC_PARSER_ARGS macro work. I think in general it is a better idea to declare macros that generate full C statements instead of just parts of them, hence, let's introduce CONFIG_PARSER_PROTOTYPE() which defines a full C function prototype, instead of the pre-existing way of defining the C function prototype manually, but then using GENERIC_PARSER_ARGS to define its arguments. This doesn't drop GENERIC_PARSER_ARGS though, but renames it to CONFIG_PARSER_ARGUMENTS, and changes the ConfigParserCallback function type to use it. The new name follows more closely how the other symbols in the header are named.
* bus-util: add more macros for defining functions of getting dbus propertiesYu Watanabe2018-08-24
|
* conf-parser: shorten config_parse_string() by using free_and_strdup() and ↵Lennart Poettering2018-08-24
| | | | empty_to_null()
* core: move config_parse_limit() to the generic conf-parser.[ch]Lennart Poettering2018-08-24
| | | | | | | That way we can use it in nspawn. Also, while we are at it, let's rename the call config_parse_rlimit(), i.e. insert the "r", to clarify what kind of limit this is about.
* rlimit-util: rework rlimit_{from|to}_string() to work without "Limit" prefixLennart Poettering2018-08-24
| | | | | let's make the call more generic, so that we can also easily use it for parsing "RLIMIT_xyz" style constants.
* bus-util: add several macros for defining functions of getting dbus propertiesYu Watanabe2018-08-24
|
* shared/sleep-config: fix memleak of strv, add testZbigniew Jędrzejewski-Szmek2018-08-24
| | | | CID #1390921, #1390951.
* conf-parser: accept trailing backslash at the end of the file (#8941)Filipe Brandenburger2018-08-24
| | | | | | | | | | 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.
* meson: recompile all sources for install_libudev_static and ↵Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | install_libsystemd_static This means that when those targets are built, all the sources are built again, instead of reusing the work done to create libbasic.a and other convenience static libraries. It would be nice to not do this, but there seems to be no support in our toolchain for joining multiple static libraries into one. When linking a static library, any -l arguments are simply ignored by ar/gcc-ar, and .a libraries given as positional arguments are copied verbatim into the archive so they objects in them cannot be accessed. https://stackoverflow.com/questions/2157629/linking-static-libraries-to-other-static-libraries suggests either unzipping all the archives and putting them back togather, or using a linker script. Unzipping and zipping back together seems ugly. The other option is not very nice. The linker script language does not allow "+" to appear in the filenames, and filenames that meson generates use that, so files would have to be renamed before a linker script was used. And we would have to generate the linker script on the fly. Either way, this doesn't seem attractive. Since those static libraries are a niche use case, it seems reasonable to just go with the easiest and safest solution and recompile all the source files. Thanks to ccache, this is probably almost as cheap as actually reusing the convenience .a libraries. test-libsystemd-sym.c and test-libudev-sym.c compile fine with the generated static libs, so it seems that they indeed provide all the symbols they should.
* tree-wide: use strv_free_and_replace() macroYu Watanabe2018-08-24
|
* bus-util: print a friendly message when PID1 is not systemdYu Watanabe2018-08-24
| | | | | | Follow-up for 861f16d2679eeda79e8185057cef24653913e300. Fixes #8913.
* util: rename signal_from_string_try_harder() to signal_from_string()Yu Watanabe2018-08-24
| | | | | Also this makes the new `signal_from_string()` function reject e.g, `SIG3` or `SIG+5`.
* conf-parse: add a generic config_parse_mtu() conf file parser functionLennart Poettering2018-08-24
| | | | | | | It's mostly a wrapper around parse_mtu() but with some nicer logging. The address family is initialized from the "ltype" parameter, so that configuration file parser tables can be easily declare it.
* 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.