chiark / gitweb /
journal-remote: rename KEY_FILE to avoid confict with <linux/input.h>
[elogind.git] / src / journal-remote / journal-remote.c
index 08de9d03ae90e2a9ae01fa47768dd955a6346b08..1df178691a45c742e0d4111c890fd98a7da6d18d 100644 (file)
@@ -52,9 +52,9 @@
 
 #define REMOTE_JOURNAL_PATH "/var/log/journal/remote"
 
-#define KEY_FILE   CERTIFICATE_ROOT "/private/journal-remote.pem"
-#define CERT_FILE  CERTIFICATE_ROOT "/certs/journal-remote.pem"
-#define TRUST_FILE CERTIFICATE_ROOT "/ca/trusted.pem"
+#define PRIV_KEY_FILE CERTIFICATE_ROOT "/private/journal-remote.pem"
+#define CERT_FILE     CERTIFICATE_ROOT "/certs/journal-remote.pem"
+#define TRUST_FILE    CERTIFICATE_ROOT "/ca/trusted.pem"
 
 static char* arg_url = NULL;
 static char* arg_getter = NULL;
@@ -149,9 +149,11 @@ static int spawn_getter(const char *getter, const char *url) {
         _cleanup_strv_free_ char **words = NULL;
 
         assert(getter);
-        words = strv_split_quoted(getter);
-        if (!words)
-                return log_oom();
+        r = strv_split_quoted(&words, getter);
+        if (r < 0) {
+                log_error("Failed to split getter option: %s", strerror(-r));
+                return r;
+        }
 
         r = strv_extend(&words, url);
         if (r < 0) {
@@ -1122,16 +1124,11 @@ static int parse_config(void) {
                 { "Remote",  "ServerCertificateFile",  config_parse_path,             0, &arg_cert       },
                 { "Remote",  "TrustedCertificateFile", config_parse_path,             0, &arg_trust      },
                 {}};
-        int r;
-
-        r = config_parse(NULL, PKGSYSCONFDIR "/journal-remote.conf", NULL,
-                         "Remote\0",
-                         config_item_table_lookup, items,
-                         false, false, NULL);
-        if (r < 0)
-                log_error("Failed to parse configuration file: %s", strerror(-r));
 
-        return r;
+        return config_parse(NULL, PKGSYSCONFDIR "/journal-remote.conf", NULL,
+                            "Remote\0",
+                            config_item_table_lookup, items,
+                            false, false, true, NULL);
 }
 
 static void help(void) {
@@ -1147,7 +1144,7 @@ static void help(void) {
                "  --[no-]compress      Use XZ-compression in the output journal (default: yes)\n"
                "  --[no-]seal          Use Event sealing in the output journal (default: no)\n"
                "  --key=FILENAME       Specify key in PEM format (default:\n"
-               "                           \"" KEY_FILE "\")\n"
+               "                           \"" PRIV_KEY_FILE "\")\n"
                "  --cert=FILENAME      Specify certificate in PEM format (default:\n"
                "                           \"" CERT_FILE "\")\n"
                "  --trust=FILENAME|all Specify CA certificate or disable checking (default:\n"
@@ -1349,7 +1346,7 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case ARG_GNUTLS_LOG: {
 #ifdef HAVE_GNUTLS
-                        char *word, *state;
+                        const char *word, *state;
                         size_t size;
 
                         FOREACH_WORD_SEPARATOR(word, size, optarg, ",", state) {
@@ -1423,10 +1420,10 @@ static int parse_argv(int argc, char *argv[]) {
 static int load_certificates(char **key, char **cert, char **trust) {
         int r;
 
-        r = read_full_file(arg_key ?: KEY_FILE, key, NULL);
+        r = read_full_file(arg_key ?: PRIV_KEY_FILE, key, NULL);
         if (r < 0) {
                 log_error("Failed to read key from file '%s': %s",
-                          arg_key ?: KEY_FILE, strerror(-r));
+                          arg_key ?: PRIV_KEY_FILE, strerror(-r));
                 return r;
         }