diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-12-17 01:13:55 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-12-17 01:13:55 +0100 |
commit | cab8ac60837b489b27a247990f741315c71cb389 (patch) | |
tree | c5eb0e242f349e0d61f8cd92c7e85e12049e2b90 /src/journal/journald.c | |
parent | 7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49e (diff) |
journal: enforce limits on open journal files
Diffstat (limited to 'src/journal/journald.c')
-rw-r--r-- | src/journal/journald.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/journal/journald.c b/src/journal/journald.c index 453495a964..6b774f499d 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -38,6 +38,8 @@ #include "acl-util.h" #include "cgroup-util.h" +#define USER_JOURNALS_MAX 1024 + typedef struct Server { int epoll_fd; int signal_fd; @@ -127,6 +129,13 @@ static JournalFile* find_journal(Server *s, uid_t uid) { if (asprintf(&p, "/var/log/journal/%s/user-%lu.journal", sd_id128_to_string(machine, ids), (unsigned long) uid) < 0) return s->system_journal; + while (hashmap_size(s->user_journals) >= USER_JOURNALS_MAX) { + /* Too many open? Then let's close one */ + f = hashmap_steal_first(s->user_journals); + assert(f); + journal_file_close(f); + } + r = journal_file_open(p, O_RDWR|O_CREAT, 0640, s->system_journal, &f); free(p); |