aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gpg-card.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-08-14 10:19:11 +0000
committerWerner Koch <[email protected]>2020-08-14 10:19:11 +0000
commit6bcb609e1b2a507caa2e1a078178709d808b590b (patch)
tree28de80abf6d947281188a2f89612311168747fdc /tools/gpg-card.c
parentgpg: Ignore personal_digest_prefs for ECDSA keys. (diff)
downloadgnupg-6bcb609e1b2a507caa2e1a078178709d808b590b.tar.gz
gnupg-6bcb609e1b2a507caa2e1a078178709d808b590b.zip
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 <[email protected]>
Diffstat (limited to 'tools/gpg-card.c')
-rw-r--r--tools/gpg-card.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index 7910a48fe..bf3663924 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -76,6 +76,7 @@ enum opt_values
oNoKeyLookup,
oNoHistory,
+ oChUid,
oDummy
};
@@ -104,6 +105,7 @@ static gpgrt_opt_t opts[] = {
"use --no-key-lookup for \"list\""),
ARGPARSE_s_n (oNoHistory,"no-history",
"do not use the command history file"),
+ ARGPARSE_s_s (oChUid, "chuid", "@"),
ARGPARSE_end ()
};
@@ -125,6 +127,8 @@ struct keyinfolabel_s
};
typedef struct keyinfolabel_s *keyinfolabel_t;
+/* Helper for --chuid. */
+static const char *changeuser;
/* Limit of size of data we read from a file for certain commands. */
#define MAX_GET_DATA_FROM_FILE 16384
@@ -235,6 +239,8 @@ parse_arguments (gpgrt_argparse_t *pargs, gpgrt_opt_t *popts)
case oNoKeyLookup: opt.no_key_lookup = 1; break;
case oNoHistory: opt.no_history = 1; break;
+ case oChUid: changeuser = pargs->r.ret_str; break;
+
default: pargs->err = 2; break;
}
}
@@ -279,6 +285,9 @@ main (int argc, char **argv)
parse_arguments (&pargs, opts);
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);