summaryrefslogtreecommitdiff
path: root/src/journal-remote
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-24 16:58:59 +0900
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-03-24 13:53:04 +0100
commitf7adeaeb897f6d24c50250e2d5fdc9797964b81e (patch)
tree9e5802043ec5f5c8f642c1c9b953f6f163adcfa1 /src/journal-remote
parent7500c6cbef3100c8d05301e6cc096c3e89af87f7 (diff)
downloadsystemd-f7adeaeb897f6d24c50250e2d5fdc9797964b81e.tar.gz
journal-remote: refuse to specify --trust option when gnutls is disabled
and check_permission() should not be called in that case. Replaces #22847.
Diffstat (limited to 'src/journal-remote')
-rw-r--r--src/journal-remote/journal-remote-main.c13
-rw-r--r--src/journal-remote/microhttpd-util.c2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index 13ca22ef26..beb73f3572 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -46,7 +46,11 @@ static const char* arg_output = NULL;
static char *arg_key = NULL;
static char *arg_cert = NULL;
static char *arg_trust = NULL;
+#if HAVE_GNUTLS
static bool arg_trust_all = false;
+#else
+static bool arg_trust_all = true;
+#endif
STATIC_DESTRUCTOR_REGISTER(arg_gnutls_log, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_key, freep);
@@ -931,6 +935,7 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_TRUST:
+#if HAVE_GNUTLS
if (arg_trust || arg_trust_all)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Confusing trusted CA configuration");
@@ -938,16 +943,14 @@ static int parse_argv(int argc, char *argv[]) {
if (streq(optarg, "all"))
arg_trust_all = true;
else {
-#if HAVE_GNUTLS
arg_trust = strdup(optarg);
if (!arg_trust)
return log_oom();
+ }
#else
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Option --trust is not available.");
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Option --trust is not available.");
#endif
- }
-
break;
case 'o':
diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c
index a8119bd687..48e4b1414c 100644
--- a/src/journal-remote/microhttpd-util.c
+++ b/src/journal-remote/microhttpd-util.c
@@ -299,7 +299,7 @@ int check_permissions(struct MHD_Connection *connection, int *code, char **hostn
#else
int check_permissions(struct MHD_Connection *connection, int *code, char **hostname) {
- return -EPERM;
+ assert_not_reached();
}
int setup_gnutls_logger(char **categories) {