1
0
Fork 0
mirror of https://passt.top/passt synced 2025-05-20 16:35:33 +02:00

conf: allow --fd 0

inetd-style socket passing traditionally starts a service with a
connected socket on file descriptors 0 and 1.  passt disallowing
obtaining its socket from either of these descriptors made it
difficult to use with super-servers providing this interface — in my
case I wanted to use passt with s6-ipcserver[1].  Since (as far as I
can tell) passt does not use standard input for anything else (unlike
standard output), it should be safe to relax the restrictions on --fd
to allow setting it to 0, enabling this use case.

Link: https://skarnet.org/software/s6/s6-ipcserver.html [1]
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Alyssa Ross 2025-04-26 10:44:25 +02:00 committed by Stefano Brivio
parent 436afc3044
commit aa1cc89228
2 changed files with 5 additions and 2 deletions

3
conf.c
View file

@ -1717,7 +1717,8 @@ void conf(struct ctx *c, int argc, char **argv)
fd_tap_opt = strtol(optarg, NULL, 0);
if (errno ||
fd_tap_opt <= STDERR_FILENO || fd_tap_opt > INT_MAX)
(fd_tap_opt != STDIN_FILENO && fd_tap_opt <= STDERR_FILENO) ||
fd_tap_opt > INT_MAX)
die("Invalid --fd: %s", optarg);
c->fd_tap = fd_tap_opt;

4
util.c
View file

@ -875,7 +875,9 @@ void close_open_files(int argc, char **argv)
errno = 0;
fd = strtol(optarg, NULL, 0);
if (errno || fd <= STDERR_FILENO || fd > INT_MAX)
if (errno ||
(fd != STDIN_FILENO && fd <= STDERR_FILENO) ||
fd > INT_MAX)
die("Invalid --fd: %s", optarg);
}
} while (name != -1);