X Tutup
Skip to content

Commit 2f8cd17

Browse files
committed
cryptsetup: automatically order crypt partitions before cryptsetup.target
1 parent 21931db commit 2f8cd17

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

Makefile.am

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ dist_systemunit_DATA = \
188188
units/halt.target \
189189
units/kexec.target \
190190
units/local-fs.target \
191+
units/cryptsetup.target \
191192
units/network.target \
192193
units/nss-lookup.target \
193194
units/mail-transfer-agent.target \
@@ -1161,12 +1162,14 @@ install-data-hook:
11611162
fsck-root.service \
11621163
remount-rootfs.service \
11631164
var-run.mount \
1164-
var-lock.mount && \
1165+
var-lock.mount \
1166+
cryptsetup.target && \
11651167
$(LN_S) ../systemd-remount-api-vfs.service systemd-remount-api-vfs.service && \
11661168
$(LN_S) ../fsck-root.service fsck-root.service && \
11671169
$(LN_S) ../remount-rootfs.service remount-rootfs.service && \
11681170
$(LN_S) ../var-run.mount var-run.mount && \
1169-
$(LN_S) ../var-lock.mount var-lock.mount )
1171+
$(LN_S) ../var-lock.mount var-lock.mount && \
1172+
$(LN_S) ../cryptsetup.target )
11701173
( cd $(DESTDIR)$(userunitdir) && \
11711174
rm -f shutdown.target sockets.target local-fs.target swap.target bluetooth.target printer.target && \
11721175
$(LN_S) $(systemunitdir)/shutdown.target shutdown.target && \

TODO

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,10 @@
8888

8989
* add to cpu cgroup by default
9090

91-
* introduce crypttab.target
91+
External:
9292

9393
* make cryptsetup lower --iter-time
9494

95-
External:
96-
9795
* patch kernel for xattr support in /dev, /proc/, /sys and /sys/fs/cgroup.
9896

9997
* patch kernel for cpu feature modalias for autoloading aes/kvm/...

src/cryptsetup-generator.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int create_disk(
102102
"DefaultDependencies=no\n"
103103
"BindTo=%s dev-mapper-%%i.device\n"
104104
"After=systemd-readahead-collect.service systemd-readahead-replay.service %s\n"
105-
"Before=dev-mapper-%%i.device shutdown.target local-fs.target\n",
105+
"Before=dev-mapper-%%i.device shutdown.target cryptsetup.target\n",
106106
d, d);
107107

108108
if (password && (streq(password, "/dev/urandom") ||
@@ -157,6 +157,25 @@ static int create_disk(
157157
r = -errno;
158158
goto fail;
159159
}
160+
161+
free(to);
162+
to = NULL;
163+
164+
if (!options || !has_option(options, "nofail")) {
165+
166+
if (asprintf(&to, "%s/cryptsetup.target.wants/%s", arg_dest, n) < 0) {
167+
r = -ENOMEM;
168+
goto fail;
169+
}
170+
171+
mkdir_parents(to, 0755);
172+
173+
if (symlink(from, to) < 0) {
174+
log_error("Failed to create symlink '%s' to '%s': %m", from, to);
175+
r = -errno;
176+
goto fail;
177+
}
178+
}
160179
}
161180

162181
free(to);

units/cryptsetup.target

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is part of systemd.
2+
#
3+
# systemd is free software; you can redistribute it and/or modify it
4+
# under the terms of the GNU General Public License as published by
5+
# the Free Software Foundation; either version 2 of the License, or
6+
# (at your option) any later version.
7+
8+
# See systemd.special(7) for details
9+
10+
[Unit]
11+
Description=Encrypted Volumes
12+
13+
[Install]
14+
WantedBy=local-fs.target

0 commit comments

Comments
 (0)
X Tutup