Detect file truncation earlier in a few places

Users of read_one_line_file() for APIVFS entries are ignored as they are
assumed to never get truncated.
This commit is contained in:
Topi Miettinen
2019-02-02 16:25:32 +02:00
parent cbed254f96
commit a21760454d
3 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -469,11 +469,11 @@ int detect_container(void) {
/* Otherwise, PID 1 might have dropped this information into a file in /run. This is better than accessing
* /proc/1/environ, since we don't need CAP_SYS_PTRACE for that. */
r = read_one_line_file("/run/systemd/container", &m);
if (r >= 0) {
if (r > 0) {
e = m;
goto translate_name;
}
if (r != -ENOENT)
if (!IN_SET(r, -ENOENT, 0))
return log_debug_errno(r, "Failed to read /run/systemd/container: %m");
/* Fallback for cases where PID 1 was not systemd (for example, cases where init=/bin/sh is used. */