summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-02 21:46:42 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-03 21:51:28 +0100
commit3b3154df7e2773332bb814e167187367a0ccae4a (patch)
treea3c34ce14c37180f242243249a91b1031fa322f9 /src
parentf49481d0ca170ea567b46fde6c1c089b1dbb49cb (diff)
journald: constify all things!
Diffstat (limited to 'src')
-rw-r--r--src/journal/journald-console.c2
-rw-r--r--src/journal/journald-console.h2
-rw-r--r--src/journal/journald-kmsg.c4
-rw-r--r--src/journal/journald-kmsg.h2
-rw-r--r--src/journal/journald-native.c16
-rw-r--r--src/journal/journald-native.h4
-rw-r--r--src/journal/journald-server.c8
-rw-r--r--src/journal/journald-server.h2
-rw-r--r--src/journal/journald-syslog.c16
-rw-r--r--src/journal/journald-syslog.h4
-rw-r--r--src/journal/journald-wall.c2
-rw-r--r--src/journal/journald-wall.h2
12 files changed, 30 insertions, 34 deletions
diff --git a/src/journal/journald-console.c b/src/journal/journald-console.c
index 6ec2528d74..19d077a126 100644
--- a/src/journal/journald-console.c
+++ b/src/journal/journald-console.c
@@ -48,7 +48,7 @@ void server_forward_console(
int priority,
const char *identifier,
const char *message,
- struct ucred *ucred) {
+ const struct ucred *ucred) {
struct iovec iovec[5];
char header_pid[16];
diff --git a/src/journal/journald-console.h b/src/journal/journald-console.h
index aa8e6579ba..d8af2267e1 100644
--- a/src/journal/journald-console.h
+++ b/src/journal/journald-console.h
@@ -23,4 +23,4 @@
#include "journald-server.h"
-void server_forward_console(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred);
+void server_forward_console(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred);
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index fb8ea08e31..126126b887 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -37,7 +37,7 @@ void server_forward_kmsg(
int priority,
const char *identifier,
const char *message,
- struct ucred *ucred) {
+ const struct ucred *ucred) {
struct iovec iovec[5];
char header_priority[6], header_pid[16];
@@ -104,7 +104,7 @@ static bool is_us(const char *pid) {
return t == getpid();
}
-static void dev_kmsg_record(Server *s, char *p, size_t l) {
+static void dev_kmsg_record(Server *s, const char *p, size_t l) {
struct iovec iovec[N_IOVEC_META_FIELDS + 7 + N_IOVEC_KERNEL_FIELDS + 2 + N_IOVEC_UDEV_FIELDS];
char *message = NULL, *syslog_priority = NULL, *syslog_pid = NULL, *syslog_facility = NULL, *syslog_identifier = NULL, *source_time = NULL;
int priority, r;
diff --git a/src/journal/journald-kmsg.h b/src/journal/journald-kmsg.h
index f60f605572..9a9d089967 100644
--- a/src/journal/journald-kmsg.h
+++ b/src/journal/journald-kmsg.h
@@ -26,6 +26,6 @@
int server_open_dev_kmsg(Server *s);
int server_flush_dev_kmsg(Server *s);
-void server_forward_kmsg(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred);
+void server_forward_kmsg(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred);
int server_open_kernel_seqnum(Server *s);
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index ace8d5cbfd..3c60b22eaf 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -70,15 +70,15 @@ bool valid_user_field(const char *p, size_t l, bool allow_protected) {
return true;
}
-static bool allow_object_pid(struct ucred *ucred) {
+static bool allow_object_pid(const struct ucred *ucred) {
return ucred && ucred->uid == 0;
}
void server_process_native_message(
Server *s,
const void *buffer, size_t buffer_size,
- struct ucred *ucred,
- struct timeval *tv,
+ const struct ucred *ucred,
+ const struct timeval *tv,
const char *label, size_t label_len) {
struct iovec *iovec = NULL;
@@ -303,8 +303,8 @@ finish:
void server_process_native_file(
Server *s,
int fd,
- struct ucred *ucred,
- struct timeval *tv,
+ const struct ucred *ucred,
+ const struct timeval *tv,
const char *label, size_t label_len) {
struct stat st;
@@ -412,7 +412,8 @@ void server_process_native_file(
}
int server_open_native_socket(Server*s) {
- int one, r;
+ static const int one = 1;
+ int r;
assert(s);
@@ -440,7 +441,6 @@ int server_open_native_socket(Server*s) {
} else
fd_nonblock(s->native_fd, 1);
- one = 1;
r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
if (r < 0) {
log_error("SO_PASSCRED failed: %m");
@@ -449,14 +449,12 @@ int server_open_native_socket(Server*s) {
#ifdef HAVE_SELINUX
if (mac_selinux_use()) {
- one = 1;
r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one));
if (r < 0)
log_warning("SO_PASSSEC failed: %m");
}
#endif
- one = 1;
r = setsockopt(s->native_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
if (r < 0) {
log_error("SO_TIMESTAMP failed: %m");
diff --git a/src/journal/journald-native.h b/src/journal/journald-native.h
index e82a5b87d5..2f9d458fb5 100644
--- a/src/journal/journald-native.h
+++ b/src/journal/journald-native.h
@@ -30,8 +30,8 @@
bool valid_user_field(const char *p, size_t l, bool allow_protected);
-void server_process_native_message(Server *s, const void *buffer, size_t buffer_size, struct ucred *ucred, struct timeval *tv, const char *label, size_t label_len);
+void server_process_native_message(Server *s, const void *buffer, size_t buffer_size, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len);
-void server_process_native_file(Server *s, int fd, struct ucred *ucred, struct timeval *tv, const char *label, size_t label_len);
+void server_process_native_file(Server *s, int fd, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len);
int server_open_native_socket(Server*s);
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 12735c4b81..ac6dc3660f 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -537,8 +537,8 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
static void dispatch_message_real(
Server *s,
struct iovec *iovec, unsigned n, unsigned m,
- struct ucred *ucred,
- struct timeval *tv,
+ const struct ucred *ucred,
+ const struct timeval *tv,
const char *label, size_t label_len,
const char *unit_id,
int priority,
@@ -855,8 +855,8 @@ void server_driver_message(Server *s, sd_id128_t message_id, const char *format,
void server_dispatch_message(
Server *s,
struct iovec *iovec, unsigned n, unsigned m,
- struct ucred *ucred,
- struct timeval *tv,
+ const struct ucred *ucred,
+ const struct timeval *tv,
const char *label, size_t label_len,
const char *unit_id,
int priority,
diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
index 6888187df9..65a2b71a7f 100644
--- a/src/journal/journald-server.h
+++ b/src/journal/journald-server.h
@@ -148,7 +148,7 @@ typedef struct Server {
#define N_IOVEC_UDEV_FIELDS 32
#define N_IOVEC_OBJECT_FIELDS 11
-void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigned m, struct ucred *ucred, struct timeval *tv, const char *label, size_t label_len, const char *unit_id, int priority, pid_t object_pid);
+void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigned m, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len, const char *unit_id, int priority, pid_t object_pid);
void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) _printf_(3,4);
/* gperf lookup function */
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index 79c07fffa1..4725031086 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -35,7 +35,7 @@
/* Warn once every 30s if we missed syslog message */
#define WARN_FORWARD_SYSLOG_MISSED_USEC (30 * USEC_PER_SEC)
-static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned n_iovec, struct ucred *ucred, struct timeval *tv) {
+static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned n_iovec, const struct ucred *ucred, const struct timeval *tv) {
static const union sockaddr_union sa = {
.un.sun_family = AF_UNIX,
@@ -109,7 +109,7 @@ static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned
log_debug("Failed to forward syslog message: %m");
}
-static void forward_syslog_raw(Server *s, int priority, const char *buffer, struct ucred *ucred, struct timeval *tv) {
+static void forward_syslog_raw(Server *s, int priority, const char *buffer, const struct ucred *ucred, const struct timeval *tv) {
struct iovec iovec;
assert(s);
@@ -122,7 +122,7 @@ static void forward_syslog_raw(Server *s, int priority, const char *buffer, stru
forward_syslog_iovec(s, &iovec, 1, ucred, tv);
}
-void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred, struct timeval *tv) {
+void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred, const struct timeval *tv) {
struct iovec iovec[5];
char header_priority[6], header_time[64], header_pid[16];
int n = 0;
@@ -351,8 +351,8 @@ static void syslog_skip_date(char **buf) {
void server_process_syslog_message(
Server *s,
const char *buf,
- struct ucred *ucred,
- struct timeval *tv,
+ const struct ucred *ucred,
+ const struct timeval *tv,
const char *label,
size_t label_len) {
@@ -421,7 +421,8 @@ void server_process_syslog_message(
}
int server_open_syslog_socket(Server *s) {
- int one, r;
+ static const int one = 1;
+ int r;
assert(s);
@@ -449,7 +450,6 @@ int server_open_syslog_socket(Server *s) {
} else
fd_nonblock(s->syslog_fd, 1);
- one = 1;
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
if (r < 0) {
log_error("SO_PASSCRED failed: %m");
@@ -458,14 +458,12 @@ int server_open_syslog_socket(Server *s) {
#ifdef HAVE_SELINUX
if (mac_selinux_use()) {
- one = 1;
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one));
if (r < 0)
log_warning("SO_PASSSEC failed: %m");
}
#endif
- one = 1;
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
if (r < 0) {
log_error("SO_TIMESTAMP failed: %m");
diff --git a/src/journal/journald-syslog.h b/src/journal/journald-syslog.h
index 057ea79def..25f89883f4 100644
--- a/src/journal/journald-syslog.h
+++ b/src/journal/journald-syslog.h
@@ -28,9 +28,9 @@ int syslog_fixup_facility(int priority) _const_;
void syslog_parse_priority(const char **p, int *priority, bool with_facility);
size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid);
-void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred, struct timeval *tv);
+void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred, const struct timeval *tv);
-void server_process_syslog_message(Server *s, const char *buf, struct ucred *ucred, struct timeval *tv, const char *label, size_t label_len);
+void server_process_syslog_message(Server *s, const char *buf, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len);
int server_open_syslog_socket(Server *s);
void server_maybe_warn_forward_syslog_missed(Server *s);
diff --git a/src/journal/journald-wall.c b/src/journal/journald-wall.c
index fcbd9183fe..1bdddb0db3 100644
--- a/src/journal/journald-wall.c
+++ b/src/journal/journald-wall.c
@@ -28,7 +28,7 @@ void server_forward_wall(
int priority,
const char *identifier,
const char *message,
- struct ucred *ucred) {
+ const struct ucred *ucred) {
_cleanup_free_ char *ident_buf = NULL, *l_buf = NULL;
const char *l;
diff --git a/src/journal/journald-wall.h b/src/journal/journald-wall.h
index 93c3cec1d2..45c52854a0 100644
--- a/src/journal/journald-wall.h
+++ b/src/journal/journald-wall.h
@@ -23,4 +23,4 @@
#include "journald-server.h"
-void server_forward_wall(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred);
+void server_forward_wall(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred);