Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmpfiles: don't skip cleanup of read-only root owned files if TMPFILES_AGE_ALL is set (#1533638) #201

Merged
merged 1 commit into from Jun 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
tmpfiles: don't skip cleanup of read-only root owned files if TMPFILE…
…S_AGE_ALL is set

Resolves: #1533638
  • Loading branch information
msekletar committed Jun 1, 2018
commit 5349b65d33560518d464490aa5a1a63e90295dc6
12 changes: 8 additions & 4 deletions src/tmpfiles/tmpfiles.c
Expand Up @@ -367,6 +367,7 @@ static int dir_cleanup(
struct stat s;
usec_t age;
_cleanup_free_ char *sub_path = NULL;
const char *e;

if (STR_IN_SET(dent->d_name, ".", ".."))
continue;
Expand Down Expand Up @@ -399,10 +400,13 @@ static int dir_cleanup(
continue;
}

/* Do not delete read-only files owned by root */
if (s.st_uid == 0 && !(s.st_mode & S_IWUSR)) {
log_debug("Ignoring \"%s/%s\": read-only and owner by root.", p, dent->d_name);
continue;
e = getenv("TMPFILES_AGE_ALL");
if (!e) {
/* Do not delete read-only files owned by root */
if (s.st_uid == 0 && !(s.st_mode & S_IWUSR)) {
log_debug("Ignoring \"%s/%s\": read-only and owner by root.", p, dent->d_name);
continue;
}
}

sub_path = strjoin(p, "/", dent->d_name, NULL);
Expand Down