etc/services - sync with NetBSD-8
[minix.git] / crypto / external / bsd / heimdal / dist / lib / hdb / test_mkey.c
blob6e0cbfe1e6881d5a16275e626a251f68f3e622c6
1 /* $NetBSD: test_mkey.c,v 1.1.1.2 2014/04/24 12:45:28 pettai Exp $ */
4 #include "hdb_locl.h"
5 #include <krb5/getarg.h>
6 #include <krb5/base64.h>
8 static char *mkey_file;
9 static int help_flag;
10 static int version_flag;
12 struct getargs args[] = {
13 { "mkey-file", 0, arg_string, &mkey_file },
14 { "help", 'h', arg_flag, &help_flag },
15 { "version", 0, arg_flag, &version_flag }
18 static int num_args = sizeof(args) / sizeof(args[0]);
20 int
21 main(int argc, char **argv)
23 krb5_context context;
24 int ret, o = 0;
26 setprogname(argv[0]);
28 if(getarg(args, num_args, argc, argv, &o))
29 krb5_std_usage(1, args, num_args);
31 if(help_flag)
32 krb5_std_usage(0, args, num_args);
34 if(version_flag){
35 print_version(NULL);
36 exit(0);
39 ret = krb5_init_context(&context);
40 if (ret)
41 errx(1, "krb5_init_context failed: %d", ret);
43 if (mkey_file) {
44 hdb_master_key mkey;
46 ret = hdb_read_master_key(context, mkey_file, &mkey);
47 if (ret)
48 krb5_err(context, 1, ret, "failed to read master key %s", mkey_file);
50 hdb_free_master_key(context, mkey);
51 } else
52 krb5_errx(context, 1, "no command option given");
54 krb5_free_context(context);
56 return 0;