aboutgitcodebugslistschat
path: root/pasta.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2024-08-20 22:39:44 +0200
committerStefano Brivio <sbrivio@redhat.com>2024-08-21 12:04:53 +0200
commitf00ebda369844a8570591a9defd46f9e304a82ef (patch)
treea914d86cd0e3ff7b68c8f0febfc7db84f4205786 /pasta.c
parent05453ea59072f2ad0a40a1f1bed346de098a6e58 (diff)
downloadpasst-f00ebda369844a8570591a9defd46f9e304a82ef.tar
passt-f00ebda369844a8570591a9defd46f9e304a82ef.tar.gz
passt-f00ebda369844a8570591a9defd46f9e304a82ef.tar.bz2
passt-f00ebda369844a8570591a9defd46f9e304a82ef.tar.lz
passt-f00ebda369844a8570591a9defd46f9e304a82ef.tar.xz
passt-f00ebda369844a8570591a9defd46f9e304a82ef.tar.zst
passt-f00ebda369844a8570591a9defd46f9e304a82ef.zip
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 (before :, which is needed to avoid printing errors) 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. Now that we change the parsing mode between close_open_files() and conf(), we need to reset optind to 0, not to 1, whenever we call getopt_long() again in conf(), so that the internal initialisation of getopt_long() evaluating GNU extensions is re-triggered. 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 <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'pasta.c')
0 files changed, 0 insertions, 0 deletions