diff options
author | Russ Allbery <rra@stanford.edu> | 2008-04-24 23:05:14 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2008-04-24 23:05:14 +0000 |
commit | 86bce23e53e6cc89ed5104b21a5fe33fab5a7a9f (patch) | |
tree | c8c352137a41c5e8da8e46dd880252a30132c89e /client/wallet.c | |
parent | a93ca104c89859e1022c818579f81f528be204b5 (diff) |
The wallet command-line client now reads the data for store from a
file (using -f) or from standard input (if -f wasn't given) when the
data isn't specified on the command line. The data still must not
contain nul characters.
Diffstat (limited to 'client/wallet.c')
-rw-r--r-- | client/wallet.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/client/wallet.c b/client/wallet.c index 2995cf6..5ee24f5 100644 --- a/client/wallet.c +++ b/client/wallet.c @@ -194,9 +194,10 @@ main(int argc, char *argv[]) if (argc < 3) usage(1); - /* -f is only supported for get and -S with get keytab. */ - if (file != NULL && strcmp(argv[0], "get") != 0) - die("-f only supported for get"); + /* -f is only supported for get and store and -S with get keytab. */ + if (file != NULL) + if (strcmp(argv[0], "get") != 0 && strcmp(argv[0], "store") != 0) + die("-f only supported for get and store"); if (srvtab != NULL) { if (strcmp(argv[0], "get") != 0 || strcmp(argv[1], "keytab") != 0) die("-S only supported for get keytab"); @@ -239,11 +240,23 @@ main(int argc, char *argv[]) status = get_file(r, options.type, argv[1], argv[2], file); } } else { - command = xmalloc(sizeof(char *) * (argc + 2)); + if (strcmp(argv[0], "store") == 0) { + if (argc > 4) + die("too many arguments"); + else if (argc == 4) + command = xmalloc(sizeof(char *) * (argc + 2)); + else + command = xmalloc(sizeof(char *) * (argc + 3)); + } else + command = xmalloc(sizeof(char *) * (argc + 2)); command[0] = options.type; for (i = 0; i < argc; i++) command[i + 1] = argv[i]; - command[argc + 1] = NULL; + if (strcmp(argv[0], "store") == 0 && argc < 4) { + command[argc + 1] = read_file(file == NULL ? "-" : file); + command[argc + 2] = NULL; + } else + command[argc + 1] = NULL; status = run_command(r, command, NULL, NULL); } remctl_close(r); |