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,
}
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)
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);
return -EINVAL;
}
- r = fd_fd(optarg);
+ r = negative_fd(optarg);
if (r >= 0)
http_socket = r;
else
return -EINVAL;
}
- r = fd_fd(optarg);
+ r = negative_fd(optarg);
if (r >= 0)
https_socket = r;
else
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,