aboutsummaryrefslogtreecommitdiff
path: root/client/keytab.c
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2007-10-05 02:15:27 +0000
committerRuss Allbery <rra@stanford.edu>2007-10-05 02:15:27 +0000
commitf21fba65f194ff26bf72e23f0db311314529720b (patch)
treece454a33292244ad130962ab9da7f667fe57d1ec /client/keytab.c
parentfe56c09a7feeb2d1c9cd699fda07e145c4c354a2 (diff)
Refactor the remctl calls in the wallet client to share a common routine.
Diffstat (limited to 'client/keytab.c')
-rw-r--r--client/keytab.c36
1 files changed, 3 insertions, 33 deletions
diff --git a/client/keytab.c b/client/keytab.c
index 3450766..b815e4a 100644
--- a/client/keytab.c
+++ b/client/keytab.c
@@ -26,49 +26,19 @@ get_keytab(struct remctl *r, const char *type, const char *name,
const char *file)
{
const char *command[5];
- struct remctl_output *output;
char *data = NULL;
size_t length = 0;
int status = 255;
- /* Run the command on the wallet server */
command[0] = type;
command[1] = "get";
command[2] = "keytab";
command[3] = name;
command[4] = NULL;
- if (!remctl_command(r, command))
- die("%s", remctl_error(r));
-
- /* Retrieve the results. */
- do {
- output = remctl_output(r);
- switch (output->type) {
- case REMCTL_OUT_OUTPUT:
- if (output->stream == 1) {
- data = xrealloc(data, length + output->length);
- memcpy(data + length, output->data, output->length);
- length += output->length;
- } else {
- fprintf(stderr, "wallet: ");
- fwrite(output->data, 1, output->length, stderr);
- }
- break;
- case REMCTL_OUT_STATUS:
- status = output->status;
- break;
- case REMCTL_OUT_ERROR:
- fprintf(stderr, "wallet: ");
- fwrite(output->data, 1, output->length, stderr);
- fputc('\n', stderr);
- exit(255);
- case REMCTL_OUT_DONE:
- break;
- }
- } while (output->type != REMCTL_OUT_DONE);
+ status = run_command(r, command, &data, &length);
if (status != 0)
exit(status);
-
- /* Okay, we now have the valid keytab data in data. Write it out. */
+ if (data == NULL)
+ die("no data returned by wallet server");
write_file(file, data, length);
}