journal-upload: fix socket activation

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2014-10-18 01:27:10 -04:00
parent a9becdd65b
commit 42b6bf75e4
2 changed files with 11 additions and 10 deletions

View 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

View 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,