1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

Add --chuid to gpg, gpg-card, and gpg-connect-agent.

* g10/gpg.c (oChUid): New.
(opts): Add --chuid.
(main): Implement --chuid.  Delay setting of homedir until the new
chuid is done.
* sm/gpgsm.c (main): Delay setting of homedir until the new chuid is
done.
* tools/gpg-card.c (oChUid): New.
(opts): Add --chuid.
(changeuser): New helper var.
(main): Implement --chuid.
* tools/gpg-connect-agent.c (oChUid): New.
(opts): Add --chuid.
(main): Implement --chuid.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-08-14 12:19:11 +02:00
parent 53d84f9815
commit 6bcb609e1b
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
7 changed files with 108 additions and 42 deletions

View file

@ -71,8 +71,10 @@ enum cmd_and_opt_values
oKeyboxd,
oUIServer,
oNoHistory,
oNoAutostart
oNoAutostart,
oChUid,
oNoop
};
@ -107,6 +109,7 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_s (oAgentProgram, "agent-program", "@"),
ARGPARSE_s_s (oDirmngrProgram, "dirmngr-program", "@"),
ARGPARSE_s_s (oKeyboxdProgram, "keyboxd-program", "@"),
ARGPARSE_s_s (oChUid, "chuid", "@"),
ARGPARSE_end ()
};
@ -1187,6 +1190,9 @@ main (int argc, char **argv)
char **cmdline_commands = NULL;
char *historyname = NULL;
static const char *changeuser;
early_system_init ();
gnupg_rl_initialize ();
gpgrt_set_strusage (my_strusage);
@ -1233,12 +1239,16 @@ main (int argc, char **argv)
opt.enable_varsubst = 1;
opt.trim_leading_spaces = 1;
break;
case oChUid: changeuser = pargs.r.ret_str; break;
default: pargs.err = 2; break;
}
}
gpgrt_argparse (NULL, &pargs, NULL); /* Release internal state. */
if (changeuser && gnupg_chuid (changeuser, 0))
log_inc_errorcount (); /* Force later termination. */
if (log_get_errorcount (0))
exit (2);