chiark / gitweb /
journal-upload: fix socket activation
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 18 Oct 2014 05:27:10 +0000 (01:27 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 23 Oct 2014 04:18:10 +0000 (00:18 -0400)
src/journal-remote/journal-remote.c
src/journal-remote/journal-upload.c

index eb092ce02045439ac267e2227fbfea2dfdd15e76..5c3c671033991a809733b79b73ee83849905121f 100644 (file)
@@ -796,16 +796,19 @@ static int setup_signals(RemoteServer *s) {
         return 0;
 }
 
-static int fd_fd(const char *spec) {
+static int negative_fd(const char *spec) {
+        /* Return a non-positive number as its inverse, -EINVAL otherwise. */
+
         int fd, r;
 
         r = safe_atoi(spec, &fd);
         if (r < 0)
                 return r;
-        if (fd < 0)
-                return -EINVAL;
 
-        return fd;
+        if (fd > 0)
+                return -EINVAL;
+        else
+                return -fd;
 }
 
 static int remoteserver_init(RemoteServer *s,
@@ -851,7 +854,7 @@ static int remoteserver_init(RemoteServer *s,
         }
 
         for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd++) {
-                if (sd_is_socket(fd, AF_UNSPEC, 0, false)) {
+                if (sd_is_socket(fd, AF_UNSPEC, 0, true)) {
                         log_info("Received a listening socket (fd:%d)", fd);
 
                         if (fd == http_socket)
@@ -860,7 +863,7 @@ static int remoteserver_init(RemoteServer *s,
                                 r = setup_microhttpd_server(s, fd, key, cert, trust);
                         else
                                 r = add_raw_socket(s, fd);
-                } else if (sd_is_socket(fd, AF_UNSPEC, 0, true)) {
+                } else if (sd_is_socket(fd, AF_UNSPEC, 0, false)) {
                         char *hostname;
 
                         r = getnameinfo_pretty(fd, &hostname);
@@ -1256,7 +1259,7 @@ static int parse_argv(int argc, char *argv[]) {
                                 return -EINVAL;
                         }
 
-                        r = fd_fd(optarg);
+                        r = negative_fd(optarg);
                         if (r >= 0)
                                 http_socket = r;
                         else
@@ -1269,7 +1272,7 @@ static int parse_argv(int argc, char *argv[]) {
                                 return -EINVAL;
                         }
 
-                        r = fd_fd(optarg);
+                        r = negative_fd(optarg);
                         if (r >= 0)
                                 https_socket = r;
                         else
index e16204484e2a40e436ead0e5fa15f46ef957395e..bf3a059c3b11ef8f794d7a1abc976fba5698438d 100644 (file)
@@ -220,8 +220,6 @@ int start_upload(Uploader *u,
                             LOG_WARNING, );
 
                 if (arg_key || startswith(u->url, "https://")) {
-                        assert(arg_cert);
-
                         easy_setopt(curl, CURLOPT_SSLKEY, arg_key ?: PRIV_KEY_FILE,
                                     LOG_ERR, return -EXFULL);
                         easy_setopt(curl, CURLOPT_SSLCERT, arg_cert ?: CERT_FILE,