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

« back to all changes in this revision

Viewing changes to src/windows/identity/kmm/kmm_reg.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
1
/*
2
 
 * Copyright (c) 2004 Massachusetts Institute of Technology
 
2
 * Copyright (c) 2005 Massachusetts Institute of Technology
 
3
 * Copyright (c) 2006 Secure Endpoints Inc.
3
4
 *
4
5
 * Permission is hereby granted, free of charge, to any person
5
6
 * obtaining a copy of this software and associated documentation
96
97
    khm_int32 rv;
97
98
 
98
99
    if(!plugin || wcschr(plugin, L'/') || wcschr(plugin, L'\\'))
99
 
        return KHM_ERROR_INVALID_PARM;
 
100
        return KHM_ERROR_INVALID_PARAM;
100
101
 
101
102
    if(KHM_FAILED(kmm_get_plugins_config(flags, &csplugins)))
102
103
        return KHM_ERROR_UNKNOWN;
118
119
    khm_int32 rv;
119
120
 
120
121
    if(!module || wcschr(module, L'/') || wcschr(module, L'\\'))
121
 
        return KHM_ERROR_INVALID_PARM;
 
122
        return KHM_ERROR_INVALID_PARAM;
122
123
 
123
124
    if(KHM_FAILED(kmm_get_modules_config(flags, &csmodules)))
124
125
        return KHM_ERROR_UNKNOWN;
143
144
    config_flags &= ~KHM_FLAG_CREATE;
144
145
 
145
146
    if((plugin == NULL) ||
146
 
        (plugin->dependencies && 
147
 
         KHM_FAILED(multi_string_length_cch(plugin->dependencies, KMM_MAXCCH_DEPS, &cch))) ||
148
 
       FAILED(StringCchLength(plugin->module, KMM_MAXCCH_NAME - 1, &cch)) ||
149
 
       (plugin->description && 
150
 
        FAILED(StringCchLength(plugin->description, KMM_MAXCCH_DESC - 1, &cch))) ||
151
 
       FAILED(StringCchLength(plugin->name, KMM_MAXCCH_NAME - 1, &cch)))
 
147
       (plugin->dependencies && 
 
148
        KHM_FAILED(multi_string_length_cch(plugin->dependencies, 
 
149
                                           KMM_MAXCCH_DEPS, &cch))) ||
 
150
       FAILED(StringCchLength(plugin->module, KMM_MAXCCH_NAME, &cch)) ||
 
151
       (plugin->description &&
 
152
        FAILED(StringCchLength(plugin->description,
 
153
                               KMM_MAXCCH_DESC, &cch))) ||
 
154
       FAILED(StringCchLength(plugin->name, KMM_MAXCCH_NAME, &cch)))
152
155
    {
153
 
        return KHM_ERROR_INVALID_PARM;
 
156
        return KHM_ERROR_INVALID_PARAM;
154
157
    }
155
158
 
156
159
    /* note that we are retaining the length of the plugin name in
177
180
        rv = khc_write_string(csp_plugin, L"Description", plugin->description);
178
181
        CKRV;
179
182
    }
 
183
 
180
184
    if(plugin->dependencies) {
181
 
        rv = khc_write_multi_string(csp_plugin, L"Dependencies", plugin->dependencies);
 
185
        rv = khc_write_multi_string(csp_plugin, L"Dependencies", 
 
186
                                    plugin->dependencies);
182
187
        CKRV;
183
188
    }
 
189
 
184
190
    rv = khc_write_int32(csp_plugin, L"Type", plugin->type);
185
191
    CKRV;
186
 
    rv = khc_write_int32(csp_plugin, L"Flags", plugin->flags);
 
192
    rv = khc_write_int32(csp_plugin, L"Disabled",
 
193
                         !!(plugin->flags & KMM_PLUGIN_FLAG_DISABLED));
187
194
    CKRV;
188
195
 
189
196
    {
192
199
        size_t scb = 0;
193
200
 
194
201
        rv = khc_read_multi_string(csp_module, L"PluginList", NULL, &cb);
195
 
        if(rv != KHM_ERROR_TOO_LONG)
196
 
            goto _exit;
 
202
        if(rv != KHM_ERROR_TOO_LONG) {
 
203
            if (rv == KHM_ERROR_NOT_FOUND) {
 
204
 
 
205
                scb = cb = cch * sizeof(wchar_t);
 
206
                pl = PMALLOC(cb);
 
207
                multi_string_init(pl, cb);
 
208
                rv = KHM_ERROR_SUCCESS;
 
209
 
 
210
                goto add_plugin_to_list;
 
211
 
 
212
            } else {
 
213
                goto _exit;
 
214
            }
 
215
        }
197
216
 
198
217
        cb += cch * sizeof(wchar_t);
199
218
        scb = cb;
200
219
 
201
 
        pl = malloc(cb);
 
220
        pl = PMALLOC(cb);
202
221
 
203
 
        rv = khc_read_multi_string(csp_module, L"PluginList", NULL, &cb);
 
222
        rv = khc_read_multi_string(csp_module, L"PluginList", pl, &cb);
204
223
        if(KHM_FAILED(rv)) {
205
224
            if(pl)
206
 
                free(pl);
 
225
                PFREE(pl);
207
226
            goto _exit;
208
227
        }
209
228
 
 
229
    add_plugin_to_list:
 
230
 
210
231
        if(!multi_string_find(pl, plugin->name, 0)) {
211
232
            multi_string_append(pl, &scb, plugin->name);
212
233
            rv = khc_write_multi_string(csp_module, L"PluginList", pl);
213
234
        }
214
235
 
215
 
        free(pl);
 
236
        PFREE(pl);
216
237
        CKRV;
217
238
    }
218
239
 
236
257
    int i;
237
258
 
238
259
    if((module == NULL) ||
239
 
        FAILED(StringCchLength(module->name, KMM_MAXCCH_NAME - 1, &cch)) ||
 
260
        FAILED(StringCchLength(module->name, KMM_MAXCCH_NAME, &cch)) ||
240
261
        (module->description && 
241
 
            FAILED(StringCchLength(module->description, KMM_MAXCCH_DESC - 1, &cch))) ||
 
262
            FAILED(StringCchLength(module->description, 
 
263
                                   KMM_MAXCCH_DESC, &cch))) ||
242
264
        FAILED(StringCchLength(module->path, MAX_PATH, &cch)) ||
243
 
        (module->n_plugins > 0 && module->plugin_reg_info == NULL))
244
 
    {
245
 
        return KHM_ERROR_INVALID_PARM;
 
265
        (module->n_plugins > 0 && module->plugin_reg_info == NULL)) {
 
266
        return KHM_ERROR_INVALID_PARAM;
246
267
    }
247
268
 
248
269
#define CKRV if(KHM_FAILED(rv)) goto _exit
249
270
 
250
 
    rv = kmm_get_module_config(module->name, config_flags | KHM_FLAG_CREATE, &csp_module);
 
271
    rv = kmm_get_module_config(module->name, config_flags | KHM_FLAG_CREATE, 
 
272
                               &csp_module);
251
273
    CKRV;
252
274
 
253
 
    if(module->description) {
254
 
        rv = khc_write_string(csp_module, L"Description", module->description);
255
 
        CKRV;
256
 
    }
257
275
    rv = khc_write_string(csp_module, L"ImagePath", module->path);
258
276
    CKRV;
259
277
 
260
 
    rv = khc_write_int32(csp_module, L"Flags", 0);
 
278
    rv = khc_write_int32(csp_module, L"Disabled", 0);
261
279
    CKRV;
262
280
 
263
281
    /* FileVersion and ProductVersion will be set when the module
264
282
       is loaded for the first time */
