chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cgroup: honour sticky bit when trimming cgroup trees
[elogind.git]
/
src
/
cryptsetup-generator.c
diff --git
a/src/cryptsetup-generator.c
b/src/cryptsetup-generator.c
index 858aed82d16cbf1c7d4ef1a0b7bc334be375f969..a340218fda0d177bb1b2811bac3a075ca609ebe8 100644
(file)
--- a/
src/cryptsetup-generator.c
+++ b/
src/cryptsetup-generator.c
@@
-47,7
+47,7
@@
static bool has_option(const char *haystack, const char *needle) {
continue;
}
continue;
}
- if (f[l] != 0 && f[l]
=
= ',') {
+ if (f[l] != 0 && f[l]
!
= ',') {
f++;
continue;
}
f++;
continue;
}
@@
-67,10
+67,14
@@
static int create_disk(
char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *from = NULL, *to = NULL, *e = NULL;
int r;
FILE *f = NULL;
char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *from = NULL, *to = NULL, *e = NULL;
int r;
FILE *f = NULL;
+ bool noauto, nofail;
assert(name);
assert(device);
assert(name);
assert(device);
+ noauto = has_option(options, "noauto");
+ nofail = has_option(options, "nofail");
+
if (!(n = unit_name_build_escape("cryptsetup", name, ".service"))) {
r = -ENOMEM;
log_error("Failed to allocate unit name.");
if (!(n = unit_name_build_escape("cryptsetup", name, ".service"))) {
r = -ENOMEM;
log_error("Failed to allocate unit name.");
@@
-104,12
+108,17
@@
static int create_disk(
fprintf(f,
"[Unit]\n"
"Description=Cryptography Setup for %%I\n"
fprintf(f,
"[Unit]\n"
"Description=Cryptography Setup for %%I\n"
+ "Conflicts=umount.target\n"
"DefaultDependencies=no\n"
"BindTo=%s dev-mapper-%%i.device\n"
"After=systemd-readahead-collect.service systemd-readahead-replay.service %s\n"
"DefaultDependencies=no\n"
"BindTo=%s dev-mapper-%%i.device\n"
"After=systemd-readahead-collect.service systemd-readahead-replay.service %s\n"
- "Before=
shutdown.target cryptsetup
.target\n",
+ "Before=
umount
.target\n",
d, d);
d, d);
+ if (!nofail)
+ fprintf(f,
+ "Before=cryptsetup.target\n");
+
if (password && (streq(password, "/dev/urandom") ||
streq(password, "/dev/random") ||
streq(password, "/dev/hw_random")))
if (password && (streq(password, "/dev/urandom") ||
streq(password, "/dev/random") ||
streq(password, "/dev/hw_random")))
@@
-149,7
+158,7
@@
static int create_disk(
goto fail;
}
goto fail;
}
- if (!
has_option(options, "noauto")
) {
+ if (!
noauto
) {
if (asprintf(&to, "%s/%s.wants/%s", arg_dest, d, n) < 0) {
r = -ENOMEM;
if (asprintf(&to, "%s/%s.wants/%s", arg_dest, d, n) < 0) {
r = -ENOMEM;
@@
-167,20
+176,22
@@
static int create_disk(
free(to);
to = NULL;
free(to);
to = NULL;
- if (!has_option(options, "nofail")) {
+ if (!nofail)
+ asprintf(&to, "%s/cryptsetup.target.requires/%s", arg_dest, n);
+ else
+ asprintf(&to, "%s/cryptsetup.target.wants/%s", arg_dest, n);
-
if (asprintf(&to, "%s/cryptsetup.target.wants/%s", arg_dest, n) < 0
) {
-
r = -ENOMEM;
-
goto fail;
-
}
+
if (!to
) {
+ r = -ENOMEM;
+ goto fail;
+ }
-
mkdir_parents(to, 0755);
+ mkdir_parents(to, 0755);
- if (symlink(from, to) < 0) {
- log_error("Failed to create symlink '%s' to '%s': %m", from, to);
- r = -errno;
- goto fail;
- }
+ if (symlink(from, to) < 0) {
+ log_error("Failed to create symlink '%s' to '%s': %m", from, to);
+ r = -errno;
+ goto fail;
}
}
}
}
@@
-235,6
+246,8
@@
int main(int argc, char *argv[]) {
log_parse_environment();
log_open();
log_parse_environment();
log_open();
+ umask(0022);
+
if (!(f = fopen("/etc/crypttab", "re"))) {
if (errno == ENOENT)
if (!(f = fopen("/etc/crypttab", "re"))) {
if (errno == ENOENT)