]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-remote: refuse to specify --trust option when gnutls is disabled
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 24 Mar 2022 07:58:59 +0000 (16:58 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 24 Mar 2022 12:53:04 +0000 (13:53 +0100)
and check_permission() should not be called in that case.

Replaces #22847.

src/journal-remote/journal-remote-main.c
src/journal-remote/microhttpd-util.c

index 13ca22ef268a19ff1d3eac5364c5acfc76536aaa..beb73f3572c1c89a245edc89fa562dd9e01e19cd 100644 (file)
@@ -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':
index a8119bd687a1c6e3f130ea30404ab9828bc0e601..48e4b1414cb38a2a20f849ce72094ae8b97b5c33 100644 (file)
@@ -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) {