diff options
author | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
---|---|---|
committer | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
commit | 7281f9682138be213c08fe4674685b925aef5ead (patch) | |
tree | 8db65324ee035fc0568492b88eec17f660241fd0 /crypto/heimdal/admin/change.c | |
parent | 869b11442ded05e5e48acc47ea0896d83d8ea198 (diff) | |
parent | 0c8fa354358381b3f1b92598e7f1b46f8cf744cc (diff) | |
download | FreeBSD-src-7281f9682138be213c08fe4674685b925aef5ead.zip FreeBSD-src-7281f9682138be213c08fe4674685b925aef5ead.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r78527,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'crypto/heimdal/admin/change.c')
-rw-r--r-- | crypto/heimdal/admin/change.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/crypto/heimdal/admin/change.c b/crypto/heimdal/admin/change.c index 128395a..c523dc4 100644 --- a/crypto/heimdal/admin/change.c +++ b/crypto/heimdal/admin/change.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,10 +33,11 @@ #include "ktutil_locl.h" -RCSID("$Id: change.c,v 1.2 2000/06/03 12:24:03 assar Exp $"); +RCSID("$Id: change.c,v 1.3 2001/05/10 15:40:07 assar Exp $"); static void -change_entry (krb5_context context, krb5_keytab_entry *entry, +change_entry (krb5_context context, krb5_keytab keytab, + krb5_keytab_entry *entry, const char *realm, const char *admin_server, int server_port) { krb5_error_code ret; @@ -49,7 +50,7 @@ change_entry (krb5_context context, krb5_keytab_entry *entry, ret = krb5_unparse_name (context, entry->principal, &client_name); if (ret) { - krb5_warn (context, ret, "kadm5_c_init_with_skey_ctx"); + krb5_warn (context, ret, "krb5_unparse_name"); return; } @@ -113,6 +114,7 @@ int kt_change (int argc, char **argv) { krb5_error_code ret; + krb5_keytab keytab; krb5_kt_cursor cursor; krb5_keytab_entry entry; char *realm = NULL; @@ -145,21 +147,39 @@ kt_change (int argc, char **argv) || help_flag) { arg_printusage(args, sizeof(args) / sizeof(args[0]), "ktutil change", "principal..."); - return 0; + return 1; } + if (keytab_string == NULL) { + ret = krb5_kt_default_modify_name (context, keytab_buf, + sizeof(keytab_buf)); + if (ret) { + krb5_warn(context, ret, "krb5_kt_default_modify_name"); + return 1; + } + keytab_string = keytab_buf; + } + ret = krb5_kt_resolve(context, keytab_string, &keytab); + if (ret) { + krb5_warn(context, ret, "resolving keytab %s", keytab_string); + return 1; + } + + if (verbose_flag) + fprintf (stderr, "Using keytab %s\n", keytab_string); + j = 0; max = 10; princs = malloc (max * sizeof(*princs)); if (princs == NULL) { krb5_warnx (context, "malloc: out of memory"); - return 1; + goto out; } ret = krb5_kt_start_seq_get(context, keytab, &cursor); if(ret){ krb5_warn(context, ret, "krb5_kt_start_seq_get %s", keytab_string); - return 1; + goto out; } while((ret = krb5_kt_next_entry(context, keytab, &entry, &cursor)) == 0) { @@ -174,7 +194,8 @@ kt_change (int argc, char **argv) continue; if (optind == argc) { - change_entry (context, &entry, realm, admin_server, server_port); + change_entry (context, keytab, &entry, realm, admin_server, + server_port); done = 1; } else { for (i = optind; i < argc; ++i) { @@ -186,7 +207,7 @@ kt_change (int argc, char **argv) continue; } if (krb5_principal_compare (context, princ, entry.principal)) { - change_entry (context, &entry, + change_entry (context, keytab, &entry, realm, admin_server, server_port); done = 1; } @@ -220,5 +241,7 @@ kt_change (int argc, char **argv) krb5_free_principal (context, princs[j]); free (princs); ret = krb5_kt_end_seq_get(context, keytab, &cursor); + out: + krb5_kt_close(context, keytab); return 0; } |