summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* tree-wide: introduce new safe_fork() helper and port everything overLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new safe_fork() wrapper around fork() and makes use of it everywhere. The new wrapper does a couple of things we previously did manually and separately in a safer, more correct and automatic way: 1. Optionally resets signal handlers/mask in the child 2. Sets a name on all processes we fork off right after forking off (and the patch assigns useful names for all processes we fork off now, following a systematic naming scheme: always enclosed in () – in order to indicate that these are not proper, exec()ed processes, but only forked off children, and if the process is long-running with only our own code, without execve()'ing something else, it gets am "sd-" prefix.) 3. Optionally closes all file descriptors in the child 4. Optionally sets a PR_SET_DEATHSIG to SIGTERM in the child, in a safe way so that the parent dying before this happens being handled safely. 5. Optionally reopens the logs 6. Optionally connects stdin/stdout/stderr to /dev/null 7. Debug logs about the forked off processes.
* terminal-util: open /dev/null with O_CLOEXEC in make_stdio_null()Lennart Poettering2018-05-30
| | | | | | | | | | Ultimately, O_CLOEXEC should be off in fd 0, 1, 2, but when we open /dev/null here it's unlikely to be < 0, and after dupping the fd to 0, 1, 2 we turn off O_CLOEXEC explicitly anyway. Unless we know that what we are about to open will return 0, 1 or 2 we should always set O_CLOEXEC in order to be safe to other threads forking of subprocesses at the wrong moment.
* terminal-util: return first error, not last in make_stdio()Lennart Poettering2018-05-30
| | | | | | | | Just a minor tweak, making sure we execute as much as we can of the funciton, but return the first error instead of the last we encounter. This is usuelly how we do things when we have functions that continue on the first error, so let's do it like that here too.
* fd-util: use close_nointr() return value instead of errnoLennart Poettering2018-05-30
| | | | | Our own calls return errors in their return values, hence use that rather than errno when checking errors.
* fd-util: add some (void) castsLennart Poettering2018-05-30
|
* man: add a systemd-rc-local-generator(8) man pageLennart Poettering2018-05-30
| | | | | | | Most importantly, let's highlight the differences to the rc-local behaviour in SysV. Fixes: #7703
* separate flags from shebangbleep_blop2018-05-30
|
* meson: hopefully renameat2() will show up where renameat() is definedLennart Poettering2018-05-30
| | | | | Should glibc add this eventually, let's try to be smart where to look for it.
* meson: look for gettid() definition where getpid() is definedLennart Poettering2018-05-30
| | | | | Hopefully, should gettid() show up one day in glibc it'll show up where getpid() is defined too.
* meson: when pivot_root() is added one day, look for it in <unistd.h>Lennart Poettering2018-05-30
| | | | | | | | | | We of course don't know in which header glibc will export pivot_root() and if it ever will. But there's a good chance they'll place it where chroot() is located, given the similarity in the operations, hence let's try our luck and look for it at the same place. If we are lucky this means we don't have to patch our code if glibc decides to expose the call one day.
* meson: use "args" for setting _GNU_SOURCE when checking for functionsLennart Poettering2018-05-30
| | | | | | | | | | | | | | This reworks how we set _GNU_SOURCE when checking for the availability of functions: 1. We set it for most of the functions we look for. After all we set it for our entire built anyway, and it's usually how Linux-specific definitions in glibc are protected these days. Given that we usually have checks for such modern stuff only anyway, let's just blanket enable it. 2. Use "args" instead of "prefix" to set the macro. This is what is suggested in the meson docs, hence let's do it.
* meson: define _GNU_SOURCE to detect copy_file_range() (#7734)Yu Watanabe2018-05-30
| | | | | | | | | Follow-up for bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f of git repository for glibc. Recently glibc added `copy_file_range()`, but to use it, `_GNU_SOURCE` needs to be defined. This adds the flag in meson.build to detect the function by meson correctly.
* Move mkdir_label() to mkdir-label.cZbigniew Jędrzejewski-Szmek2018-05-30
| | | | It just seems strange to have it in a different file if mkdir-label.c exists.
* smack-util: remove unneeded initalizationZbigniew Jędrzejewski-Szmek2018-05-30
|
* Add mkdir_errno_wrapper() and use instead of mkdir() in various placesZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | We'd pass pointers to mkdir and mkdir_label to call in various places. mkdir returns the error in errno while mkdir_label returns the error directly.
* basic: introduce socket_protocol_{from,to}_name()Yu Watanabe2018-05-30
| | | | And use them where they can be applicable.
* socket-util: add socket_address_type_{from,to}_string()Yu Watanabe2018-05-30
|
* networkd: Add support for ipvlan L3s and flags (#7726)Susant Sahani2018-05-30
| | | | | This works supports to configure L3S mode and flags such as bridge, private and vepa
* sd-bus: drop check for selinux before calling getsockopt(SO_PEERSEC)Zbigniew Jędrzejewski-Szmek2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Quoting Lennart Poettering in https://github.com/systemd/systemd/pull/6464#issuecomment-319029293: > If the kernel allows us to query that data we should also be Ok with passing > it on to our own caller, regardless if selinux is technically on or off... The advantage is that this allows gcc to be smarter and reduce linkage: (before)$ ldd build/libnss_systemd.so.2 linux-vdso.so.1 (0x00007ffeb46ff000) librt.so.1 => /lib64/librt.so.1 (0x00007f2f60da6000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f2f60ba1000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f2f60978000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2f60759000) libc.so.6 => /lib64/libc.so.6 (0x00007f2f60374000) /lib64/ld-linux-x86-64.so.2 (0x00007f2f61294000) libpcre2-8.so.0 => /lib64/libpcre2-8.so.0 (0x00007f2f600f0000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f2f5feec000) (after )$ ldd build/libnss_systemd.so.2 linux-vdso.so.1 (0x00007ffe5f543000) librt.so.1 => /lib64/librt.so.1 (0x00007f427dcaa000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f427daa5000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f427d886000) libc.so.6 => /lib64/libc.so.6 (0x00007f427d4a1000) /lib64/ld-linux-x86-64.so.2 (0x00007f427e196000) Note that this only works in conjuction with the previous commit: either of the two commits alone does not have the desired effect on linkage. Replaces #6464.
* Move selinux-related stuff from btrfs-util.c to label.cZbigniew Jędrzejewski-Szmek2018-05-30
| | | | In preparation for future changes.
* more portable perl shebangs (#7701)Jörg Thalheim2018-05-30
| | | | | | | | | same motivation as in #5816: - distributions have scripts to rewrite shebangs on installation and they know what locations to rely on. - For tests/compilation we should rather rely on the user to have setup there PATH correctly.
* missing: Add DM_DEFERRED_REMOVEHenrik Grindal Bakken2018-05-30
| | | | Also include missing.h in dissect-image.c to pick it up.
* missing: Define SMACK_MAGIC if it's missingHenrik Grindal Bakken2018-05-30
|
* missing: Define EFIVARFS_MAGIC if missingHenrik Grindal Bakken2018-05-30
|
* missing: Add MAX_HANDLE_SZHenrik Grindal Bakken2018-05-30
|
* missing: Add PR_SET_MM_{ARG,ENV}_{START,END}Henrik Grindal Bakken2018-05-30
|
* missing: Add some more btrfs structs and constantsHenrik Grindal Bakken2018-05-30
|
* build-sys: install TRANSIENT-SETTINGS.md and UIDS-GIDS.md (#7690)Felipe Sateler2018-05-30
|
* mount-setup: fix MNT_CHECK_WRITABLE error handling, and log about the issueLennart Poettering2018-05-30
| | | | | Let's correct the error handling (the error is in errno, not r), and let's add logging like the rest of the function has it.
* meson: libudev_core and udevadm should have LOG_REALM=LOG_REALM_UDEV (#7666)Franck Bui2018-05-30
| | | | | | | | Otherwise, setting udev_log=debug in /etc/udev/udev.conf has no effects since systemd-udevd is built with LOG_REALM=LOG_REALM_UDEV. However using LOG_REALM_UDEV (for libudev_core) reveals another similar bug for udevadm which should also define LOG_REALM_UDEV.
* logind: use free_and_replace in one spotZbigniew Jędrzejewski-Szmek2018-05-30
| | | | No functional change.
* tree-wide: use SPECIAL_ROOT_SLICEZbigniew Jędrzejewski-Szmek2018-05-30
|
* logind: fix misleading messageZbigniew Jędrzejewski-Szmek2018-05-30
| | | | | This message would also be emitted at boot for any user with linger enabled, so "logged in" is the wrong term to use.
* logind: simplify one conditionalZbigniew Jędrzejewski-Szmek2018-05-30
| | | | Don't bother with removing the directory if we didn't create it.
* Fix logical error in meson.build (#7658)Max Harmathy2018-05-30
| | | | sysvinit_path and sysvrcnd_path have to be set both to activate Sysv compatibility.
* man: Clarify when OnFailure= activates after restarts (#7646)Ken (Bitsko) MacLeod2018-05-30
|
* tree-wide: add DEBUG_LOGGING macro that checks whether debug logging is on ↵Lennart Poettering2018-05-30
| | | | | | | | (#7645) This makes things a bit easier to read I think, and also makes sure we always use the _unlikely_ wrapper around it, which so far we used sometimes and other times we didn't. Let's clean that up.
* TODO: updateYu Watanabe2018-05-30
|
* verbs: Rename VERB_OFFLINE to VERB_ONLINE_ONLY, expand MUSTBEROOTColin Walters2018-05-30
| | | | | | Followup to previous commit. Suggested by @poettering. Reindented the `verbs[]` tables to match the apparent previous whitespace rules (indent to one flag, allow multiple flags to overflow?).
* systemctl,verbs: Introduce SYSTEMD_OFFLINE environment variableColin Walters2018-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A lot of code references the `running_in_chroot()` function; while I didn't dig I'm pretty certain this arose to deal with situations like RPM package builds in `mock` - there we don't want the `%post`s to `systemctl start` for example. And actually this exact same use case arises for [rpm-ostree](https://github.com/projectatomic/rpm-ostree/) where we implement offline upgrades by default; the `%post`s are always run in a new chroot using [bwrap](https://github.com/projectatomic/bubblewrap). And here's the problem: bwrap creates proper mount roots, so it passes `running_in_chroot()`, and then if a script tries to do `systemctl start` we get: `System has not been booted with systemd as init system (PID 1)` but that's an *error*, unlike the `running_in_chroot()` case where we ignore. Further complicating things is there are real world RPM packages like `glusterfs` which end up invoking `systemctl start`. A while ago, the `SYSTEMD_IGNORE_CHROOT` environment variable was added for the inverse case of running in a chroot, but still wanting to use systemd as PID 1 (presumably some broken initramfs setups?). Let's introduce a `SYSTEMD_OFFLINE` environment variable for cases like mock/rpm-ostree so we can force on the "ignore everything except preset" logic. This way we'll still not start services even if mock switches to use nspawn or bwrap or something else that isn't a chroot. We also cleanly supercede the `SYSTEMD_IGNORE_CHROOT=1` which is now spelled `SYSTEMD_OFFLINE=0`. (Suggested by @poettering) Also I made things slightly nicer here and we now print the ignored operation.
* CODING_STYLE: provide better explanation why /* */ over // (#7647)Lennart Poettering2018-05-30
| | | | | | | | Let's provide a real reason why /* */ should be used for commenting, rather than //, beyond mere taste. (This ultimately simply codifies how I use // vs. /* */ comments, and I think this is useful as an explanation and reason hence.)
* final v236 update (#7649)Lennart Poettering2018-05-30
|
* NEWS: update NEWS again, and prepare for a release tomorrowLennart Poettering2018-05-30
|
* meson: increase version numbersLennart Poettering2018-05-30
|
* core: Implement timeout based umount/remount limitKyle Walker2018-05-30
| | | | | | | | | | | | | Remount, and subsequent umount, attempts can hang for inaccessible network based mount points. This can leave a system in a hard hang state that requires a hard reset in order to recover. This change moves the remount, and umount attempts into separate child processes. The remount and umount operations will block for up to 90 seconds (DEFAULT_TIMEOUT_USEC). Should those waits fail, the parent will issue a SIGKILL to the child and continue with the shutdown efforts. In addition, instead of only reporting some additional errors on the final attempt, failures are reported as they occur.
* tree-wide: make use of new STRLEN() macro everywhere (#7639)Lennart Poettering2018-05-30
| | | | | | Let's employ coccinelle to do this for us. Follow-up for #7625.
* basic: turn off stdio locking for a couple of helper callsLennart Poettering2018-05-30
| | | | | | These helper calls are potentially called often, and allocate FILE* objects internally for a very short period of time, let's turn off locking for them too.
* core: add EXTEND_TIMEOUT_USEC={usec} - prevent timeouts in ↵Daniel Black2018-05-30
| | | | | | | | | | | | | | | | | | | | | startup/runtime/shutdown (#7214) With Type=notify services, EXTEND_TIMEOUT_USEC= messages will delay any startup/ runtime/shutdown timeouts. A service that hasn't timed out, i.e, start time < TimeStartSec, runtime < RuntimeMaxSec and stop time < TimeoutStopSec, may by sending EXTEND_TIMEOUT_USEC=, allow the service to continue beyond the limit for the execution phase (i.e TimeStartSec, RunTimeMaxSec and TimeoutStopSec). EXTEND_TIMEOUT_USEC= must continue to be sent (in the same way as WATCHDOG=1) within the time interval specified to continue to reprevent the timeout from occuring. Watchdog timeouts are also extended if a EXTEND_TIMEOUT_USEC is greater than the remaining time on the watchdog counter. Fixes #5868.
* check_tree.pl: Do not allow diff to move name reverts into a maskSven Eden2018-05-30
| | | | | | | block. Do not replace double dashes in XML comments, that are either the comment start or end.
* check_tree.pl: Move move upstream appends from after our mask blocksSven Eden2018-05-29
| | | | up before found #else switches.