chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
macro: document that DECIMAL_STR_MAX contains space for the trailing NUL byte
[elogind.git]
/
src
/
journal-remote
/
journal-gatewayd.c
diff --git
a/src/journal-remote/journal-gatewayd.c
b/src/journal-remote/journal-gatewayd.c
index d39a2cc67e61d53d8b643957547c8b90f0149f49..576f7cae7d302181f6e721ccc2fe4b4da8cec5fe 100644
(file)
--- a/
src/journal-remote/journal-gatewayd.c
+++ b/
src/journal-remote/journal-gatewayd.c
@@
-31,20
+31,21
@@
#include <gnutls/gnutls.h>
#endif
#include <gnutls/gnutls.h>
#endif
-#include "log.h"
-#include "util.h"
#include "sd-journal.h"
#include "sd-daemon.h"
#include "sd-bus.h"
#include "sd-journal.h"
#include "sd-daemon.h"
#include "sd-bus.h"
+#include "log.h"
+#include "util.h"
#include "bus-util.h"
#include "logs-show.h"
#include "microhttpd-util.h"
#include "build.h"
#include "fileio.h"
#include "bus-util.h"
#include "logs-show.h"
#include "microhttpd-util.h"
#include "build.h"
#include "fileio.h"
+#include "sigbus.h"
-static char *key_pem = NULL;
-static char *cert_pem = NULL;
-static char *trust_pem = NULL;
+static char *
arg_
key_pem = NULL;
+static char *
arg_
cert_pem = NULL;
+static char *
arg_
trust_pem = NULL;
typedef struct RequestMeta {
sd_journal *journal;
typedef struct RequestMeta {
sd_journal *journal;
@@
-198,7
+199,7
@@
static ssize_t request_reader_entries(
else {
m->tmp = tmpfile();
if (!m->tmp) {
else {
m->tmp = tmpfile();
if (!m->tmp) {
- log_error
(
"Failed to create temporary file: %m");
+ log_error
_errno(errno,
"Failed to create temporary file: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
}
return MHD_CONTENT_READER_END_WITH_ERROR;
}
}
@@
-211,7
+212,7
@@
static ssize_t request_reader_entries(
sz = ftello(m->tmp);
if (sz == (off_t) -1) {
sz = ftello(m->tmp);
if (sz == (off_t) -1) {
- log_error
(
"Failed to retrieve file position: %m");
+ log_error
_errno(errno,
"Failed to retrieve file position: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@
-219,7
+220,7
@@
static ssize_t request_reader_entries(
}
if (fseeko(m->tmp, pos, SEEK_SET) < 0) {
}
if (fseeko(m->tmp, pos, SEEK_SET) < 0) {
- log_error
(
"Failed to seek to position: %m");
+ log_error
_errno(errno,
"Failed to seek to position: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@
-559,7
+560,7
@@
static ssize_t request_reader_fields(
else {
m->tmp = tmpfile();
if (!m->tmp) {
else {
m->tmp = tmpfile();
if (!m->tmp) {
- log_error
(
"Failed to create temporary file: %m");
+ log_error
_errno(errno,
"Failed to create temporary file: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
}
return MHD_CONTENT_READER_END_WITH_ERROR;
}
}
@@
-572,7
+573,7
@@
static ssize_t request_reader_fields(
sz = ftello(m->tmp);
if (sz == (off_t) -1) {
sz = ftello(m->tmp);
if (sz == (off_t) -1) {
- log_error
(
"Failed to retrieve file position: %m");
+ log_error
_errno(errno,
"Failed to retrieve file position: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@
-580,7
+581,7
@@
static ssize_t request_reader_fields(
}
if (fseeko(m->tmp, pos, SEEK_SET) < 0) {
}
if (fseeko(m->tmp, pos, SEEK_SET) < 0) {
- log_error
(
"Failed to seek to position: %m");
+ log_error
_errno(errno,
"Failed to seek to position: %m");
return MHD_CONTENT_READER_END_WITH_ERROR;
}
return MHD_CONTENT_READER_END_WITH_ERROR;
}
@@
-833,7
+834,7
@@
static int request_handler(
return MHD_YES;
}
return MHD_YES;
}
- if (trust_pem) {
+ if (
arg_
trust_pem) {
r = check_permissions(connection, &code, NULL);
if (r < 0)
return code;
r = check_permissions(connection, &code, NULL);
if (r < 0)
return code;
@@
-904,37
+905,37
@@
static int parse_argv(int argc, char *argv[]) {
return 0;
case ARG_KEY:
return 0;
case ARG_KEY:
- if (key_pem) {
+ if (
arg_
key_pem) {
log_error("Key file specified twice");
return -EINVAL;
}
log_error("Key file specified twice");
return -EINVAL;
}
- r = read_full_file(optarg, &key_pem, NULL);
+ r = read_full_file(optarg, &
arg_
key_pem, NULL);
if (r < 0)
return log_error_errno(r, "Failed to read key file: %m");
if (r < 0)
return log_error_errno(r, "Failed to read key file: %m");
- assert(key_pem);
+ assert(
arg_
key_pem);
break;
case ARG_CERT:
break;
case ARG_CERT:
- if (cert_pem) {
+ if (
arg_
cert_pem) {
log_error("Certificate file specified twice");
return -EINVAL;
}
log_error("Certificate file specified twice");
return -EINVAL;
}
- r = read_full_file(optarg, &cert_pem, NULL);
+ r = read_full_file(optarg, &
arg_
cert_pem, NULL);
if (r < 0)
return log_error_errno(r, "Failed to read certificate file: %m");
if (r < 0)
return log_error_errno(r, "Failed to read certificate file: %m");
- assert(cert_pem);
+ assert(
arg_
cert_pem);
break;
case ARG_TRUST:
#ifdef HAVE_GNUTLS
break;
case ARG_TRUST:
#ifdef HAVE_GNUTLS
- if (trust_pem) {
+ if (
arg_
trust_pem) {
log_error("CA certificate file specified twice");
return -EINVAL;
}
log_error("CA certificate file specified twice");
return -EINVAL;
}
- r = read_full_file(optarg, &trust_pem, NULL);
+ r = read_full_file(optarg, &
arg_
trust_pem, NULL);
if (r < 0)
return log_error_errno(r, "Failed to read CA certificate file: %m");
if (r < 0)
return log_error_errno(r, "Failed to read CA certificate file: %m");
- assert(trust_pem);
+ assert(
arg_
trust_pem);
break;
#else
log_error("Option --trust is not available.");
break;
#else
log_error("Option --trust is not available.");
@@
-952,12
+953,12
@@
static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
return -EINVAL;
}
- if (!!
key_pem != !!
cert_pem) {
+ if (!!
arg_key_pem != !!arg_
cert_pem) {
log_error("Certificate and key files must be specified together");
return -EINVAL;
}
log_error("Certificate and key files must be specified together");
return -EINVAL;
}
- if (
trust_pem && !
key_pem) {
+ if (
arg_trust_pem && !arg_
key_pem) {
log_error("CA certificate can only be used with certificate file");
return -EINVAL;
}
log_error("CA certificate can only be used with certificate file");
return -EINVAL;
}
@@
-979,6
+980,8
@@
int main(int argc, char *argv[]) {
if (r == 0)
return EXIT_SUCCESS;
if (r == 0)
return EXIT_SUCCESS;
+ sigbus_install();
+
#ifdef HAVE_GNUTLS
gnutls_global_set_log_function(log_func_gnutls);
log_reset_gnutls_level();
#ifdef HAVE_GNUTLS
gnutls_global_set_log_function(log_func_gnutls);
log_reset_gnutls_level();
@@
-1008,18
+1011,18
@@
int main(int argc, char *argv[]) {
if (n > 0)
opts[opts_pos++] = (struct MHD_OptionItem)
{MHD_OPTION_LISTEN_SOCKET, SD_LISTEN_FDS_START};
if (n > 0)
opts[opts_pos++] = (struct MHD_OptionItem)
{MHD_OPTION_LISTEN_SOCKET, SD_LISTEN_FDS_START};
- if (key_pem) {
- assert(cert_pem);
+ if (
arg_
key_pem) {
+ assert(
arg_
cert_pem);
opts[opts_pos++] = (struct MHD_OptionItem)
opts[opts_pos++] = (struct MHD_OptionItem)
- {MHD_OPTION_HTTPS_MEM_KEY, 0, key_pem};
+ {MHD_OPTION_HTTPS_MEM_KEY, 0,
arg_
key_pem};
opts[opts_pos++] = (struct MHD_OptionItem)
opts[opts_pos++] = (struct MHD_OptionItem)
- {MHD_OPTION_HTTPS_MEM_CERT, 0, cert_pem};
+ {MHD_OPTION_HTTPS_MEM_CERT, 0,
arg_
cert_pem};
flags |= MHD_USE_SSL;
}
flags |= MHD_USE_SSL;
}
- if (trust_pem) {
+ if (
arg_
trust_pem) {
assert(flags & MHD_USE_SSL);
opts[opts_pos++] = (struct MHD_OptionItem)
assert(flags & MHD_USE_SSL);
opts[opts_pos++] = (struct MHD_OptionItem)
- {MHD_OPTION_HTTPS_MEM_TRUST, 0, trust_pem};
+ {MHD_OPTION_HTTPS_MEM_TRUST, 0,
arg_
trust_pem};
}
d = MHD_start_daemon(flags, 19531,
}
d = MHD_start_daemon(flags, 19531,