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

« back to all changes in this revision

Viewing changes to src/ccapi/server/win/ccs_win_pipe.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
/*
 
2
 * $Header$
 
3
 *
 
4
 * Copyright 2008 Massachusetts Institute of Technology.
 
5
 * All Rights Reserved.
 
6
 *
 
7
 * Export of this software from the United States of America may
 
8
 * require a specific license from the United States Government.
 
9
 * It is the responsibility of any person or organization contemplating
 
10
 * export to obtain such a license before exporting.
 
11
 *
 
12
 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
 
13
 * distribute this software and its documentation for any purpose and
 
14
 * without fee is hereby granted, provided that the above copyright
 
15
 * notice appear in all copies and that both that copyright notice and
 
16
 * this permission notice appear in supporting documentation, and that
 
17
 * the name of M.I.T. not be used in advertising or publicity pertaining
 
18
 * to distribution of the software without specific, written prior
 
19
 * permission.  Furthermore if you modify this software you must label
 
20
 * your software as modified software and not distribute it in such a
 
21
 * fashion that it might be confused with the original M.I.T. software.
 
22
 * M.I.T. makes no representations about the suitability of
 
23
 * this software for any purpose.  It is provided "as is" without express
 
24
 * or implied warranty.
 
25
 */
 
26
 
 
27
#include "assert.h"
 
28
#include <stdlib.h>
 
29
#include <malloc.h>
 
30
 
 
31
#include "ccs_win_pipe.h"
 
32
#include "cci_debugging.h"
 
33
 
 
34
/* Ref:
 
35
struct ccs_win_pipe_t {
 
36
    char*   uuid;
 
37
    HANDLE  clientHandle;
 
38
    }
 
39
 */
 
40
 
 
41
/* ------------------------------------------------------------------------ */
 
42
 
 
43
struct ccs_win_pipe_t* ccs_win_pipe_new (const char* uuid, const HANDLE h) {
 
44
 
 
45
    cc_int32                err         = ccNoError;
 
46
    struct ccs_win_pipe_t*  out_pipe    = NULL;
 
47
    char*                   uuidCopy    = NULL;
 
48
 
 
49
    if (!err) {
 
50
        if (!uuid)      {err = cci_check_error(ccErrBadParam);}
 
51
        }
 
52
 
 
53
    if (!err) {
 
54
        uuidCopy = (char*)malloc(1+strlen(uuid));
 
55
        if (!uuidCopy)  {err = cci_check_error(ccErrBadParam);}
 
56
        strcpy(uuidCopy, uuid);
 
57
        }
 
58
    
 
59
    if (!err) {
 
60
        out_pipe = (struct ccs_win_pipe_t*)malloc(sizeof(struct ccs_win_pipe_t));
 
61
        if (!out_pipe)  {err = cci_check_error(ccErrBadParam);}
 
62
        out_pipe->uuid          = uuidCopy;
 
63
        out_pipe->clientHandle  = h;
 
64
        }
 
65
#if 0
 
66
    cci_debug_printf("0x%X = %s(%s, 0x%X)", out_pipe, __FUNCTION__, uuid, h);
 
67
#endif
 
68
    return out_pipe;
 
69
    }
 
70
 
 
71
/* ------------------------------------------------------------------------ */
 
72
 
 
73
cc_int32 ccs_win_pipe_copy (WIN_PIPE** out_pipe, 
 
74
                            const WIN_PIPE* in_pipe) {
 
75
 
 
76
    *out_pipe = 
 
77
        ccs_win_pipe_new(
 
78
            ccs_win_pipe_getUuid  (in_pipe),
 
79
            ccs_win_pipe_getHandle(in_pipe) );
 
80
 
 
81
    return (*out_pipe) ? ccNoError : ccErrBadParam;
 
82
    }
 
83
 
 
84
/* ------------------------------------------------------------------------ */
 
85
 
 
86
cc_int32 ccs_win_pipe_release(const WIN_PIPE* in_pipe) {
 
87
 
 
88
    cc_int32 err = ccNoError;
 
89
 
 
90
    if (!ccs_win_pipe_valid(in_pipe))   {err = cci_check_error(ccErrBadParam);}
 
91
 
 
92
    if (!err) {
 
93
        if (!in_pipe->uuid) free(in_pipe->uuid);
 
94
        if (!in_pipe)       free(in_pipe);
 
95
        }
 
96
 
 
97
    return err;
 
98
    }
 
99
 
 
100
/* ------------------------------------------------------------------------ */
 
101
 
 
102
cc_int32 ccs_win_pipe_valid (const WIN_PIPE* in_pipe) {
 
103
 
 
104
    if (!in_pipe) {
 
105
        cci_check_error(ccErrBadParam);
 
106
        return FALSE;
 
107
        }
 
108
 
 
109
    if (!in_pipe->uuid) {
 
110
        cci_check_error(ccErrBadParam);
 
111
        return FALSE;
 
112
        }
 
113
 
 
114
    return TRUE;
 
115
    }
 
116
 
 
117
/* ------------------------------------------------------------------------ */
 
118
 
 
119
cc_int32 ccs_win_pipe_compare    (const WIN_PIPE*   in_pipe_1,
 
120
                                  const WIN_PIPE*   in_pipe_2,
 
121
                                  cc_uint32         *out_equal) {
 
122
 
 
123
    cc_int32 err    = ccNoError;
 
124
    int      seq    = 0;
 
125
    *out_equal      = FALSE;
 
126
 
 
127
    if (!ccs_win_pipe_valid(in_pipe_1)) {err = cci_check_error(ccErrBadParam);}
 
128
    if (!ccs_win_pipe_valid(in_pipe_2)) {err = cci_check_error(ccErrBadParam);}
 
129
    if (!out_equal)                     {err = cci_check_error(ccErrBadParam);}
 
130
 
 
131
    /* A disconnect doesn't have a tls* with it -- only the uuid.  SO only
 
132
       compare the uuids.
 
133
     */
 
134
    if (!err) {
 
135
        seq = strcmp(   ccs_win_pipe_getUuid(in_pipe_1),
 
136
                        ccs_win_pipe_getUuid(in_pipe_2) );
 
137
        *out_equal = (seq == 0);
 
138
        }
 
139
 
 
140
    return err;
 
141
    }
 
142
 
 
143
/* ------------------------------------------------------------------------ */
 
144
 
 
145
char* ccs_win_pipe_getUuid    (const WIN_PIPE* in_pipe) {
 
146
 
 
147
    char*   result = NULL;
 
148
 
 
149
    if (!ccs_win_pipe_valid(in_pipe)) {cci_check_error(ccErrBadParam);}
 
150
    else                              {result = in_pipe->uuid;}
 
151
 
 
152
    return result;
 
153
    }
 
154
 
 
155
/* ------------------------------------------------------------------------ */
 
156
 
 
157
HANDLE ccs_win_pipe_getHandle  (const WIN_PIPE* in_pipe) {
 
158
 
 
159
    HANDLE result = NULL;
 
160
 
 
161
    if (!ccs_win_pipe_valid(in_pipe)) {cci_check_error(ccErrBadParam);}
 
162
    else                              {result = in_pipe->clientHandle;}
 
163
 
 
164
    return result;
 
165
    }