container: fix .dockerenv stat check
authorPetr Štetiar <ynezz@true.cz>
Thu, 30 May 2019 05:53:26 +0000 (07:53 +0200)
committerPetr Štetiar <ynezz@true.cz>
Thu, 30 May 2019 05:53:26 +0000 (07:53 +0200)
applied check wasn't evaluating the existence of the file properly.

Fixes: 7f0f6b2a73f8 ("procd: add docker support")
Signed-off-by: Petr Štetiar <ynezz@true.cz>
container.h

index dd2e432adbfc586fd824846d63485b42248fe8a9..903e3e809627170b852c1f9fe541df3087005018 100644 (file)
@@ -20,7 +20,8 @@
 
 static inline bool is_container() {
        struct stat s;
-       return !!getenv("container") || !!stat("/.dockerenv", &s);
+       int r = stat("/.dockerenv", &s);
+       return !!getenv("container") || r == 0;
 }
 
 #endif