journal-file: refuse opening non-regular journal files

Let's check the file node type when we open/stat journal files: refuse
anything that is not a regular file...
This commit is contained in:
Lennart Poettering
2018-02-20 12:53:10 +01:00
parent 00f5ad93b5
commit 8d6a4d33e1
2 changed files with 10 additions and 0 deletions
+6
View File
@@ -651,6 +651,12 @@ static int journal_file_fstat(JournalFile *f) {
f->last_stat_usec = now(CLOCK_MONOTONIC);
/* Refuse dealing with with files that aren't regular */
if (S_ISDIR(f->last_stat.st_mode))
return -EISDIR;
if (!S_ISREG(f->last_stat.st_mode))
return -EBADFD;
/* Refuse appending to files that are already deleted */
if (f->last_stat.st_nlink <= 0)
return -EIDRM;
+4
View File
@@ -2016,6 +2016,10 @@ _public_ int sd_journal_open_files_fd(sd_journal **ret, int fds[], unsigned n_fd
goto fail;
}
if (S_ISDIR(st.st_mode)) {
r = -EISDIR;
goto fail;
}
if (!S_ISREG(st.st_mode)) {
r = -EBADFD;
goto fail;