Esempio n. 1
0
/* Called with cs_credtype held */
void kcdb_credtype_check_and_delete(khm_int32 id)
{
    kcdb_credtype_i * ict;

#ifdef DEBUG
    assert(id >= 1 && id <= KCDB_CREDTYPE_MAX_ID);
#endif
    if (id < 1 || id > KCDB_CREDTYPE_MAX_ID)
        return;

    ict = kcdb_credtype_tbl[id];
    if(!ict)
        return;

    if((ict->flags & KCDB_CTI_FLAG_DELETED) &&
        !ict->refcount)
    {
        kcdb_credtype_tbl[id] = NULL;
        LDELETE(&kcdb_credtypes, ict);

        PFREE(ict->ct.name);
        if(ict->ct.short_desc)
            PFREE(ict->ct.short_desc);
        if(ict->ct.long_desc)
            PFREE(ict->ct.long_desc);
        if(ict->ct.sub)
            kmq_delete_subscription(ict->ct.sub);

        PFREE(ict);
    }
}
Esempio n. 2
0
khm_int32
handle_kmsg_ident_exit(void)
{

    /* TODO: Additional uninitialization code goes here */

    if (idprov_sub) {
        kmq_delete_subscription(idprov_sub);
        idprov_sub = NULL;
    }

    return KHM_ERROR_SUCCESS;
}
Esempio n. 3
0
/* called with cs_identpro held */
static void
identpro_check_and_deleteL(kcdb_identpro_i * p)
{
    if (!(p->flags & KCDB_IDENTPRO_FLAG_DELETED) ||
        p->refcount > 0)
        return;

    p->magic = 0;
    if (p->name)
        PFREE(p->name);
    if (p->sub)
        kmq_delete_subscription(p->sub);
    if (p->plugin)
        kmm_release_plugin(p->plugin);
    LDELETE(&deleted_id_providers, p);
    ZeroMemory(p, sizeof(*p));
    PFREE(p);
}
Esempio n. 4
0
void
afs_free_extension(khm_int32 idx) {
    afs_extension * ext;

#ifdef DEBUG
    assert(idx >= 0 && idx < (khm_int32) n_extensions);
#endif

    ext = &extensions[idx];

    if (ext->name)
        PFREE((void *) ext->name);
    if (ext->token_acq.short_desc)
        PFREE((void *) ext->token_acq.short_desc);
    if (ext->token_acq.long_desc)
        PFREE((void *) ext->token_acq.long_desc);
    if (ext->sub)
        kmq_delete_subscription(ext->sub);

    ZeroMemory(ext, sizeof(*ext));
}
Esempio n. 5
0
/* Handler for system messages.  The only two we handle are
   KMSG_SYSTEM_INIT and KMSG_SYSTEM_EXIT. */
