From 6adb89c30c9e876848fa84774674db0fd05dad8d Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Wed, 10 Jun 2020 23:18:03 +0200 Subject: Make all sockets close-on-exec --- announce.c | 2 +- ctest.c | 2 +- idle.c | 2 +- proxy.c | 2 +- rcon.c | 2 +- server.c | 2 +- stest.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/announce.c b/announce.c index 3a50771..cc5d549 100644 --- a/announce.c +++ b/announce.c @@ -173,7 +173,7 @@ announce_init(struct cfg *cfg) if (afd < 0) perrordie("timerfd_create"); - sfd = socket(AF_INET, SOCK_DGRAM, 0); + sfd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); if (sfd < 0) perrordie("socket"); diff --git a/ctest.c b/ctest.c index 2e871cb..b0a367d 100644 --- a/ctest.c +++ b/ctest.c @@ -27,7 +27,7 @@ main(int argc, char **argv) { exit(EXIT_FAILURE); } - sfd = socket(AF_INET, SOCK_STREAM, 0); + sfd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); if (sfd < 0) { perror("socket"); exit(EXIT_FAILURE); diff --git a/idle.c b/idle.c index 03d9f88..46be539 100644 --- a/idle.c +++ b/idle.c @@ -357,7 +357,7 @@ again: fprintf(stderr, "%s: attempting idle check on %s (len %u)\n", scfg->name, idle->remotestr, idle->remote.addrlen); - sfd = socket(idle->remote.storage.ss_family, SOCK_STREAM, 0); + sfd = socket(idle->remote.storage.ss_family, SOCK_STREAM | SOCK_CLOEXEC, 0); if (sfd < 0) { perror("socket"); goto again; diff --git a/proxy.c b/proxy.c index dcae9b6..1ec9541 100644 --- a/proxy.c +++ b/proxy.c @@ -230,7 +230,7 @@ again: fprintf(stderr, "%s: attempting proxy connection to %s (len %u)\n", scfg->name, proxy->serverstr, proxy->server.addrlen); - sfd = socket(proxy->server.storage.ss_family, SOCK_STREAM, 0); + sfd = socket(proxy->server.storage.ss_family, SOCK_STREAM | SOCK_CLOEXEC, 0); if (sfd < 0) { perror("socket"); goto again; diff --git a/rcon.c b/rcon.c index 02fd021..a1fd90f 100644 --- a/rcon.c +++ b/rcon.c @@ -366,7 +366,7 @@ again: fprintf(stderr, "%s: attempting rcon connection to %s (len %u)\n", scfg->name, rcon->rconstr, rcon->rcon.addrlen); - sfd = socket(rcon->rcon.storage.ss_family, SOCK_STREAM, 0); + sfd = socket(rcon->rcon.storage.ss_family, SOCK_STREAM | SOCK_CLOEXEC, 0); if (sfd < 0) { perror("socket"); goto again; diff --git a/server.c b/server.c index 7a0dc5b..0298491 100644 --- a/server.c +++ b/server.c @@ -215,7 +215,7 @@ server_local_open(struct cfg *cfg, struct server *scfg, struct server_local *loc int enable = 1; int r; - sfd = socket(local->addr.storage.ss_family, SOCK_STREAM, 0); + sfd = socket(local->addr.storage.ss_family, SOCK_STREAM | SOCK_CLOEXEC, 0); if (sfd < 0) { perror("socket"); goto out; diff --git a/stest.c b/stest.c index d60ae74..94b5264 100644 --- a/stest.c +++ b/stest.c @@ -30,7 +30,7 @@ main(int argc, char **argv) { exit(EXIT_FAILURE); } - sfd = socket(AF_INET, SOCK_STREAM, 0); + sfd = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); if (sfd < 0) { perror("socket"); exit(EXIT_FAILURE); -- cgit v1.2.3