minix/crypto/external/bsd/heimdal/dist/lib/hdb/test_mkey.c
Lionel Sambuc 0a6a1f1d05 NetBSD re-synchronization of the source tree
This brings our tree to NetBSD 7.0, as found on -current on the
10-10-2015.

This updates:
 - LLVM to 3.6.1
 - GCC to GCC 5.1
 - Replace minix/commands/zdump with usr.bin/zdump
 - external/bsd/libelf has moved to /external/bsd/elftoolchain/
 - Import ctwm
 - Drop sprintf from libminc

Change-Id: I149836ac18e9326be9353958bab9b266efb056f0
2016-01-13 20:32:14 +01:00

58 lines
1.2 KiB
C

/* $NetBSD: test_mkey.c,v 1.1.1.2 2014/04/24 12:45:28 pettai Exp $ */
#include "hdb_locl.h"
#include <krb5/getarg.h>
#include <krb5/base64.h>
static char *mkey_file;
static int help_flag;
static int version_flag;
struct getargs args[] = {
{ "mkey-file", 0, arg_string, &mkey_file },
{ "help", 'h', arg_flag, &help_flag },
{ "version", 0, arg_flag, &version_flag }
};
static int num_args = sizeof(args) / sizeof(args[0]);
int
main(int argc, char **argv)
{
krb5_context context;
int ret, o = 0;
setprogname(argv[0]);
if(getarg(args, num_args, argc, argv, &o))
krb5_std_usage(1, args, num_args);
if(help_flag)
krb5_std_usage(0, args, num_args);
if(version_flag){
print_version(NULL);
exit(0);
}
ret = krb5_init_context(&context);
if (ret)
errx(1, "krb5_init_context failed: %d", ret);
if (mkey_file) {
hdb_master_key mkey;
ret = hdb_read_master_key(context, mkey_file, &mkey);
if (ret)
krb5_err(context, 1, ret, "failed to read master key %s", mkey_file);
hdb_free_master_key(context, mkey);
} else
krb5_errx(context, 1, "no command option given");
krb5_free_context(context);
return 0;
}