basic/virt: fix userns check on CONFIG_USER_NS=n kernel (#4651)

ENOENT should be treated as "false", but because of the broken errno check it
was treated as an error. So ConditionVirtualization=user-namespaces probably
returned the correct answer, but only by accident.

Fixes #4608.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2016-11-11 10:54:54 -05:00 committed by Evgeny Vereshchagin
parent 110773f6c9
commit abd67ce748

View file

@ -496,7 +496,7 @@ static int userns_has_mapping(const char *name) {
f = fopen(name, "re");
if (!f) {
log_debug_errno(errno, "Failed to open %s: %m", name);
return errno == -ENOENT ? false : -errno;
return errno == ENOENT ? false : -errno;
}
n = getline(&buf, &n_allocated, f);