source: heimdal/trunk/lib/hdb/test_mkey.c

Last change on this file was 1, checked in by Paul Smedley, 10 years ago

Initial commit of Heimdal 1.5.3

File size: 1.1 KB
Line 
1
2#include "hdb_locl.h"
3#include <getarg.h>
4#include <base64.h>
5
6static char *mkey_file;
7static int help_flag;
8static int version_flag;
9
10struct getargs args[] = {
11 { "mkey-file", 0, arg_string, &mkey_file },
12 { "help", 'h', arg_flag, &help_flag },
13 { "version", 0, arg_flag, &version_flag }
14};
15
16static int num_args = sizeof(args) / sizeof(args[0]);
17
18int
19main(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}
Note: See TracBrowser for help on using the repository browser.