Commit Graph

77 Commits

Author SHA1 Message Date
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Lennart Poettering dee29aeb59 generator: use kmsg in system-level generators, journal otherwise
Fixes: #17129.
2020-09-30 16:28:34 +02:00
Franck Bui ad8f1b0f36 generator: don't generate device dependencies for extrinsic mounts
Stop generating device dependencies for extrinsic mounts: we already exclude
extrinsic mounts from the usual start-up and shutdown dependencies but some
extra deps added by generator_write_device_deps() were remaining.
2020-04-01 17:30:34 +02:00
Zbigniew Jędrzejewski-Szmek dc9fd22d3d Merge pull request #14398 from poettering/mount-prep 2020-02-04 16:28:51 +01:00
Lennart Poettering a7e8855879 units: introduce blockdev@.target for properly ordering mounts/swaps against cryptsetup
Let's hook it into both cryptsetup-generator and gpt-auto-generator with
a shared implementation in generator.c

Fixes: #8472
2020-01-21 20:23:13 +01:00
Lennart Poettering 18e6e8635f generator: order growfs for the root fs after systemd-remount-fs
Fixes: #14603
2020-01-21 10:40:18 +01:00
Zbigniew Jędrzejewski-Szmek 7cecc56316 cryptsetup-generator: unconfuse writing of the device timeout
The code was using timeout=0 as the default option string. This option string
was ultimately passed to generator_write_timeouts(), which only looks for
comment=systemd.device-timeout= or x-systemd.device-timeout=, i.e. the whole
call path was bogus. Let's rework this: generator_write_timeouts() now writes
any timeouts if configured by the user. create_disk() writes out it's own
timeout, but with lower priority. Since the code path that was calling
timeout=0 was not effective, the only change is that we stop overwriting the
timeout if explicitly configured by the user.

In both code paths, ignore failure to write.
2019-12-03 17:20:19 +01:00
Lennart Poettering afacf3fc8a generator: downgrade Requires= → Wants= of fsck from /usr mount unit
Fixes #5099
2019-07-10 16:19:31 +02:00
Lennart Poettering cbdc9cfe2b core: spaces rock 2019-07-10 16:19:31 +02:00
Yu Watanabe 270384b2d4 tree-wide: replace strjoina() with prefix_roota() 2019-06-25 01:31:26 +09:00
Zbigniew Jędrzejewski-Szmek 37dc34f702 shared/generator: voidify mkdir_parents() call
To appease coverity: CID#1401752.
2019-06-04 08:57:54 +02:00
Zbigniew Jędrzejewski-Szmek 41f6e627d7 Make fopen_temporary and fopen_temporary_label unlocked
This is partially a refactoring, but also makes many more places use
unlocked operations implicitly, i.e. all users of fopen_temporary().
AFAICT, the uses are always for short-lived files which are not shared
externally, and are just used within the same context. Locking is not
necessary.
2019-04-12 11:44:56 +02:00
Zbigniew Jędrzejewski-Szmek 804f8e1729 generator: rename systemd-mkfs@.service to systemd-makefs@.service
The second name was used in documentation, and the first in the code that
generated the unit. 'systemd-makefs' is the name we want, for example for
consistency with the systemd-makefs executable.

In principle this breaks compatibility, but in practice this is unlikely to be
noticeable. Each instance of the unit is created by writing out a full
definition, so the template was never defined. So the name could only be used
for ordering, and there is not reason to order things against this unit from
the outside: the ordering would rather be against the final mount unit.

Fixes #11769.
2019-02-21 10:59:27 +01:00
Zbigniew Jędrzejewski-Szmek 5ff8da1057 Define macro for systemd-fsck-root.service
There is one for systemd-fsck@.service, so for consistency...
2019-01-03 15:31:03 +01:00
Zbigniew Jędrzejewski-Szmek 9b69569d2c Pull in systemd-remount-fs.service only when required
Instead of enabling it unconditionally and then using ConditionPathExists=/etc/fstab,
and possibly masking this condition if it should be enabled for auto gpt stuff,
just pull it in explicitly when required.
2019-01-03 15:30:28 +01:00
Zbigniew Jędrzejewski-Szmek 5c176eb4bf shared/generator: allow absolute symlink target in generator_add_symlink()
Also remove the stray ".d" from comment and rename directory argument to "dir"
(we usually use "root" for arg_root, so using it here was misleading).
2019-01-03 15:30:25 +01:00
Zbigniew Jędrzejewski-Szmek c2f4bcfcc1 shared/generator: reword comment for clarity 2018-12-03 23:55:29 +01:00
Lennart Poettering ff9bf8d012 units: make fsck/grows/makefs/makeswap units conflict against shutdown.target
They are the only units we shipped/generated where this was missing really. Let's fix these.

