~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/kadmin/cli/keytab.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2009-05-07 16:16:34 UTC
  • mfrom: (13.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090507161634-xqyk0s9na0le4flj
Tags: 1.7dfsg~beta1-4
When  decrypting the TGS response fails with the subkey, try with the
session key to work around Heimdal bug, Closes: #527353 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved.
3
3
 *
4
 
 * $Id: keytab.c 17730 2006-03-11 22:23:28Z raeburn $
 
4
 * $Id: keytab.c 19709 2007-07-12 23:35:24Z raeburn $
5
5
 * $Source$
6
6
 */
7
7
 
40
40
#include <string.h>
41
41
#include <errno.h>
42
42
 
43
 
#include <krb5.h>
 
43
#include "k5-int.h"
44
44
#include <kadm5/admin.h>
45
45
#include <adm_proto.h>
46
46
#include "kadmin.h"
55
55
 
56
56
static int quiet;
57
57
 
 
58
#ifdef KADMIN_LOCAL
 
59
static int norandkey;
 
60
#endif
 
61
 
58
62
static void add_usage()
59
63
{
 
64
#ifdef KADMIN_LOCAL
 
65
     fprintf(stderr, "Usage: ktadd [-k[eytab] keytab] [-q] [-e keysaltlist] [-norandkey] [principal | -glob princ-exp] [...]\n");
 
66
#else
60
67
     fprintf(stderr, "Usage: ktadd [-k[eytab] keytab] [-q] [-e keysaltlist] [principal | -glob princ-exp] [...]\n");
 
68
#endif
61
69
}
62
70
     
63
71
static void rem_usage()
91
99
                    return 1;
92
100
               }
93
101
          } else {
94
 
               char *tmp = *keytab_str;
95
 
 
96
 
               *keytab_str = (char *)
97
 
                    malloc(strlen("WRFILE:")+strlen(tmp)+1);
98
 
               if (*keytab_str == NULL) {
99
 
                    com_err(whoami, ENOMEM, "while creating keytab name");
100
 
                    return 1;
 
102
               if (asprintf(keytab_str, "WRFILE:%s", *keytab_str) < 0) {
 
103
                   *keytab_str = NULL;
 
104
                   com_err(whoami, ENOMEM, "while creating keytab name");
 
105
                   return 1;
101
106
               }
102
 
               sprintf(*keytab_str, "WRFILE:%s", tmp);
103
107
          }
104
108
          
105
109
          code = krb5_kt_resolve(my_context, *keytab_str, keytab);
126
130
 
127
131
     argc--; argv++;
128
132
     quiet = 0;
 
133
#ifdef KADMIN_LOCAL
 
134
     norandkey = 0;
 
135
#endif
129
136
     while (argc) {
130
137
          if (strncmp(*argv, "-k", 2) == 0) {
131
138
               argc--; argv++;
136
143
               keytab_str = *argv;
137
144
          } else if (strcmp(*argv, "-q") == 0) {
138
145
               quiet++;
 
146
#ifdef KADMIN_LOCAL
 
147
        } else if (strcmp(*argv, "-norandkey") == 0) {
 
148
             norandkey++;
 
149
#endif
139
150
          } else if (strcmp(*argv, "-e") == 0) {
140
151
               argc--;
141
152
               if (argc < 1) {
160
171
          return;
161
172
     }
162
173
 
 
174
#ifdef KADMIN_LOCAL
 
175
     if (norandkey && ks_tuple) {
 
176
       fprintf(stderr, "cannot specify keysaltlist when not changing key\n");
 
177
       return;
 
178
     }
 
179
#endif
 
180
 
163
181
     if (process_keytab(context, &keytab_str, &keytab))
164
182
          return;
165
183
     
261
279
          goto cleanup;
262
280
     }
263
281
 
 
282
#ifdef KADMIN_LOCAL
 
283
     if (norandkey)
 
284
       code = kadm5_get_principal_keys(handle, princ, &keys, &nkeys);
 
285
     else
 
286
#endif
264
287
     if (keepold || ks_tuple != NULL) {
265
288
         code = kadm5_randkey_principal_3(lhandle, princ,
266
289
                                          keepold, n_ks_tuple, ks_tuple,
461
484
    krb5_error_code ret;
462
485
 
463
486
    if ((ret = krb5_enctype_to_string(enctype, buf, sizeof(buf))))
464
 
        sprintf(buf, "etype %d", enctype);
 
487
        snprintf(buf, sizeof(buf), "etype %d", enctype);
465
488
 
466
489
    return buf;
467
490
}