265
283
 
266
284
    for(i=0; i<module->n_plugins; i++) {
267
 
        rv = kmm_register_plugin(module->plugin_reg_info + i, config_flags);
 
285
        rv = kmm_register_plugin(&(module->plugin_reg_info[i]), config_flags);
268
286
        CKRV;
269
287
    }
270
288
 
279
297
KHMEXP khm_int32   KHMAPI 
280
298
kmm_unregister_plugin(wchar_t * plugin, khm_int32 config_flags)
281
299
{
282
 
    /*TODO: implement this */
283
 
    return KHM_ERROR_NOT_IMPLEMENTED;
 
300
    khm_handle csp_plugin = NULL;
 
301
    khm_int32 rv = KHM_ERROR_SUCCESS;
 
302
 
 
303
    rv = kmm_get_plugin_config(plugin, config_flags, &csp_plugin);
 
304
 
 
305
    if (KHM_FAILED(rv))
 
306
        goto _cleanup;
 
307
 
 
308
    rv = khc_remove_space(csp_plugin);
 
309
 
 
310
 _cleanup:
 
311
 
 
312
    if (csp_plugin)
 
313
        khc_close_space(csp_plugin);
 
314
 
 
315
    return rv;
284
316
}
285
317
 
286
318
KHMEXP khm_int32   KHMAPI 
287
319
kmm_unregister_module(wchar_t * module, khm_int32 config_flags)
288
320
{
289
 
    /*TODO: implement this */
290
 
    return KHM_ERROR_NOT_IMPLEMENTED;
 
321
    khm_handle csp_module = NULL;
 
322
    khm_int32 rv = KHM_ERROR_SUCCESS;
 
323
 
 
324
    rv = kmm_get_module_config(module, config_flags, &csp_module);
 
325
 
 
326
    if (KHM_FAILED(rv))
 
327
        goto _cleanup;
 
328
 
 
329
    rv = khc_remove_space(csp_module);
 
330
 
 
331
 _cleanup:
 
332
    if (csp_module)
 
333
        khc_close_space(csp_module);
 
334
 
 
335
    return rv;
291
336
}