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

« back to all changes in this revision

Viewing changes to src/appl/bsd/krsh.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:
64
64
#ifdef KERBEROS
65
65
#include <krb5.h>
66
66
#include <com_err.h>
67
 
#ifdef KRB5_KRB4_COMPAT
68
 
#include <kerberosIV/krb.h>
69
 
#endif
70
67
#include "defines.h"
71
68
#endif /* KERBEROS */
72
69
 
73
 
#ifdef KRB5_KRB4_COMPAT
74
 
#include <kerberosIV/krb.h>
75
 
Key_schedule v4_schedule;
76
 
#endif
77
 
 
78
70
/*
79
71
 * rsh - remote shell
80
72
 */
96
88
krb5_context bsd_context;
97
89
krb5_creds *cred;
98
90
 
99
 
#ifdef KRB5_KRB4_COMPAT
100
 
Key_schedule v4_schedule;
101
 
CREDENTIALS v4_cred;
102
 
#endif
103
 
 
104
91
int     encrypt_flag = 0;
105
92
char    *krb_realm = (char *)0;
106
93
void    try_normal(char **);
128
115
     char **argv0;
129
116
{
130
117
    int rem, pid = 0;
131
 
    char *host=0, *cp, **ap, buf[RCMD_BUFSIZ], *args, **argv = argv0, *user = 0;
 
118
    char *host=0, **ap, buf[RCMD_BUFSIZ], *args, **argv = argv0, *user = 0;
132
119
    register int cc;
133
120
    struct passwd *pwd;
134
121
    fd_set readfrom, ready;
149
136
    krb5_error_code status;
150
137
    krb5_auth_context auth_context;
151
138
    int fflag = 0, Fflag = 0;
152
 
#ifdef KRB5_KRB4_COMPAT
153
 
    KTEXT_ST v4_ticket;
154
 
    MSG_DAT v4_msg_data;
155
 
#endif
156
139
#endif  /* KERBEROS */
157
140
    int debug_port = 0;
158
141
    enum kcmd_proto kcmd_proto = KCMD_PROTOCOL_COMPAT_HACK;
202
185
            fprintf(stderr, "rsh(kerberos): -k flag must have a realm after it.\n");
203
186
            exit (1);
204
187
        }
205
 
        if(!(krb_realm = (char *)malloc(strlen(*argv) + 1))){
 
188
        if(!(krb_realm = strdup(*argv))){
206
189
            fprintf(stderr, "rsh(kerberos): Cannot malloc.\n");
207
190
            exit(1);
208
191
        }
209
 
        strcpy(krb_realm, *argv);
210
192
        argv++, argc--;
211
193
        goto another;
212
194
    }
321
303
      cc += strlen(*ap) + 1;
322
304
    if (encrypt_flag)
323
305
      cc += 3;
324
 
    cp = args = (char *) malloc((unsigned) cc);
325
 
    if (encrypt_flag) {
326
 
      strcpy(args, "-x ");
327
 
      cp += 3;
328
 
    }
 
306
    args = (char *) malloc((unsigned) cc);
 
307
    *args = '\0';
 
308
    if (encrypt_flag)
 
309
      strlcpy(args, "-x ", cc);
329
310
    for (ap = argv; *ap; ap++) {
330
 
        (void) strcpy(cp, *ap);
331
 
        while (*cp)
332
 
          cp++;
 
311
      (void) strlcat(args, *ap, cc);
333
312
        if (ap[1])
334
 
          *cp++ = ' ';
 
313
          strlcat(args, " ", cc);
335
314
    }
336
315
 
337
316
    if(debug_port == 0) {
387
366
           ones.  */
388
367
        if (kcmd_proto == KCMD_NEW_PROTOCOL)
389
368
            exit (1);
390
 
#ifdef KRB5_KRB4_COMPAT
391
 
        /* No encrypted Kerberos 4 rsh. */
392
 
        if (encrypt_flag)
393
 
            exit(1);
394
 
#ifdef HAVE_ISATTY
395
 
        if (isatty(fileno(stderr)))
396
 
            fprintf(stderr, "Trying krb4 rsh...\n");
397
 
#endif
398
 
        status = k4cmd(&rem, &host, debug_port,
399
 
                       pwd->pw_name,
400
 
                       user ? user : pwd->pw_name, args,
401
 
                       &rfd2, &v4_ticket, "rcmd", krb_realm,
402
 
                       &v4_cred, v4_schedule, &v4_msg_data,
403
 
                       &local, &foreign, 0L, 0);
404
 
        if (status)
405
 
            try_normal(argv0);
406
 
        rcmd_stream_init_krb4(v4_cred.session, encrypt_flag, 0, 1);
407
 
#else
408
369
        try_normal(argv0);
409
 
#endif
410
370
    } else {
411
371
        krb5_keyblock *key = &cred->keyblock;
412
372