diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2022-09-12 22:23:59 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-09-13 05:31:51 +0200 |
commit | 7330ae3abfba9722c04e6c52ae6222de47016834 (patch) | |
tree | 7fcedad80d3f101ac08247ec4136224cbec4bad8 /conf.c | |
parent | e2cae8f1c3651b1237a3042b4ba6211155aa58f1 (diff) | |
download | passt-7330ae3abfba9722c04e6c52ae6222de47016834.tar passt-7330ae3abfba9722c04e6c52ae6222de47016834.tar.gz passt-7330ae3abfba9722c04e6c52ae6222de47016834.tar.bz2 passt-7330ae3abfba9722c04e6c52ae6222de47016834.tar.lz passt-7330ae3abfba9722c04e6c52ae6222de47016834.tar.xz passt-7330ae3abfba9722c04e6c52ae6222de47016834.tar.zst passt-7330ae3abfba9722c04e6c52ae6222de47016834.zip |
Don't store UID & GID persistently in the context structure
c->uid and c->gid are first set in conf(), and last used in check_root()
itself called from conf(). Therefore these don't need to be fields in the
long lived context structure and can instead be locals in conf().
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1086,6 +1086,8 @@ void conf(struct ctx *c, int argc, char **argv) uint32_t *dns4 = c->ip4.dns; int name, ret, mask, b, i; unsigned int ifi = 0; + uid_t uid = 0; + gid_t gid = 0; if (c->mode == MODE_PASTA) c->no_dhcp_dns = c->no_dhcp_dns_search = 1; @@ -1208,12 +1210,12 @@ void conf(struct ctx *c, int argc, char **argv) c->trace = c->debug = c->foreground = 1; break; case 12: - if (c->uid || c->gid) { + if (uid || gid) { err("Multiple --runas options given"); usage(argv[0]); } - if (conf_runas(optarg, &c->uid, &c->gid)) { + if (conf_runas(optarg, &uid, &gid)) { err("Invalid --runas option: %s", optarg); usage(argv[0]); } @@ -1497,7 +1499,7 @@ void conf(struct ctx *c, int argc, char **argv) } } while (name != -1); - check_root(c); + check_root(&uid, &gid); if (c->mode == MODE_PASTA) { if (*netns && optind != argc) { |