diff options
| author | David Gibson <david@gibson.dropbear.id.au> | 2026-07-17 15:46:31 +1000 |
|---|---|---|
| committer | Stefano Brivio <sbrivio@redhat.com> | 2026-07-18 09:54:27 +0200 |
| commit | 33e0fbc396f494e2fdd8033191b76d2c4aef43ec (patch) | |
| tree | 60fcf9128e87244e50067ab9a7dd0f123896d425 | |
| parent | 0a510066e9169409e9021798224bea5297c1e529 (diff) | |
| download | passt-33e0fbc396f494e2fdd8033191b76d2c4aef43ec.tar passt-33e0fbc396f494e2fdd8033191b76d2c4aef43ec.tar.gz passt-33e0fbc396f494e2fdd8033191b76d2c4aef43ec.tar.bz2 passt-33e0fbc396f494e2fdd8033191b76d2c4aef43ec.tar.lz passt-33e0fbc396f494e2fdd8033191b76d2c4aef43ec.tar.xz passt-33e0fbc396f494e2fdd8033191b76d2c4aef43ec.tar.zst passt-33e0fbc396f494e2fdd8033191b76d2c4aef43ec.zip | |
isolation, conf: Set c->fd_tap from early parse of --fd
We parse --fd twice: once in isolate_initial() just to avoid clobbering
the passed in fd. Then we parse it "for real" in conf(), to set c->fd_tap
and other configuration variables.
Change this, so that we return the value parsed early from
isolate_initial() and set c->fd_tap from that. This doesn't accomplish
much immediately, but will make some further cleanups possible.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
| -rw-r--r-- | conf.c | 2 | ||||
| -rw-r--r-- | isolation.c | 6 | ||||
| -rw-r--r-- | isolation.h | 2 | ||||
| -rw-r--r-- | passt.c | 2 |
4 files changed, 8 insertions, 4 deletions
@@ -1593,7 +1593,7 @@ void conf(struct ctx *c, int argc, char **argv) c->fd_control_listen = c->fd_control = -1; break; case 'F': - c->fd_tap = conf_tap_fd(optarg); + /* --fd was parsed early and c->fd_tap set in main() */ c->one_off = true; *c->sock_path = 0; break; diff --git a/isolation.c b/isolation.c index ea85fdb..c9dfefa 100644 --- a/isolation.c +++ b/isolation.c @@ -257,8 +257,10 @@ void isolate_initial(void) * * Should: * - close all open files except for standard streams and the one from --fd + * + * Return: fd number from --fd, or -1 if not specified */ -void isolate_fds(int argc, char **argv) +int isolate_fds(int argc, char **argv) { const struct option optfd[] = { { "fd", required_argument, NULL, 'F' }, { 0 }, }; @@ -296,6 +298,8 @@ void isolate_fds(int argc, char **argv) die_perror("Failed to close files leaked by parent"); } } + + return fd; } /** diff --git a/isolation.h b/isolation.h index e1b1bc5..ec47038 100644 --- a/isolation.h +++ b/isolation.h @@ -11,7 +11,7 @@ #include <unistd.h> void isolate_initial(void); -void isolate_fds(int argc, char **argv); +int isolate_fds(int argc, char **argv); void isolate_user(const struct ctx *c, uid_t uid, gid_t gid, bool use_userns, const char *userns); int isolate_prefork(const struct ctx *c); @@ -345,7 +345,7 @@ int main(int argc, char **argv) arch_avx2_exec(argv); isolate_initial(); - isolate_fds(argc, argv); + c->fd_tap = isolate_fds(argc, argv); sigemptyset(&sa.sa_mask); sa.sa_flags = 0; |
