1130803Smarcel/* 246283Sdfr * Copyright (c) 2005 Kungliga Tekniska H��gskolan 3130803Smarcel * (Royal Institute of Technology, Stockholm, Sweden). 4130803Smarcel * All rights reserved. 5130803Smarcel * 698944Sobrien * Redistribution and use in source and binary forms, with or without 746283Sdfr * modification, are permitted provided that the following conditions 898944Sobrien * are met: 998944Sobrien * 1098944Sobrien * 1. Redistributions of source code must retain the above copyright 1198944Sobrien * notice, this list of conditions and the following disclaimer. 1246283Sdfr * 1398944Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1498944Sobrien * notice, this list of conditions and the following disclaimer in the 1598944Sobrien * documentation and/or other materials provided with the distribution. 1698944Sobrien * 1746283Sdfr * 3. Neither the name of the Institute nor the names of its contributors 1898944Sobrien * may be used to endorse or promote products derived from this software 1998944Sobrien * without specific prior written permission. 2098944Sobrien * 2198944Sobrien * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2246283Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2346283Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2446283Sdfr * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 2546283Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2646283Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2746283Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2846283Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2946283Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3046283Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3146283Sdfr * SUCH DAMAGE. 3246283Sdfr */ 3346283Sdfr 3446283Sdfr#include "hdb_locl.h" 35130803Smarcel#include <getarg.h> 36130803Smarcel 37130803Smarcelstatic int help_flag; 3846283Sdfrstatic int version_flag; 3998944Sobrien 4098944Sobrienstruct getargs args[] = { 4198944Sobrien { "help", 'h', arg_flag, &help_flag }, 4298944Sobrien { "version", 0, arg_flag, &version_flag } 4398944Sobrien}; 4446283Sdfr 4546283Sdfrstatic int num_args = sizeof(args) / sizeof(args[0]); 4646283Sdfr 4746283Sdfrint 4846283Sdfrmain(int argc, char **argv) 4946283Sdfr{ 5046283Sdfr struct hdb_dbinfo *info, *d; 5146283Sdfr krb5_context context; 5246283Sdfr int ret, o = 0; 5398944Sobrien 5498944Sobrien setprogname(argv[0]); 5546283Sdfr 5646283Sdfr if(getarg(args, num_args, argc, argv, &o)) 5746283Sdfr krb5_std_usage(1, args, num_args); 5846283Sdfr 5946283Sdfr if(help_flag) 6046283Sdfr krb5_std_usage(0, args, num_args); 6146283Sdfr 6246283Sdfr if(version_flag){ 6346283Sdfr print_version(NULL); 6498944Sobrien exit(0); 6598944Sobrien } 6698944Sobrien 6746283Sdfr ret = krb5_init_context(&context); 6898944Sobrien if (ret) 6946283Sdfr errx (1, "krb5_init_context failed: %d", ret); 7098944Sobrien 7198944Sobrien ret = hdb_get_dbinfo(context, &info); 7298944Sobrien if (ret) 7398944Sobrien krb5_err(context, 1, ret, "hdb_get_dbinfo"); 7446283Sdfr 7546283Sdfr d = NULL; 7698944Sobrien while ((d = hdb_dbinfo_get_next(info, d)) != NULL) { 7798944Sobrien const char *s; 7898944Sobrien s = hdb_dbinfo_get_label(context, d); 7998944Sobrien printf("label: %s\n", s ? s : "no label"); 8098944Sobrien s = hdb_dbinfo_get_realm(context, d); 8198944Sobrien printf("\trealm: %s\n", s ? s : "no realm"); 8246283Sdfr s = hdb_dbinfo_get_dbname(context, d); 8346283Sdfr printf("\tdbname: %s\n", s ? s : "no dbname"); 8498944Sobrien s = hdb_dbinfo_get_mkey_file(context, d); 8598944Sobrien printf("\tmkey_file: %s\n", s ? s : "no mkey file"); 8698944Sobrien s = hdb_dbinfo_get_acl_file(context, d); 8746283Sdfr printf("\tacl_file: %s\n", s ? s : "no acl file"); 8898944Sobrien } 8998944Sobrien 9098944Sobrien hdb_free_dbinfo(context, &info); 9198944Sobrien 9298944Sobrien krb5_free_context(context); 9398944Sobrien 9498944Sobrien return 0; 9598944Sobrien} 9698944Sobrien