summaryrefslogtreecommitdiff
path: root/src/cryptsetup
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-08-21 10:45:42 +0200
committerLennart Poettering <lennart@poettering.net>2019-11-19 15:34:09 +0100
commit9120aa820b30ecdcfb7473708eaf420cc439bff5 (patch)
treeee1c26576d1ac5d0aef7d390af83297f0beef24c /src/cryptsetup
parent9c5253ffecb602b3eeb9b9fd0f42f8e757fd3ed8 (diff)
downloadsystemd-9120aa820b30ecdcfb7473708eaf420cc439bff5.tar.gz
cryptsetup: use STR_IN_SET() where appropriate
Note that this slightly changes behaviour: "none" is only allowed as option, if it's the only option specified, but not in combination with other options. I think this makes more sense, since it's the choice when no options shall be specified.
Diffstat (limited to 'src/cryptsetup')
-rw-r--r--src/cryptsetup/cryptsetup.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index f993a5f66b..553b1afb47 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -228,7 +228,7 @@ static int parse_one_option(const char *option) {
if (r < 0)
return log_error_errno(r, "Failed to parse %s: %m", option);
- } else if (!streq(option, "none"))
+ } else
log_warning("Encountered unknown /etc/crypttab option '%s', ignoring.", option);
return 0;
@@ -635,18 +635,14 @@ static int run(int argc, char *argv[]) {
if (argc < 4)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "attach requires at least two arguments.");
- if (argc >= 5 &&
- argv[4][0] &&
- !streq(argv[4], "-") &&
- !streq(argv[4], "none")) {
-
- if (!path_is_absolute(argv[4]))
- log_warning("Password file path '%s' is not absolute. Ignoring.", argv[4]);
- else
+ if (argc >= 5 && !STR_IN_SET(argv[4], "", "-", "none")) {
+ if (path_is_absolute(argv[4]))
key_file = argv[4];
+ else
+ log_warning("Password file path '%s' is not absolute. Ignoring.", argv[4]);
}
- if (argc >= 6 && argv[5][0] && !streq(argv[5], "-")) {
+ if (argc >= 6 && !STR_IN_SET(argv[5], "", "-", "none")) {
r = parse_options(argv[5]);
if (r < 0)
return r;