[PATCH] util: Don't stop on unrelated values when looking for --fd in close_open_files()
Seen with krun: we get a file descriptor via --fd, but we close it and
happily use the same number for TCP files.
The issue is that if we also get other options before --fd, with
arguments, getopt_long() stops parsing them because it sees them as
non-option values.
Use the - modifier at the beginning of optstring, instead of +, which
means we'll continue parsing after finding unrelated option values,
but getopt_long() won't reorder them anyway: they'll be passed with
option value '1', which we can ignore.
By the way, we also need to add : after F in the optstring, so that
we're able to parse the option when given as short name as well.
Link: https://github.com/slp/krun/issues/17#issuecomment-2294943828
Fixes: baccfb95ce0e ("conf: Stop parsing options at first non-option argument")
Fixes: 09603cab28f9 ("passt, util: Close any open file that the parent might have leaked")
Signed-off-by: Stefano Brivio
participants (1)
-
Stefano Brivio