diff options
author | Werner Koch <wk@gnupg.org> | 2020-08-06 15:32:43 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2020-08-06 16:03:57 +0200 |
commit | d10f45184c4482036c41f4818c84c0725a0c2c94 (patch) | |
tree | 624c61c1c93bd90a1d7c785d794cb47cccef8ee6 /tools/gpgconf.c | |
parent | common: New helper function gnupg_chuid. (diff) | |
download | gnupg2-d10f45184c4482036c41f4818c84c0725a0c2c94.tar.xz gnupg2-d10f45184c4482036c41f4818c84c0725a0c2c94.zip |
gpgconf: New option --chuid.
* tools/gpgconf.c (oChUid, opts): New option --chuid.
(main): Implement.
--
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to '')
-rw-r--r-- | tools/gpgconf.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/gpgconf.c b/tools/gpgconf.c index 3433ed473..e68eecdd7 100644 --- a/tools/gpgconf.c +++ b/tools/gpgconf.c @@ -51,6 +51,7 @@ enum cmd_and_opt_values oBuilddir, oStatusFD, oShowSocket, + oChUid, aListComponents, aCheckPrograms, @@ -113,6 +114,7 @@ static gpgrt_opt_t opts[] = { oNull, "null", 0, "@" }, { oNoVerbose, "no-verbose", 0, "@"}, ARGPARSE_s_n (oShowSocket, "show-socket", "@"), + ARGPARSE_s_s (oChUid, "chuid", "@"), ARGPARSE_end(), }; @@ -547,6 +549,7 @@ main (int argc, char **argv) enum cmd_and_opt_values cmd = 0; estream_t outfp = NULL; int show_socket = 0; + const char *changeuser = NULL; early_system_init (); gnupg_reopen_std (GPGCONF_NAME); @@ -579,6 +582,7 @@ main (int argc, char **argv) set_status_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); break; case oShowSocket: show_socket = 1; break; + case oChUid: changeuser = pargs.r.ret_str; break; case aListDirs: case aListComponents: @@ -620,6 +624,10 @@ main (int argc, char **argv) fname = argc ? *argv : NULL; + /* If requested switch to the requested user or die. */ + if (changeuser && (err = gnupg_chuid (changeuser, 0))) + gpgconf_failure (err); + /* Set the configuraton directories for use by gpgrt_argparser. We * don't have a configuration file for this program but we have code * which reads the component's config files. */ |