Implement --principal.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22848 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -67,12 +67,10 @@ usage (int ret)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
const krb5_cc_ops *ops;
|
||||
krb5_context context;
|
||||
krb5_error_code ret;
|
||||
krb5_ccache id;
|
||||
int optidx = 0;
|
||||
char *str;
|
||||
|
||||
setprogname (argv[0]);
|
||||
|
||||
@@ -99,22 +97,42 @@ main (int argc, char **argv)
|
||||
if (argc != 0)
|
||||
usage (1);
|
||||
|
||||
if (cache == NULL)
|
||||
krb5_errx(context, 1, "No cache name given");
|
||||
if (cache && principal)
|
||||
krb5_errx(context, 1, "Both --cache and --principal given, choose one");
|
||||
|
||||
ops = krb5_cc_get_prefix_ops(context, type);
|
||||
if (ops == NULL)
|
||||
krb5_err (context, 1, 0, "krb5_cc_get_prefix_ops");
|
||||
if (principal) {
|
||||
krb5_principal p;
|
||||
|
||||
asprintf(&str, "%s:%s", ops->prefix, cache);
|
||||
if (str == NULL)
|
||||
krb5_errx(context, 1, "out of memory");
|
||||
ret = krb5_parse_name(context, principal, &p);
|
||||
if (ret)
|
||||
krb5_err (context, 1, ret, "krb5_parse_name: %s", principal);
|
||||
|
||||
ret = krb5_cc_resolve(context, str, &id);
|
||||
if (ret)
|
||||
krb5_err (context, 1, ret, "krb5_cc_resolve: %s", str);
|
||||
ret = krb5_cc_cache_match(context, p, type, &id);
|
||||
if (ret)
|
||||
krb5_err (context, 1, ret,
|
||||
"Did not find principal: %s", principal);
|
||||
|
||||
free(str);
|
||||
krb5_free_principal(context, p);
|
||||
|
||||
} else if (cache) {
|
||||
const krb5_cc_ops *ops;
|
||||
char *str;
|
||||
|
||||
ops = krb5_cc_get_prefix_ops(context, type);
|
||||
if (ops == NULL)
|
||||
krb5_err (context, 1, 0, "krb5_cc_get_prefix_ops");
|
||||
|
||||
asprintf(&str, "%s:%s", ops->prefix, cache);
|
||||
if (str == NULL)
|
||||
krb5_errx(context, 1, "out of memory");
|
||||
|
||||
ret = krb5_cc_resolve(context, str, &id);
|
||||
if (ret)
|
||||
krb5_err (context, 1, ret, "krb5_cc_resolve: %s", str);
|
||||
|
||||
free(str);
|
||||
} else
|
||||
usage(1);
|
||||
|
||||
ret = krb5_cc_switch(context, id);
|
||||
if (ret)
|
||||
|
Reference in New Issue
Block a user