DIR *sub_dir;
int q;
- sub_dir = xopendirat(dirfd(d), dent->d_name);
+ sub_dir = xopendirat(dirfd(d), dent->d_name, O_NOFOLLOW);
if (sub_dir == NULL) {
if (errno != ENOENT) {
log_error("opendir(%s/%s) failed: %m", p, dent->d_name);
}
} else {
+ /* Skip files for which the sticky bit is
+ * set. These are semantics we define, and are
+ * unknown elsewhere. See XDG_RUNTIME_DIR
+ * specification for details. */
+ if (s.st_mode & S_ISVTX)
+ continue;
+
if (mountpoint) {
if (streq(dent->d_name, ".journal") &&
s.st_uid == 0)
static int parse_line(const char *fname, unsigned line, const char *buffer, const char *prefix) {
Item *i;
char *mode = NULL, *user = NULL, *group = NULL, *age = NULL;
- int r, n;
+ int r;
assert(fname);
assert(line >= 1);
return -ENOMEM;
}
- if ((n = sscanf(buffer,
- "%c "
- "%ms "
- "%ms "
- "%ms "
- "%ms "
- "%ms",
- &i->type,
- &i->path,
- &mode,
- &user,
- &group,
- &age)) < 2) {
+ if (sscanf(buffer,
+ "%c "
+ "%ms "
+ "%ms "
+ "%ms "
+ "%ms "
+ "%ms",
+ &i->type,
+ &i->path,
+ &mode,
+ &user,
+ &group,
+ &age) < 2) {
log_error("[%s:%u] Syntax error.", fname, line);
r = -EIO;
goto finish;
}
if (i->type != CREATE_FILE &&
- i->type != CREATE_DIRECTORY &&
i->type != TRUNCATE_FILE &&
+ i->type != CREATE_DIRECTORY &&
+ i->type != TRUNCATE_DIRECTORY &&
i->type != IGNORE_PATH &&
i->type != REMOVE_PATH &&
i->type != RECURSIVE_REMOVE_PATH) {
}
if ((r = hashmap_put(items, i->path, i)) < 0) {
+ if (r == -EEXIST) {
+ log_warning("Two or more conflicting lines for %s configured, ignoring.", i->path);
+ r = 0;
+ goto finish;
+ }
+
log_error("Failed to insert item %s: %s", i->path, strerror(-r));
goto finish;
}
hashmap_free(items);
+ label_finish();
+
return r;
}