1 /* $NetBSD: kcc.c,v 1.1.1.2 2014/04/24 12:45:28 pettai Exp $ */
4 * Copyright (c) 2010 Kungliga Tekniska Högskolan
5 * (Royal Institute of Technology, Stockholm, Sweden).
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the Institute nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include "kuser_locl.h"
38 #include "kcc-commands.h"
40 krb5_context kcc_context
;
41 static int version_flag
;
44 static struct getargs args
[] = {
45 { "version", 0, arg_flag
, &version_flag
, NULL
, NULL
},
46 { "help", 0, arg_flag
, &help_flag
, NULL
, NULL
}
52 arg_printusage_i18n(args
,
53 sizeof(args
)/sizeof(*args
),
62 help(void *opt
, int argc
, char **argv
)
64 sl_slc_help(commands
, argc
, argv
);
69 kgetcred(struct kgetcred_options
*opt
, int argc
, char **argv
)
75 * Wrapper for command line compatiblity
79 kvno(struct kvno_options
*opt
, int argc
, char **argv
)
81 struct kgetcred_options k
;
82 memset(&k
, 0, sizeof(k
));
84 k
.cache_string
= opt
->cache_string
;
85 k
.enctype_string
= opt
->enctype_string
;
87 return kgetcred(&k
, argc
, argv
);
91 command_alias(const char *name
)
93 const char *aliases
[] = {
94 "kinit", "klist", "kswitch", "kgetcred", "kvno", "kdeltkt",
95 "kdestroy", "kcpytkt", NULL
98 while (*p
&& strcmp(name
, *p
) != 0)
105 main(int argc
, char **argv
)
111 setprogname (argv
[0]);
113 setlocale (LC_ALL
, "");
114 bindtextdomain ("heimdal_kuser", HEIMDAL_LOCALEDIR
);
115 textdomain("heimdal_kuser");
117 ret
= krb5_init_context(&kcc_context
);
118 if (ret
== KRB5_CONFIG_BADFORMAT
)
119 errx (1, "krb5_init_context failed to parse configuration file");
121 errx(1, "krb5_init_context failed: %d", ret
);
124 * Support linking of kcc to commands
127 if (!command_alias(getprogname())) {
130 sl_slc_help(commands
, 0, NULL
);
134 if(getarg(args
, sizeof(args
) / sizeof(args
[0]), argc
, argv
, &optidx
))
146 argv
[0] = rk_UNCONST(getprogname());
153 ret
= sl_command(commands
, argc
, argv
);
155 krb5_warnx(kcc_context
, "unrecognized command: %s", argv
[0]);
161 sl_slc_help(commands
, argc
, argv
);
165 krb5_free_context(kcc_context
);