#include "acl-util.h"
#include "cgroup-util.h"
+#define USER_JOURNALS_MAX 1024
+
typedef struct Server {
int epoll_fd;
int signal_fd;
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);
q = memchr(p, '=', e - p);
if (q) {
- iovec[n].iov_base = (char*) p;
- iovec[n].iov_len = e - p;
- n++;
+ if (p[0] != '_') {
+ /* If the field name starts with an
+ * underscore, skip the variable,
+ * since that indidates a trusted
+ * field */
+ iovec[n].iov_base = (char*) p;
+ iovec[n].iov_len = e - p;
+ n++;
+ }
remaining -= (e - p) + 1;
p = e + 1;
k[e - p] = '=';
memcpy(k + (e - p) + 1, e + 1 + sizeof(uint64_t), l);
- iovec[n].iov_base = k;
- iovec[n].iov_len = (e - p) + 1 + l;
- n++;
+ if (k[0] != '_') {
+ iovec[n].iov_base = k;
+ iovec[n].iov_len = (e - p) + 1 + l;
+ n++;
+ } else
+ free(k);
remaining -= (e - p) + 1 + sizeof(uint64_t) + l + 1;
p = e + 1 + sizeof(uint64_t) + l + 1;