mirror of
https://github.com/systemd/systemd.git
synced 2025-09-06 05:44:41 +03:00
cgroup: properly check for ignore-notfound paths (#4803)
Follow-up to #4687 and e7330dfe14
.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
06bf09af67
commit
b200489b2b
@@ -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) {
|
static int whitelist_device(const char *path, const char *node, const char *acc) {
|
||||||
char buf[2+DECIMAL_STR_MAX(dev_t)*2+2+4];
|
char buf[2+DECIMAL_STR_MAX(dev_t)*2+2+4];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
bool ignore_notfound;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(path);
|
assert(path);
|
||||||
assert(acc);
|
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) {
|
if (stat(node, &st) < 0) {
|
||||||
/* path starting with "-" must be silently ignored */
|
if (errno == ENOENT && ignore_notfound)
|
||||||
if (errno == ENOENT && startswith(node, "-"))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return log_warning_errno(errno, "Couldn't stat device %s: %m", node);
|
return log_warning_errno(errno, "Couldn't stat device %s: %m", node);
|
||||||
|
Reference in New Issue
Block a user