diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-10-06 12:55:03 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-10-14 17:38:26 +0200 |
commit | 51fa9bfd7b19b1eec6ea30f5ea3406672276feca (patch) | |
tree | c4e62499b59aa439fb79f3c253332f974d601f67 /conf.c | |
parent | da152331cf2e8537bc3651e10eb8b72d751721c3 (diff) | |
download | passt-51fa9bfd7b19b1eec6ea30f5ea3406672276feca.tar passt-51fa9bfd7b19b1eec6ea30f5ea3406672276feca.tar.gz passt-51fa9bfd7b19b1eec6ea30f5ea3406672276feca.tar.bz2 passt-51fa9bfd7b19b1eec6ea30f5ea3406672276feca.tar.lz passt-51fa9bfd7b19b1eec6ea30f5ea3406672276feca.tar.xz passt-51fa9bfd7b19b1eec6ea30f5ea3406672276feca.tar.zst passt-51fa9bfd7b19b1eec6ea30f5ea3406672276feca.zip |
conf: Drop duplicate, diverging optstring assignments
This originated as a result of copy and paste to introduce a second
stage for processing options related to port forwarding, has already
bitten David in the past, and just gave me hours of fun.
As a matter of fact, the second set of optstring assignments was
already incorrect, but it didn't matter because the first one was
more restrictive, not allowing optional arguments for -P, -D, -S.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 20 |
1 files changed, 6 insertions, 14 deletions
@@ -1043,25 +1043,23 @@ void conf(struct ctx *c, int argc, char **argv) struct fqdn *dnss = c->dns_search; uint32_t *dns4 = c->ip4.dns; int name, ret, mask, b, i; + const char *optstring; unsigned int ifi = 0; char *runas = NULL; uid_t uid; gid_t gid; - if (c->mode == MODE_PASTA) + if (c->mode == MODE_PASTA) { c->no_dhcp_dns = c->no_dhcp_dns_search = 1; + optstring = "dqfehI:p:P:m:a:n:M:g:i:D:S:46t:u:T:U:"; + } else { + optstring = "dqfehs:p:P:m:a:n:M:g:i:D:S:46t:u:"; + } c->tcp.fwd_in.mode = c->tcp.fwd_out.mode = 0; c->udp.fwd_in.f.mode = c->udp.fwd_out.f.mode = 0; do { - const char *optstring; - - if (c->mode == MODE_PASST) - optstring = "dqfehs:p:P:m:a:n:M:g:i:D:S:46t:u:"; - else - optstring = "dqfehI:p:P:m:a:n:M:g:i:D:S:46t:u:T:U:"; - name = getopt_long(argc, argv, optstring, options, NULL); switch (name) { @@ -1505,12 +1503,6 @@ void conf(struct ctx *c, int argc, char **argv) optind = 1; do { struct port_fwd *fwd = NULL; - const char *optstring; - - if (c->mode == MODE_PASST) - optstring = "dqfehs:p::P:m:a:n:M:g:i:D::S::46t:u:"; - else - optstring = "dqfehI:p::P:m:a:n:M:g:i:D::S::46t:u:T:U:"; name = getopt_long(argc, argv, optstring, options, NULL); switch (name) { |