~ubuntu-branches/ubuntu/precise/krb5/precise-updates

« back to all changes in this revision

Viewing changes to src/windows/identity/plugins/krb5/krb5props.c

  • Committer: Package Import Robot
  • Author(s): Sam Hartman
  • Date: 2011-12-01 19:34:41 UTC
  • mfrom: (28.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20111201193441-9tipg3aru1jsidyv
Tags: 1.10+dfsg~alpha1-6
* Fix segfault with unknown hostnames in krb5_sname_to_principal,
  Closes: #650671
* Indicate that this library breaks libsmbclient versions that depend on
  krb5_locate_kdc, Closes: #650603, #650611

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2005 Massachusetts Institute of Technology
3
 
 *
4
 
 * Permission is hereby granted, free of charge, to any person
5
 
 * obtaining a copy of this software and associated documentation
6
 
 * files (the "Software"), to deal in the Software without
7
 
 * restriction, including without limitation the rights to use, copy,
8
 
 * modify, merge, publish, distribute, sublicense, and/or sell copies
9
 
 * of the Software, and to permit persons to whom the Software is
10
 
 * furnished to do so, subject to the following conditions:
11
 
 *
12
 
 * The above copyright notice and this permission notice shall be
13
 
 * included in all copies or substantial portions of the Software.
14
 
 *
15
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
 
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19
 
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20
 
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
 
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 
 * SOFTWARE.
23
 
 */
24
 
 
25
 
/* $Id$ */
26
 
 
27
 
#include<krbcred.h>
28
 
#include<kherror.h>
29
 
#include<khmsgtypes.h>
30
 
#include<commctrl.h>
31
 
#include<strsafe.h>
32
 
#include<krb5.h>
33
 
#ifdef DEBUG
34
 
#include<assert.h>
35
 
#endif
36
 
 
37
 
/* Property page
38
 
 
39
 
   Runs in the context of the UI thread.
40
 
   */
41
 
INT_PTR CALLBACK krb5_pp_proc(HWND hwnd,
42
 
    UINT uMsg,
43
 
    WPARAM wParam,
44
 
    LPARAM lParam
45
 
    )
46
 
{
47
 
    switch(uMsg) {
48
 
    case WM_INITDIALOG:
49
 
        {
50
 
            khui_property_sheet * s;
51
 
            PROPSHEETPAGE * p;
52
 
            wchar_t buf[512];
53
 
            wchar_t unavailable[64];
54
 
            khm_size cbsize;
55
 
            khm_int32 rv;
56
 
            khm_int32 tflags;
57
 
 
58
 
            p = (PROPSHEETPAGE *) lParam;
59
 
            s = (khui_property_sheet *) p->lParam;
60
 
 
61
 
#pragma warning(push)
62
 
#pragma warning(disable: 4244)
63
 
            SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) s);
64
 
#pragma warning(pop)
65
 
 
66
 
            LoadString(hResModule, IDS_UNAVAILABLE,
67
 
                       unavailable, ARRAYLENGTH(unavailable));
68
 
 
69
 
            if(s->cred) {
70
 
                cbsize = sizeof(buf);
71
 
                kcdb_cred_get_name(s->cred, buf, &cbsize);
72
 
                SetDlgItemText(hwnd, IDC_PPK5_NAME, buf);
73
 
 
74
 
                cbsize = sizeof(buf);
75
 
                rv = kcdb_cred_get_attr_string(s->cred,
76
 
                                               KCDB_ATTR_ISSUE,
77
 
                                               buf, &cbsize, 0);
78
 
                if (KHM_SUCCEEDED(rv))
79
 
                    SetDlgItemText(hwnd, IDC_PPK5_ISSUE, buf);
80
 
                else
81
 
                    SetDlgItemText(hwnd, IDC_PPK5_ISSUE, unavailable);
82
 
 
83
 
                cbsize = sizeof(buf);
84
 
                rv = kcdb_cred_get_attr_string(s->cred,
85
 
                                               KCDB_ATTR_EXPIRE,
86
 
                                               buf, &cbsize, 0);
87
 
                if (KHM_SUCCEEDED(rv))
88
 
                    SetDlgItemText(hwnd, IDC_PPK5_VALID, buf);
89
 
                else
90
 
                    SetDlgItemText(hwnd, IDC_PPK5_VALID, unavailable);
91
 
 
92
 
                cbsize = sizeof(buf);
93
 
                rv = kcdb_cred_get_attr_string(s->cred,
94
 
                                               KCDB_ATTR_RENEW_EXPIRE,
95
 
                                               buf, &cbsize, 0);
96
 
                if (KHM_SUCCEEDED(rv))
97
 
                    SetDlgItemText(hwnd, IDC_PPK5_RENEW, buf);
98
 
                else
99
 
                    SetDlgItemText(hwnd, IDC_PPK5_RENEW, unavailable);
100
 
 
101
 
                tflags = 0;
102
 
                cbsize = sizeof(tflags);
103
 
                rv = kcdb_cred_get_attr(s->cred,
104
 
                                        attr_id_krb5_flags,
105
 
                                        NULL,
106
 
                                        &tflags,
107
 
                                        &cbsize);
108
 
                if (KHM_SUCCEEDED(rv)) {
109
 
 
110
 
#define ADDBITFLAG(f,s) \
111
 
   if (tflags & f) {    \
112
 
     LoadString(hResModule, s, buf, ARRAYLENGTH(buf)); \
113
 
     SendDlgItemMessage(hwnd, IDC_PPK5_FLAGS, LB_ADDSTRING, 0, (LPARAM) buf); \
114
 
   }
115
 
 
116
 
                    ADDBITFLAG(TKT_FLG_FORWARDABLE, IDS_FLG_FORWARDABLE);
117
 
                    ADDBITFLAG(TKT_FLG_FORWARDED, IDS_FLG_FORWARDED);
118
 
                    ADDBITFLAG(TKT_FLG_PROXIABLE, IDS_FLG_PROXIABLE);
119
 
                    ADDBITFLAG(TKT_FLG_PROXY, IDS_FLG_PROXY);
120
 
                    ADDBITFLAG(TKT_FLG_MAY_POSTDATE, IDS_FLG_MAY_POSTDATE);
121
 
                    ADDBITFLAG(TKT_FLG_POSTDATED, IDS_FLG_POSTDATED);
122
 
                    ADDBITFLAG(TKT_FLG_INVALID, IDS_FLG_INVALID);
123
 
                    ADDBITFLAG(TKT_FLG_RENEWABLE, IDS_FLG_RENEWABLE);
124
 
                    ADDBITFLAG(TKT_FLG_INITIAL, IDS_FLG_INITIAL);
125
 
                    ADDBITFLAG(TKT_FLG_PRE_AUTH, IDS_FLG_PRE_AUTH);
126
 
                    ADDBITFLAG(TKT_FLG_HW_AUTH, IDS_FLG_HW_AUTH);
127
 
                    ADDBITFLAG(TKT_FLG_TRANSIT_POLICY_CHECKED, IDS_FLG_TRANSIT_POL);
128
 
                    ADDBITFLAG(TKT_FLG_OK_AS_DELEGATE, IDS_FLG_OK_DELEGATE);
129
 
                    ADDBITFLAG(TKT_FLG_ANONYMOUS, IDS_FLG_ANONYMOUS);
130
 
 
131
 
#undef ADDBITFLAG
132
 
 
133
 
                }
134
 
            } else {
135
 
#ifdef DEBUG
136
 
                assert(FALSE);
137
 
#endif
138
 
            }
139
 
        }
140
 
        return FALSE;
141
 
    }
