aboutsummaryrefslogtreecommitdiffstats
path: root/key2root-rmkey.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-06-23 10:40:22 +0200
committerMattias Andrée <maandree@kth.se>2023-06-23 10:40:22 +0200
commit901d3533ec3285b58960d0af0937c8e05692ebe0 (patch)
treee552881286ad78a0fbfb3aafe9a9c1ed360d53b8 /key2root-rmkey.c
parentImplement key2root-lskeys (diff)
downloadkey2root-901d3533ec3285b58960d0af0937c8e05692ebe0.tar.gz
key2root-901d3533ec3285b58960d0af0937c8e05692ebe0.tar.bz2
key2root-901d3533ec3285b58960d0af0937c8e05692ebe0.tar.xz
Add argument checks to key2root-addkey and key2root-rmkey
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--key2root-rmkey.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/key2root-rmkey.c b/key2root-rmkey.c
index 1050977..f2ab34d 100644
--- a/key2root-rmkey.c
+++ b/key2root-rmkey.c
@@ -19,6 +19,9 @@ usage(void)
int
main(int argc, char *argv[])
{
+ const char *user;
+ int i, failed = 0;
+
ARGBEGIN {
default:
usage();
@@ -27,5 +30,23 @@ main(int argc, char *argv[])
if (argc < 2)
usage();
+ user = *argv++;
+ argc--;
+
+ if (!user[0] || user[0] == '.' || strchr(user, '/') || strchr(user, '~')) {
+ fprintf(stderr, "%s: bad user name specified: %s\n", argv0, user);
+ failed = 1;
+ }
+ for (i = 0; i < argc; i++) {
+ if (argv[i][strcspn(argv[i], " \t\f\n\r\v")]) {
+ fprintf(stderr, "%s: bad key name specified: %s, includes whitespace\n", argv0, argv[i]);
+ failed = 1;
+ }
+ }
+ if (failed)
+ return 1;
+
+ /* TODO */
+
return 0;
}