khm_int32 KHMAPI
handle_kmsg_system(khm_int32 msg_type,
                   khm_int32 msg_subtype,
                   khm_ui_4  uparam,
                   void *    vparam) {
    khm_int32 rv = KHM_ERROR_SUCCESS;

    switch (msg_subtype) {

        /* This is the first message that will be received by a
           plugin.  We use it to perform initialization operations
           such as registering any credential types, data types and
           attributes. */
    case KMSG_SYSTEM_INIT:
        {
            wchar_t short_desc[KCDB_MAXCCH_SHORT_DESC];
            wchar_t long_desc[KCDB_MAXCCH_LONG_DESC];
#ifdef USE_CONFIGURATION_PANELS
            khui_config_node_reg creg;
#endif
            afs_msg_announce announce;

            if (KHM_FAILED(kmq_find_type(AFS_MSG_TYPENAME, &msg_type_afs))) {
                return KHM_ERROR_UNKNOWN;
            }

            /* We must first announce our extension plug-in, so that
               the AFS plug-in will know we exist */
            announce.cbsize = sizeof(announce);
            announce.version = AFS_PLUGIN_VERSION;
            announce.name = MYPLUGIN_NAMEW;

            kmq_create_subscription(handle_AFS_MSG, &announce.sub);

            /* Set to TRUE if we are providing a token acquisition
               method */
            announce.provide_token_acq = TRUE;

            LoadString(hResModule, IDS_TKMETHOD_SHORT_DESC,
                       short_desc, ARRAYLENGTH(short_desc));

            announce.token_acq.short_desc = short_desc;

            LoadString(hResModule, IDS_TKMETHOD_LONG_DESC,
                       long_desc, ARRAYLENGTH(long_desc));

            announce.token_acq.long_desc = long_desc;

            if (KHM_FAILED(kmq_send_message(msg_type_afs,
                                            AFS_MSG_ANNOUNCE, 0, &announce))) {
                kmq_delete_subscription(announce.sub);
                announce.sub = NULL;

                return KHM_ERROR_UNKNOWN;
            }

            tk_method = announce.token_acq.method_id;

#ifdef USE_CONFIGURATION_PANELS

            /* Register our configuration panels. */

            /* Registering configuration panels is not required for
               extension plug-in.  As such, this bit of code is
               commented out.  However, if you wish to provide a
               configuration panel, you should uncomment this block
               and fill in the stub functions in config_main.c */

            ZeroMemory(&creg, sizeof(creg));

            short_desc[0] = L'\0';

            LoadString(hResModule, IDS_CFG_SHORT_DESC,
                       short_desc, ARRAYLENGTH(short_desc));

            long_desc[0] = L'\0';

            LoadString(hResModule, IDS_CFG_LONG_DESC,
                       long_desc, ARRAYLENGTH(long_desc));

            creg.name = CONFIGNODE_MAIN;
            creg.short_desc = short_desc;
            creg.long_desc = long_desc;
            creg.h_module = hResModule;
            creg.dlg_template = MAKEINTRESOURCE(IDD_CONFIG);
            creg.dlg_proc = config_dlgproc;
            creg.flags = 0;

            khui_cfg_register(NULL, &creg);
#endif
        }
        break;

        /* This is the last message that will be received by the
           plugin. */
    case KMSG_SYSTEM_EXIT:
        {
            khui_config_node cnode;

            /* It should not be assumed that initialization of the
               plugin went well at this point since we receive a
               KMSG_SYSTEM_EXIT even if the initialization failed. */

            /* Now unregister any configuration nodes we registered. */

            if (KHM_SUCCEEDED(khui_cfg_open(NULL, CONFIGNODE_MAIN, &cnode))) {
                khui_cfg_remove(cnode);
                khui_cfg_release(cnode);
            }

            /* TODO: Perform additional uninitialization
               operations. */
        }
        break;
    }

    return rv;
}
Esempio n. 6
0
static kcdb_identpro_i *
identpro_create_with_plugin(kmm_plugin plugin, khm_handle sub)
{
    kmm_plugin_info pi;
    kcdb_identpro_i * p;
    size_t len;

    ZeroMemory(&pi, sizeof(pi));
    if (KHM_FAILED(kmm_get_plugin_info_i(plugin, &pi)))
        return NULL;

    if (pi.reg.type != KHM_PITYPE_IDENT) {
        kmm_release_plugin_info_i(&pi);
#ifdef DEBUG
        assert(FALSE);
#endif
        return NULL;
    }

    if (FAILED(StringCbLength(pi.reg.name, KMM_MAXCB_NAME, &len)))
        return NULL;
    len += sizeof(wchar_t);

    /* we need to check if the plug-in is already there, both in the
       current and the deleted lists */
    EnterCriticalSection(&cs_identpro);
    for (p = QTOP(&id_providers); p; p = QNEXT(p)) {
        if (p->plugin == plugin)
            break;
    }

    if (p == NULL)
        for (p = deleted_id_providers; p; p = LNEXT(p)) {
            if (p->plugin == plugin ||
                !wcscmp(p->name, pi.reg.name))
                break;
        }

    if (p)
        identpro_hold(p);

    if (p == NULL) {
        p = PMALLOC(sizeof(*p));
        ZeroMemory(p, sizeof(*p));

        p->magic = KCDB_IDENTPRO_MAGIC;
        p->name = PMALLOC(len);
        StringCbCopy(p->name, len, pi.reg.name);
        p->sub = sub;
        p->plugin = plugin;
        kmm_hold_plugin(plugin);

        p->refcount = 1;            /* initially held */

        QPUT(&id_providers, p);

        n_id_providers++;
        kcdbint_identpro_post_message(KCDB_OP_INSERT, p);

    } else if (p->flags & KCDB_IDENTPRO_FLAG_DELETED) {

        LDELETE(&deleted_id_providers, p);
        p->flags &= ~KCDB_IDENTPRO_FLAG_DELETED;
        if (p->plugin != plugin) {
            /* can happen if the plug-in was reloaded */
            if (p->plugin)
                kmm_release_plugin_info_i(p->plugin);
            p->plugin = plugin;
            kmm_hold_plugin(plugin);
        }

        if (p->sub) {
            kmq_delete_subscription(p->sub);
        }

        p->sub = sub;

        QPUT(&id_providers, p);
        n_id_providers++;
    }

    identpro_check_and_set_default_provider();
    LeaveCriticalSection(&cs_identpro);

    kmm_release_plugin_info_i(&pi);

    return p;
}