generators: check the error fopen_unlocked() returns, not errno

The crypttab, integritytab and veritytab generators look at errno after
fopen_unlocked() failed. Since fopen_unlocked() goes through
xopenat_full() errno isn't necessarily set when it fails, e.g. for an
empty $SYSTEMD_CRYPTTAB. Check the returned error instead.

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
(cherry picked from commit d059194685)
(cherry picked from commit 18abd60f3e)
This commit is contained in:
Christian Brauner authored and Luca Boccassi committed 2026-11-05 14:48:10 +00:00
1 parent 7a20d25946
commit b2e1988b7e
3 files changed
+6 -6

No files matched your search

+2 -2
View File
@@ -850,8 +850,8 @@ static int add_crypttab_devices(void) {
r = fopen_unlocked(arg_crypttab, "re", &f);
if (r < 0) {
if (errno != ENOENT)
log_error_errno(errno, "Failed to open %s: %m", arg_crypttab);
if (r != -ENOENT)
log_error_errno(r, "Failed to open %s: %m", arg_crypttab);
return 0;
}
@@ -138,8 +138,8 @@ static int add_integritytab_devices(void) {
r = fopen_unlocked(arg_integritytab, "re", &f);
if (r < 0) {
if (errno != ENOENT)
log_error_errno(errno, "Failed to open %s: %m", arg_integritytab);
if (r != -ENOENT)
log_error_errno(r, "Failed to open %s: %m", arg_integritytab);
return 0;
}
+2 -2
View File
@@ -437,8 +437,8 @@ static int add_veritytab_devices(void) {
r = fopen_unlocked(arg_veritytab, "re", &f);
if (r < 0) {
if (errno != ENOENT)
log_error_errno(errno, "Failed to open %s: %m", arg_veritytab);
if (r != -ENOENT)
log_error_errno(r, "Failed to open %s: %m", arg_veritytab);
return 0;
}