summaryrefslogtreecommitdiff
path: root/src/shared
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-06107-1391/+0
| | | | | | | | | | 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.
* dissect: when pulling metadata from an image, don't bother with /home or ESPLennart Poettering2018-04-051-2/+4
| | | | | | | | When we try to read meta-data from an image, don't bother with mounting /home or the ESP, as that's not where the metadata is. This not only speeds things up a bit, but also has the benefit that setups where an unencrypted root is mixed with an encrypted /home (which I have on one of my own systems) won't result in errors that the crypto key is needed.
* dissect: tighten block device checks a bitLennart Poettering2018-04-051-1/+24
| | | | | | | | | | | | | | | | | | | This extends on #8609, and makes two changes: 1. We'll now explicitly check that the child devices of a block device we are interested in (i.e. the partitions) are block devices themselves. On newer kernels the mmc rpmb stuff is actually exposed as char rather than block device as before, and they probably should have been that in the first place. By adding this check we'll hence filter out these weird devices through a second rule too, that hopefully makes things a bit more future-proof, should more devices like this be added eventually, or other subsystems do a similar thing. 2. When counting partitions we'll now also check the devnum of the device being non-null, which we already do when matching up the devices in the second iteration. This should make things more robust, and prevent other kinds of miscounting, which after all was the main issue #8609 fixed.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-0514-141/+77
|
* bus-util: fix a meaningless assertionYu Watanabe2018-04-051-1/+1
|
* Merge pull request #8605 from poettering/drop-in-name-fixZbigniew Jędrzejewski-Szmek2018-04-043-49/+62
|\ | | | | | | Fix validation of unit file drop-in naming in install.c.
| * bus-unit-util: one less newlineLennart Poettering2018-03-291-1/+0
| |
| * install: don't enforce that .d/ dropin files (and their symlink chain ↵Lennart Poettering2018-03-291-40/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | elements) for units must have names that qualify as unit names The names of drop-in files can be anything as long as they are suffixed in ".conf", hence don't be stricter than necessary when validating the names used in symlink chains of such drop-in files. Also, drop-in files should not be ale to change the type of unit file itself, i.e. not affect whether it is considered masked or an alias as a whole. This adds a flag SEARCH_DROPIN that is passed whenever we load a drop-in rather the main unit file, and in that case loosen checks and behaviour we otherwise enforce for the unit file itself. Specifically: 1. If SEARCH_DROPIN is passed we won't change the unit's info->type field anymore, as that field (which can be REGULAR, MASKED, SYMLINK) should not be affected by drop-ins, but only by the unit file itself. 2. If SEARCH_DROPIN is passed we will shortcut following of symlink chains, and not validate the naming of each element in the chain, since that's irrelevant for drop-ins, and only matters for the unit file itself. Or in other words, without this: 1. A symlink /etc/systemd/system/foobar.service.d/20-quux.conf → /dev/null might have caused the whole of foobar.service to be considered "masked". 2. A symlink /etc/systemd/system/foobar.service.d/20-quux.conf → /tmp/miepf might have caused the whole loading of foobar.service to fail as EINVAL, as "miepf" is not a valid unit name.
| * dissect: port code to chase_symlinks_and_open()Lennart Poettering2018-03-291-8/+4
| |
* | dissect: Don't count RPMB and boot partitions (#8609)João Paulo Rechi Vita2018-04-031-7/+20
|/ | | | | | | | Filter-out RPMB partitions and boot partitions from MMC devices when counting partitions enumerated by the kernel. Also factor out the now duplicated code into a separate function. This complement the previous fixes to the problem reported in https://github.com/systemd/systemd/issues/5806
* Merge pull request #8606 from dell/rename-suspend-to-hibernateZbigniew Jędrzejewski-Szmek2018-03-291-4/+4
|\ | | | | Rename suspend-to-hibernate to suspend-then-hibernate
| * Rename suspend-to-hibernate to suspend-then-hibernateMario Limonciello2018-03-281-4/+4
| | | | | | | | | | Per some discussion with Gnome folks, they would prefer this name as it's more descriptive of what's happening.
* | machine-image,mount-setup: minor coding style fixesLennart Poettering2018-03-281-2/+1
|/
* bus-util: add flags for bus_map_all_properties() (#8546)Yu Watanabe2018-03-282-13/+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.
* Merge pull request #8600 from keszybz/oss-fuzz-againLennart Poettering2018-03-281-17/+14
|\ | | | | Fuzzing- and test-related fixes
| * shared/specifier: use realloc to free some memory after specifier expansionZbigniew Jędrzejewski-Szmek2018-03-281-2/+9
| | | | | | | | | | | | | | | | | | | | | | This is a separate commit only because it actually *increases* memory allocations: ==3256== total heap usage: 100,120 allocs, 100,120 frees, 13,097,140 bytes allocated to ==4690== total heap usage: 100,121 allocs, 100,121 frees, 14,198,329 bytes allocated Essentially, we do a little more work to reduce the memory footprint a bit. For a test where we just allocate the memory and drop it soon afterwards, this is not beneficial, but it should still be useful for a long running program.
| * shared/specifier: be less extravagant with memory allocationsZbigniew Jędrzejewski-Szmek2018-03-281-15/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ubsan times out because we do too many allocations: $ valgrind build/fuzz-unit-file test/fuzz-regressions/fuzz-unit-file/oss-fuzz-6977-full ... test/fuzz-regressions/fuzz-unit-file/oss-fuzz-6977-full... ok ==1757== ==1757== HEAP SUMMARY: ==1757== in use at exit: 0 bytes in 0 blocks ==1757== total heap usage: 199,997 allocs, 199,997 frees, 90,045,318,585 bytes allocated ... ==3256== total heap usage: 100,120 allocs, 100,120 frees, 13,097,140 bytes allocated https://oss-fuzz.com/v2/issue/4651449704251392/6977 should now be really fixed. e3c3d6761b3e7d was the first attempt, but even with this change, e3c3d6761b3e7d still makes sense.
* | nspawn: do not insist on locking read-only container on readonly fs (#8589)Lauri Tirkkonen2018-03-281-2/+7
|/
* Merge pull request #8554 from poettering/chase-trail-slashZbigniew Jędrzejewski-Szmek2018-03-262-6/+6
|\ | | | | fs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()
| * fs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()Lennart Poettering2018-03-222-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This rearranges chase_symlinks() a bit: if no special flags are specified it will now revert to behaviour before b12d25a8d631af00b200e7aa9dbba6ba4a4a59ff. However, if the new CHASE_TRAIL_SLASH flag is specified it will follow the behaviour introduced by that commit. I wasn't sure which one to make the beaviour that requires specification of a flag to enable. I opted to make the "append trailing slash" behaviour the one to enable by a flag, following the thinking that the function should primarily be used to generate a normalized path, and I am pretty sure a path without trailing slash is the more "normalized" one, as the trailing slash is not really a part of it, but merely a "decorator" that tells various system calls to generate ENOTDIR if the path doesn't refer to a path. Or to say this differently: if the slash was part of normalization then we really should add it in all cases when the final path is a directory, not just when the user originally specified it. Fixes: #8544 Replaces: #8545
* | Partially revert "seccomp: add mmap and address family restrictions for ↵James Cowgill2018-03-231-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MIPS" (#8563) This reverts the mmap parts of f5aeac1439d64905c7b1b57042c39589dd31e3a6, but keeps the part which restricts address families which works correctly. Unfortunately the MIPS toolchains still do not implement PT_GNU_STACK. This means that while the commit to restrict mmap on MIPS was "correct", it had the side effect of causing pthread_create to fail because glibc tries to allocate an executable stack for new threads in the absense of PT_GNU_STACK. We should wait until PT_GNU_STACK is implemented in all the relevant parts of the toolchain (at least gcc and glibc) before enabling this again.
* | tree-wide: tabs suck (#8527)Lennart Poettering2018-03-231-1/+1
| |
* | Merge pull request #8530 from poettering/include-is-obsoleteZbigniew Jędrzejewski-Szmek2018-03-231-3/+8
|\ \ | | | | | | actively say that .include is obsolete
| * | conf-parse: small prettificationLennart Poettering2018-03-211-3/+4
| | | | | | | | | | | | | | | | | | 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-03-211-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | .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.
* | | macro: introduce new TAKE_FD() macroLennart Poettering2018-03-221-9/+3
| | | | | | | | | | | | | | | | | | | | | This is similar to TAKE_PTR() but operates on file descriptors, and thus assigns -1 to the fd parameter after returning it. Removes 60 lines from our codebase. Pretty good too I think.
* | | sleep-config: replace USE() macro with TAKE_PTR() usageLennart Poettering2018-03-221-8/+6
| | | | | | | | | | | | | | | let's use the new generic macor instead of the locally defined, specific one.
* | | macro: introduce TAKE_PTR() macroLennart Poettering2018-03-2214-54/+25
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | seccomp: add mmap and address family restrictions for MIPS (#8547)James Cowgill2018-03-221-4/+16
|/
* shared/conf-parser: fix outdated commentZbigniew Jędrzejewski-Szmek2018-03-211-1/+1
|
* Merge pull request #8508 from poettering/more-cocciZbigniew Jędrzejewski-Szmek2018-03-211-1/+1
|\ | | | | two new coccinelle rules files and their results
| * coccinelle: make use of DIV_ROUND_UP() wherever appropriateLennart Poettering2018-03-201-1/+1
| | | | | | | | Let's use our macros where we can
* | dissect: add dissect_image_and_warn() that unifies error message generation ↵Lennart Poettering2018-03-212-1/+56
|/ | | | for dissect_image() (#8517)
* seccomp: enable RestrictAddressFamilies on ppc (#8505)Mathieu Malaterre2018-03-201-1/+1
| | | | | In commit da1921a5c3 ppc64/ppc64el were added as supported architectures for socketcall() for the POWER family. Extend the support for the 32bits architectures.
* bus-util: introduce bus_message_print_all_properties()Yu Watanabe2018-03-202-43/+83
| | | | Then, use it where applicable.
* bus-util: make bus_map_all_properties() not copy stringYu Watanabe2018-03-202-9/+23
|
* bus-util: store boolean message to boolYu Watanabe2018-03-191-2/+2
|
* Merge pull request #8399 from keszybz/systemctl-kexecYu Watanabe2018-03-191-3/+3
|\ | | | | Systemctl kexec buglet fixes
| * shared/bootspec: look at the correct variableZbigniew Jędrzejewski-Szmek2018-03-081-3/+3
| | | | | | | | | | The result of this parsing isn't used for anything, so this didn't cause a functional difference, but a spurious warning was emitted.
* | systemd-link: Remove UDP Fragmentation Offload support. (#8183)Rosen Penev2018-03-182-0/+38
| | | | | | | | | | | | | | | | Support was killed in kernel 4.15 as well as ethtool 4.13. Justification was lack of use by drivers and too much of a maintenance burden. https://www.spinics.net/lists/netdev/msg443815.html Also moved config_parse_warn_compat to conf-parser.[ch] to fix compile errors.
* | basic/macros: rename noreturn into _noreturn_ (#8456)Franck Bui2018-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | "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.
* | shared/sleep-config: fix unitialized variable and use STR_IN_SET (#8416)Zbigniew Jędrzejewski-Szmek2018-03-111-10/+7
| |
* | Merge pull request #8372 from keszybz/two-cleanupsLennart Poettering2018-03-083-8/+4
|\ \ | | | | | | Two cleanups
| * | core: drop unnecessary __useless_struct_to_allow_trailing_semicolon__Zbigniew Jędrzejewski-Szmek2018-03-063-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ISO C does not allow empty statements outside of functions, and gcc will warn the trailing semicolons when compiling with -pedantic: warning: ISO C does not allow extra ‘;’ outside of a function [-Wpedantic] But our code cannot compile with -pedantic anyway, at least because warning: ISO C does not support ‘__PRETTY_FUNCTION__’ predefined identifier [-Wpedantic] Without -pedatnic, clang and even old gcc (3.4) generate no warnings about those semicolons, so let's just drop __useless_struct_to_allow_trailing_semicolon__.
* | | Introduce suspend-to-hibernate (#8274)Mario Limonciello2018-03-082-8/+50
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | Suspend to Hibernate is a new sleep method that invokes suspend for a predefined period of time before automatically waking up and hibernating the system. It's similar to HybridSleep however there isn't a performance impact on every suspend cycle. It's intended to use with systems that may have a higher power drain in their supported suspend states to prevent battery and data loss over an extended suspend cycle. Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
* | Merge pull request #8086 from hdante/sdboot-setmode-v2Zbigniew Jędrzejewski-Szmek2018-03-072-0/+3
|\ \
| * | bootctl: synchronize bootctl code with sd-boot codeHenrique Dante de Almeida2018-02-032-0/+3
| | | | | | | | | | | | | | | This patch adds a line with "#console-mode keep" as a documentation for the console mode feature and duplicates console-mode parsing to bootctl.
* | | Merge pull request #7817 from medhefgo/systemd-bootZbigniew Jędrzejewski-Szmek2018-03-072-0/+8
|\ \ \ | |_|/ |/| | systemd-boot improvements
| * | systemd-boot: Make automatic entries configurableJan Janssen2018-01-282-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hiding automatic entries allows for giving custom entry names like "Windows 10" instead of "Windows Boot Manager" by creating an appropriate loader file in the loader/entries folder. Note that it is already doable by renaming bootmgfw.efi (or the other auto-detected boot loaders) and then using the renamed file for a custom entry. But windows will automatically recreate the boot loader on updates, including the default EFI bootloader entry if that one is missing. Make hiding EFI reboot a separate option because there is no simple way to create it with a custom loader entry and people may still want that around while still hiding the other auto entries. Also, turn no_editor into a positive boolean name while we're touching this code.
* | | coccinelle: add reallocarray() coccinelle scriptLennart Poettering2018-03-022-2/+3
| | | | | | | | | | | | | | | Let's systematically make use of reallocarray() whereever we invoke realloc() with a product of two values.