chiark / gitweb /
journal: drop unnecessary parameters of next_beyond_location()
[elogind.git] / src / journal / journald-server.c
index 3d1947f25ff1c64ffada940bbe3973aabc02df66..a2a2e197c05b75a575e603c5f07cabff29f94e4b 100644 (file)
@@ -212,7 +212,7 @@ void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
 
         acl = acl_get_fd(f->fd);
         if (!acl) {
-                log_warning("Failed to read ACL on %s, ignoring: %m", f->path);
+                log_warning_errno(errno, "Failed to read ACL on %s, ignoring: %m", f->path);
                 return;
         }
 
@@ -222,7 +222,7 @@ void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
                 if (acl_create_entry(&acl, &entry) < 0 ||
                     acl_set_tag_type(entry, ACL_USER) < 0 ||
                     acl_set_qualifier(entry, &uid) < 0) {
-                        log_warning("Failed to patch ACL on %s, ignoring: %m", f->path);
+                        log_warning_errno(errno, "Failed to patch ACL on %s, ignoring: %m", f->path);
                         goto finish;
                 }
         }
@@ -232,12 +232,12 @@ void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
         if (acl_get_permset(entry, &permset) < 0 ||
             acl_add_perm(permset, ACL_READ) < 0 ||
             calc_acl_mask_if_needed(&acl) < 0) {
-                log_warning("Failed to patch ACL on %s, ignoring: %m", f->path);
+                log_warning_errno(errno, "Failed to patch ACL on %s, ignoring: %m", f->path);
                 goto finish;
         }
 
         if (acl_set_fd(f->fd, acl) < 0)
-                log_warning("Failed to set ACL on %s, ignoring: %m", f->path);
+                log_warning_errno(errno, "Failed to set ACL on %s, ignoring: %m", f->path);
 
 finish:
         acl_free(acl);
@@ -811,7 +811,7 @@ static void dispatch_message_real(
                  * realuid is not root, in order not to accidentally
                  * leak privileged information to the user that is
                  * logged by a privileged process that is part of an
-                 * unprivileged session.*/
+                 * unprivileged session. */
                 journal_uid = owner;
         else
                 journal_uid = 0;
@@ -1131,7 +1131,7 @@ int process_datagram(sd_event_source *es, int fd, uint32_t revents, void *userda
                          * the SELinux people this will change and it
                          * will probably be identical to NAME_MAX. For
                          * now we use that, but this should be updated
-                         * one day when the final limit is known.*/
+                         * one day when the final limit is known. */
                         uint8_t buf[CMSG_SPACE(sizeof(struct ucred)) +
                                     CMSG_SPACE(sizeof(struct timeval)) +
                                     CMSG_SPACE(sizeof(int)) + /* fd */
@@ -1158,7 +1158,7 @@ int process_datagram(sd_event_source *es, int fd, uint32_t revents, void *userda
                  * don't rely on it. */
                 (void) ioctl(fd, SIOCINQ, &v);
 
-                /* Fix it up, if it is too small. We use the same fixed value as auditd here. Awful!*/
+                /* Fix it up, if it is too small. We use the same fixed value as auditd here. Awful! */
                 m = PAGE_ALIGN(MAX3((size_t) v + 1,
                                     (size_t) LINE_MAX,
                                     ALIGN(sizeof(struct nlmsghdr)) + ALIGN((size_t) MAX_AUDIT_MESSAGE_LENGTH)) + 1);
@@ -1174,7 +1174,7 @@ int process_datagram(sd_event_source *es, int fd, uint32_t revents, void *userda
                         if (errno == EINTR || errno == EAGAIN)
                                 return 0;
 
-                        log_error("recvmsg() failed: %m");
+                        log_error_errno(errno, "recvmsg() failed: %m");
                         return -errno;
                 }
 
@@ -1351,10 +1351,11 @@ static int server_parse_proc_cmdline(Server *s) {
 static int server_parse_config_file(Server *s) {
         assert(s);
 
-        return config_parse(NULL, "/etc/systemd/journald.conf", NULL,
-                            "Journal\0",
-                            config_item_perf_lookup, journald_gperf_lookup,
-                            false, false, true, s);
+        return config_parse_many("/etc/systemd/journald.conf",
+                                 CONF_DIRS_NULSTR("systemd/journald.conf"),
+                                 "Journal\0",
+                                 config_item_perf_lookup, journald_gperf_lookup,
+                                 false, s);
 }
 
 static int server_dispatch_sync(sd_event_source *es, usec_t t, void *userdata) {
@@ -1431,10 +1432,8 @@ static int server_open_hostname(Server *s) {
         assert(s);
 
         s->hostname_fd = open("/proc/sys/kernel/hostname", O_RDONLY|O_CLOEXEC|O_NDELAY|O_NOCTTY);
-        if (s->hostname_fd < 0) {
-                log_error("Failed to open /proc/sys/kernel/hostname: %m");
-                return -errno;
-        }
+        if (s->hostname_fd < 0)
+                return log_error_errno(errno, "Failed to open /proc/sys/kernel/hostname: %m");
 
         r = sd_event_add_io(s->event, &s->hostname_event_source, s->hostname_fd, 0, dispatch_hostname_change, s);
         if (r < 0) {
@@ -1553,8 +1552,16 @@ int server_init(Server *s) {
 
                         s->audit_fd = fd;
 
-                } else
-                        log_error("Unknown socket passed as file descriptor %d, ignoring.", fd);
+                } else {
+                        log_warning("Unknown socket passed as file descriptor %d, ignoring.", fd);
+
+                        /* Let's close the fd, better be safe than
+                           sorry. The fd might reference some resource
+                           that we really want to release if we don't
+                           make use of it. */
+
+                        safe_close(fd);
+                }
         }
 
         r = server_open_syslog_socket(s);