journald: constify all things!

This commit is contained in:
Lennart Poettering 2014-11-02 21:46:42 +01:00
parent f49481d0ca
commit 3b3154df7e
12 changed files with 30 additions and 34 deletions

View File

@ -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];

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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,

View File

@ -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 */

View File

@ -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");

View File

@ -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);

View File

@ -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;

View File

@ -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);