commit 9ec8edf7c3ed58660d5ce984a55bbafbd9a23fb9 from: Omar Polo date: Thu Nov 16 21:45:34 2023 UTC gotwebd: define constant instead of using the magic number 3 suggested by stsp@ commit - b2ce80908e83c8a29aab68c76588a41813f13a74 commit + 9ec8edf7c3ed58660d5ce984a55bbafbd9a23fb9 blob - 96fd5c7c164275779cca5fd8206b15f4af564a94 blob + aeb7899ca94b67c3cdb0073a8c958e4090cc27ea --- gotwebd/gotwebd.c +++ gotwebd/gotwebd.c @@ -243,8 +243,8 @@ spawn_socket_process(struct gotwebd *env, const char * argv[argc++] = "-v"; argv[argc] = NULL; - if (p[0] != 3) { - if (dup2(p[0], 3) == -1) + if (p[0] != GOTWEBD_SOCK_FILENO) { + if (dup2(p[0], GOTWEBD_SOCK_FILENO) == -1) fatal("dup2"); } else if (fcntl(p[0], F_SETFD, 0) == -1) fatal("fcntl"); @@ -352,7 +352,7 @@ main(int argc, char **argv) setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) == -1) fatal("failed to drop privileges"); - sockets(env, 3); + sockets(env, GOTWEBD_SOCK_FILENO); return 1; } blob - d47297375a5f9fe3888d5e964455fbc3a3d9416a blob + a76ef44049655b82575dc5a398b4739eeb44efbc --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -48,6 +48,7 @@ #define GOTWEBD_MAXPORT 6 #define GOTWEBD_NUMPROC 3 #define GOTWEBD_REPO_CACHESIZE 4 +#define GOTWEBD_SOCK_FILENO 3 #define PROC_MAX_INSTANCES 32