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

« back to all changes in this revision

Viewing changes to src/windows/identity/plugins/krb4/krb4main.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 10:28:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20061030102853-x7v876vw4af46v0m
Tags: 1.4.4-3ubuntu1
* Merge with Debian; only Ubuntu change:
  - src/include/k5-thread.h: Define__USE_GNU when #include'ing pthread.h to
    fix FTBFS (from 1.4.3-9ubuntu1).

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
 
 
30
kmm_module h_khModule; /* KMM's handle to this module */
 
31
HINSTANCE hInstance;
 
32
HMODULE hResModule;    /* HMODULE to the resource library */
 
33
 
 
34
khm_int32 type_id_enctype       = -1;
 
35
khm_int32 type_id_addr_list     = -1;
 
36
khm_int32 type_id_krb5_flags    = -1;
 
37
 
 
38
khm_int32 attr_id_key_enctype   = -1;
 
39
khm_int32 attr_id_tkt_enctype   = -1;
 
40
khm_int32 attr_id_addr_list     = -1;
 
41
khm_int32 attr_id_krb5_flags    = -1;
 
42
 
 
43
khm_handle csp_plugins          = NULL;
 
44
khm_handle csp_krbcred          = NULL;
 
45
khm_handle csp_params           = NULL;
 
46
 
 
47
kmm_module_locale locales[] = {
 
48
    LOCALE_DEF(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US), L"krb4cred_en_us.dll", KMM_MLOC_FLAG_DEFAULT)
 
49
};
 
50
 
 
51
int n_locales = ARRAYLENGTH(locales);
 
52
 
 
53
/* These two probably should not do anything */
 
54
void init_krb() {
 
55
}
 
56
 
 
57
void exit_krb() {
 
58
}
 
59
 
 
60
/* called by the NetIDMgr module manager */
 
61
KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) {
 
62
    khm_int32 rv = KHM_ERROR_SUCCESS;
 
63
    kmm_plugin_reg pi;
 
64
    wchar_t buf[256];
 
65
 
 
66
    h_khModule = h_module;
 
67
 
 
68
    rv = kmm_set_locale_info(h_module, locales, n_locales);
 
69
    if(KHM_SUCCEEDED(rv)) {
 
70
        hResModule = kmm_get_resource_hmodule(h_module);
 
71
    } else
 
72
        goto _exit;
 
73
 
 
74
    ZeroMemory(&pi, sizeof(pi));
 
75
    pi.name = KRB4_PLUGIN_NAME;
 
76
    pi.type = KHM_PITYPE_CRED;
 
77
    pi.icon = LoadImage(hResModule, MAKEINTRESOURCE(IDI_PLUGIN),
 
78
                        IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
 
79
    pi.flags = 0;
 
80
    pi.msg_proc = krb4_cb;
 
81
    pi.dependencies = KRB4_PLUGIN_DEPS;
 
82
    pi.description = buf;
 
83
    LoadString(hResModule, IDS_PLUGIN_DESC,
 
84
               buf, ARRAYLENGTH(buf));
 
85
    kmm_provide_plugin(h_module, &pi);
 
86
 
 
87
    if(KHM_FAILED(rv = init_imports()))
 
88
        goto _exit;
 
89
 
 
90
    if(KHM_FAILED(rv = init_error_funcs()))
 
91
        goto _exit;
 
92
 
 
93
    rv = kmm_get_plugins_config(0, &csp_plugins);
 
94
    if(KHM_FAILED(rv)) goto _exit;
 
95
 
 
96
    rv = khc_load_schema(csp_plugins, schema_krbconfig);
 
97
    if(KHM_FAILED(rv)) goto _exit;
 
98
 
 
99
    rv = khc_open_space(csp_plugins, CSNAME_KRB4CRED, 0, &csp_krbcred);
 
100
    if(KHM_FAILED(rv)) goto _exit;
 
101
 
 
102
    rv = khc_open_space(csp_krbcred, CSNAME_PARAMS, 0, &csp_params);
 
103
    if(KHM_FAILED(rv)) goto _exit;
 
104
 
 
105
 _exit:
 
106
    return rv;
 
107
}
 
108
 
 
109
/* called by the NetIDMgr module manager */
 
110
KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module) {
 
111
    exit_imports();
 
112
    exit_error_funcs();
 
113
 
 
114
    if(csp_params) {
 
115
        khc_close_space(csp_params);
 
116
        csp_params = NULL;
 
117
    }
 
118
 
 
119
    if(csp_krbcred) {
 
120
        khc_close_space(csp_krbcred);
 
121
        csp_krbcred = NULL;
 
122
    }
 
123
 
 
124
    if(csp_plugins) {
 
125
        khc_unload_schema(csp_plugins, schema_krbconfig);
 
126
        khc_close_space(csp_plugins);
 
127
        csp_plugins = NULL;
 
128
    }
 
129
 
 
130
    return KHM_ERROR_SUCCESS;  /* the return code is ignored */
 
131
}
 
132
 
 
133
BOOL WINAPI DllMain(
 
134
  HINSTANCE hinstDLL,
 
135
  DWORD fdwReason,
 
136
  LPVOID lpvReserved
 
137
)
 
138
{
 
139
    switch(fdwReason) {
 
140
        case DLL_PROCESS_ATTACH:
 
141
            hInstance = hinstDLL;
 
142
            init_krb();
 
143
            break;
 
144
 
 
145
        case DLL_PROCESS_DETACH:
 
146
            exit_krb();
 
147
            break;
 
148
 
 
149
        case DLL_THREAD_ATTACH:
 
150
            break;
 
151
 
 
152
        case DLL_THREAD_DETACH:
 
153
            break;
 
154
    }
 
155
 
 
156
    return TRUE;
 
157
}