142
 
 
143
 
    return FALSE;
144
 
}
145
 
 
146
 
void k5_pp_begin(khui_property_sheet * s)
147
 
{
148
 
    PROPSHEETPAGE *p;
149
 
 
150
 
    if(s->credtype == credtype_id_krb5 &&
151
 
       s->cred) {
152
 
        p = PMALLOC(sizeof(*p));
153
 
        ZeroMemory(p, sizeof(*p));
154
 
 
155
 
        p->dwSize = sizeof(*p);
156
 
        p->dwFlags = 0;
157
 
        p->hInstance = hResModule;
158
 
        p->pszTemplate = MAKEINTRESOURCE(IDD_PP_KRB5C);
159
 
        p->pfnDlgProc = krb5_pp_proc;
160
 
        p->lParam = (LPARAM) s;
161
 
        khui_ps_add_page(s, credtype_id_krb5, 0, p, NULL);
162
 
    }
163
 
}
164
 
 
165
 
void k5_pp_end(khui_property_sheet * s)
166
 
{
167
 
    khui_property_page * p = NULL;
168
 
 
169
 
    khui_ps_find_page(s, credtype_id_krb5, &p);
170
 
    if(p) {
171
 
        if(p->p_page)
172
 
            PFREE(p->p_page);
173
 
        p->p_page = NULL;
174
 
    }
175
 
}