Follow-up for: #10933
2018-11-26 22:18:16 +01:00
Harald Hoyer 4e9322048b generator.c: systemd-fsck-root.service conflict with shutdown.target
Otherwise a "reboot" or "poweroff" in the initramfs will have to wait
until systemd-fsck-root.service has completed, which might never happen
if the root device never shows up.
2018-11-26 16:51:22 +01:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Lennart Poettering 6bf3c61c57 log: introduce new helper call log_setup_service()
Let's reduce the common boilerplate and have a single setup function
used by all service code to setup logging.
2018-11-20 11:18:22 +01:00
Lennart Poettering afe44c8ffd generators: introduce a common implementation for the log setup boilerplate 2018-11-20 10:57:50 +01:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
These lines are generally out-of-date, incomplete and unnecessary. With
SPDX and git repository much more accurate and fine grained information
about licensing and authorship is available, hence let's drop the
per-file copyright notice. Of course, removing copyright lines of others
is problematic, hence this commit only removes my own lines and leaves
all others untouched. It might be nicer if sooner or later those could
go away too, making git the only and accurate source of authorship
information.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
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.
2018-04-06 18:58:55 +02:00
Zbigniew Jędrzejewski-Szmek fb883e759d generator: add helper function for writing unit files
It doesn't save too much, but it's a common pattern so I think it's worth
to factor this out.
2017-12-15 16:47:11 +01:00
Zbigniew Jędrzejewski-Szmek 7f2806d509 Add x-systemd.growfs option for fstab 2017-11-30 20:46:30 +01:00
Zbigniew Jędrzejewski-Szmek da495a0385 Add x-systemd.makefs option for fstab
I opted to completely generate a unit for both mount points and swaps. For
swaps, it would be possible to use fixed template unit like systemd-mkswap@.service,
because there's no information passed except the device name. For mount points,
that's not possible because both the device name and file system type need to
be passed. Nevertheless, I expect that options will need to passed to both mkfs
and mkswap, in which case it'll be necessary to create units of both types
anyway.
2017-11-30 20:46:30 +01:00
Lennart Poettering 98bad05e75 generators: be more careful when writing unit settings that support specifier expansion
Let's always escape strings we receive from the user before writing them
out to unit file settings that suppor specifier expansion, so that user
strings are transported as-is.
2017-11-29 12:32:57 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Lennart Poettering acd53eaa7e generator: when we insert a '\n', actually place a proper newline, too 2017-10-05 13:06:44 +02:00
NeilBrown c67bd1f758 fstab-generator: ignore x-systemd.device-timeout for non-devices (#6368)
If you specify "x-systemd.device-timeout" for an NFS mount
point, you get no warning and a meaningless device unit
dependency created.

Better to have a warning and no dependency.
2017-07-17 10:03:34 +02:00
Zbigniew Jędrzejewski-Szmek 7f0cc63771 sysv-generator: use generator_add_symlink()
generator_add_symlink() is extended to ignore EEXIST. This should be fine
for all existing callers.

There's a small difference in behaviour when adding symlinks in sysv-generator:
the message is more generic and does not include ", ignored". But creation of
symlinks shouldn't ever fail except if things are very wrong, so in practice
this shouldn't matter.

Test needed updating: os.path.exists(os.readlink(link)) only works if the link
is absolute (or if we are in the right directory). Let's just use
os.path.exists(link), which properly tests that the symlink target exists.
2017-07-13 18:56:36 -04:00
Zbigniew Jędrzejewski-Szmek b559616f23 cryptsetup-generator: add a helper utility to create symlinks
It seems that there's a common pattern among the various generators. Let's add
a helper function for it and make use of it in cryptsetup-generator.

This fixes a bunch of theoretical memleaks in error paths, since *to wasn't
generally freed properly. Not thath it matters.
2017-07-10 00:16:36 -04:00
Zbigniew Jędrzejewski-Szmek 0004f698df Parse "timeout=0" as infinity in various generators (#6264)
This extends 2d79a0bbb9 to the kernel
command line parsing.

The parsing is changed a bit to only understand "0" as infinity. If units are
specified, parse normally, e.g. "0s" is just 0. This makes it possible to
provide a zero timeout if necessary.

Simple test is added.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1462378.
2017-07-03 14:29:32 +02:00
Michal Koutný d9732d7803 core/device: Use JobRunningTimeoutSec= for device units
Device job timeouts should respect possible device job dependencies so we set
JobRunningTimeoutSec= by default.
2017-04-25 18:00:36 +02:00
Michal Koutný 4195077ab4 fstab-generator: Apply _netdev option also to device units
In case the device field of fstab record is an actual device (not an address)
apply same dependencies to the device unit as to the mount unit, i.e.

> After=network-online.target network.target
> Wants=network-online.targe

It makes sense to start the device expecting job only when network is actually
ready (consider e.g. iSCSI devices) since it is device's implicit dependency.

The eventual implementation should better obtain network flag from udev
database and would also take into account device hierarchy (see [1]).
This patch approximates that by taking the `_netdev` option as a hint from the
user both about the filesystem and underlying device. (For local devices with
network filesystems (e.g. ocfs2), this hint leads to unused dependencies.)

[1] https://lists.freedesktop.org/archives/systemd-devel/2014-October/024718.html
2017-04-25 18:00:36 +02:00
Lennart Poettering 0900593e86 generator: order fsck service After= the device
Otherwise we might get started too early.
2016-12-14 10:13:52 +01:00
Daniel Drake 7163e1ca11 Create initrd-root-device.target synchronization point (#3239)
Add a synchronization point so that custom initramfs units can run
after the root device becomes available, before it is fsck'd and
mounted.

This is useful for custom initramfs units that may modify the
root disk partition table, where the root device is not known in
advance (it's dynamically selected by the generators).
2016-05-12 18:42:39 +02:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Franck Bui 10c71477e9 fstab-gen: don't convert device timeout into seconds when initializing JobTimeoutSec
There was no need for such conversion and it was actually wrong since
any device timeout less than a second was converted into 0 which means
waits forever.
2015-12-11 10:02:32 +01:00
Thomas Hindoe Paaboel Andersen a8fbdf5424 shared: include what we use
The next step of a general cleanup of our includes. This one mostly
adds missing includes but there are a few removals as well.
2015-12-06 13:49:33 +01:00
Michal Schmidt 7152869f0a Merge pull request #1869 from poettering/kill-overridable
Remove support for RequiresOverridable= and RequisiteOverridable=
2015-11-13 14:04:34 +01:00
Michael Marineau 5fd534d919 generator: order initrd fsck-root after local-fs-pre
The initrd version of systemd-fsck-root.service must wait for
local-fs-pre.target just like systemd-fsck@.service to prevent
modifications to the filesystem prior to resuming from hibernation.
As-is my laptop routinely fails to resume due to fsck errors. The rest
of the time it is probably silently corrupting the filesystem.

Unlike normal boot, in the initrd systemd-fsck-root.service has no
special significance so it needs to be kept in sync with
systemd-fsck@.service. The name systemd-fsck-root.service is only used
to preserve state across switch-root.
2015-11-12 18:35:27 -08:00
Lennart Poettering f32b43bda4 core: remove support for RequiresOverridable= and RequisiteOverridable=
As discussed at systemd.conf 2015 and on also raised on the ML:

http://lists.freedesktop.org/archives/systemd-devel/2015-November/034880.html

This removes the two XyzOverridable= unit dependencies, that were
basically never used, and do not enhance user experience in any way.
Most folks looking for the functionality this provides probably opt for
the "ignore-dependencies" job mode, and that's probably a good idea.

Hence, let's simplify systemd's dependency engine and remove these two
dependency types (and their inverses).

The unit file parser and the dbus property parser will now redirect
the settings/properties to result in an equivalent non-overridable
dependency. In the case of the unit file parser we generate a warning,
to inform the user.

The dbus properties for this unit type stay available on the unit
objects, but they are now hidden from usual introspection and will
always return the empty list when queried.

This should provide enough compatibility for the few unit files that
actually ever made use of this.
2015-11-12 19:27:24 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 4349cd7c1d util-lib: move mount related utility calls to mount-util.[ch] 2015-10-27 13:25:55 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Lennart Poettering 4f5dd3943b util: split out escaping code into escape.[ch]
This really deserves its own file, given how much code this is now.
2015-10-24 23:04:42 +02:00