| 1 |
|
| 2 |
#include "hdb_locl.h" |
| 3 |
#include <getarg.h> |
| 4 |
#include <base64.h> |
| 5 |
|
| 6 |
static char *mkey_file; |
| 7 |
static int help_flag; |
| 8 |
static int version_flag; |
| 9 |
|
| 10 |
struct getargs args[] = { |
| 11 |
{ "mkey-file", 0, arg_string, &mkey_file, NULL, NULL }, |
| 12 |
{ "help", 'h', arg_flag, &help_flag, NULL, NULL }, |
| 13 |
{ "version", 0, arg_flag, &version_flag, NULL, NULL } |
| 14 |
}; |
| 15 |
|
| 16 |
static int num_args = sizeof(args) / sizeof(args[0]); |
| 17 |
|
| 18 |
int |
| 19 |
main(int argc, char **argv) |
| 20 |
{ |
| 21 |
krb5_context context; |
| 22 |
int ret, o = 0; |
| 23 |
|
| 24 |
setprogname(argv[0]); |
| 25 |
|
| 26 |
if(getarg(args, num_args, argc, argv, &o)) |
| 27 |
krb5_std_usage(1, args, num_args); |
| 28 |
|
| 29 |
if(help_flag) |
| 30 |
krb5_std_usage(0, args, num_args); |
| 31 |
|
| 32 |
if(version_flag){ |
| 33 |
print_version(NULL); |
| 34 |
exit(0); |
| 35 |
} |
| 36 |
|
| 37 |
ret = krb5_init_context(&context); |
| 38 |
if (ret) |
| 39 |
errx(1, "krb5_init_context failed: %d", ret); |
| 40 |
|
| 41 |
if (mkey_file) { |
| 42 |
hdb_master_key mkey; |
| 43 |
|
| 44 |
ret = hdb_read_master_key(context, mkey_file, &mkey); |
| 45 |
if (ret) |
| 46 |
krb5_err(context, 1, ret, "failed to read master key %s", mkey_file); |
| 47 |
|
| 48 |
hdb_free_master_key(context, mkey); |
| 49 |
} else |
| 50 |
krb5_errx(context, 1, "no command option given"); |
| 51 |
|
| 52 |
krb5_free_context(context); |
| 53 |
|
| 54 |
return 0; |
| 55 |
} |