summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2016-12-02 09:23:23 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-02 09:23:23 -0500
commitb200489b2b0ebb45be80fc8168be1f0587ae2bcc (patch)
tree13c172bd110ed89688c915329d92c0fbdb8a512c
parent06bf09af67406040806799583cc101271cf0891e (diff)
cgroup: properly check for ignore-notfound paths (#4803)
Follow-up to #4687 and e7330dfe14b1965f.
-rw-r--r--src/core/cgroup.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 6dab6e9043..5789e2aa82 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -287,14 +287,21 @@ static int lookup_block_device(const char *p, dev_t *dev) {
static int whitelist_device(const char *path, const char *node, const char *acc) {
char buf[2+DECIMAL_STR_MAX(dev_t)*2+2+4];
struct stat st;
+ bool ignore_notfound;
int r;
assert(path);
assert(acc);
+ if (node[0] == '-') {
+ /* Non-existent paths starting with "-" must be silently ignored */
+ node++;
+ ignore_notfound = true;
+ } else
+ ignore_notfound = false;
+
if (stat(node, &st) < 0) {
- /* path starting with "-" must be silently ignored */
- if (errno == ENOENT && startswith(node, "-"))
+ if (errno == ENOENT && ignore_notfound)
return 0;
return log_warning_errno(errno, "Couldn't stat device %s: %m", node);