コード例 #1
0
ファイル: credset.c プロジェクト: aosm/Kerberos
KHMEXP khm_int32 KHMAPI 
kcdb_credset_collect_filtered(khm_handle cs_dest,
			      khm_handle cs_src,
			      kcdb_cred_filter_func filter,
			      void * rock,
			      khm_int32 * delta)
{
    kcdb_credset * cs;
    kcdb_credset * rcs;
    khm_int32 code = KHM_ERROR_SUCCESS;
    kcdb_cred ** r_sel = NULL;
    kcdb_cred ** c_sel = NULL;
    int nr_sel, nc_sel;
    int i;
    khm_int32 cs_f = 0;
    khm_int32 rcs_f = 0;

    if((cs_src && !kcdb_credset_is_credset(cs_src)) ||
        (cs_dest && !kcdb_credset_is_credset(cs_dest)) ||
        (cs_src == cs_dest)) /* works because credsets use shared
                                handles */
        return KHM_ERROR_INVALID_PARAM;

    if(cs_src)
        cs = (kcdb_credset *) cs_src;
    else {
        cs = kcdb_root_credset;
        cs_f = KCDB_CREDCOLL_FILTER_ROOT;
    }

    if(cs_dest)
        rcs = (kcdb_credset *) cs_dest;
    else {
        rcs = kcdb_root_credset;
        rcs_f = KCDB_CREDCOLL_FILTER_ROOT;
    }

    if (kcdb_credset_is_sealed(rcs))
        return KHM_ERROR_INVALID_OPERATION;

    EnterCriticalSection(&(cs->cs));
    EnterCriticalSection(&(rcs->cs));

#ifdef DEBUG
    assert(!(rcs->flags & KCDB_CREDSET_FLAG_ENUM));
    assert(!(cs->flags & KCDB_CREDSET_FLAG_ENUM));
#endif

    if(rcs->nclist)
        r_sel = PMALLOC(sizeof(kcdb_cred *) * rcs->nclist);
    if(cs->nclist)
        c_sel = PMALLOC(sizeof(kcdb_cred *) * cs->nclist);
    nr_sel = 0;
    nc_sel = 0;

    rcs->flags |= KCDB_CREDSET_FLAG_ENUM;

    for(i=0; i<rcs->nclist; i++) {
        if(rcs->clist[i].cred && 
           (*filter)((khm_handle)rcs->clist[i].cred, 
                     KCDB_CREDCOLL_FILTER_DEST | rcs_f, 
                     rock))
        {
            r_sel[nr_sel++] = rcs->clist[i].cred;
        }
    }

    rcs->flags &= ~KCDB_CREDSET_FLAG_ENUM;
    cs->flags |= KCDB_CREDSET_FLAG_ENUM;

    for(i=0; i<cs->nclist; i++) {
        if(cs->clist[i].cred && filter((khm_handle)rcs->clist[i].cred, KCDB_CREDCOLL_FILTER_SRC | cs_f, rock))
        {
            c_sel[nc_sel++] = cs->clist[i].cred;
        }
    }

    cs->flags &= ~KCDB_CREDSET_FLAG_ENUM;

    rcs->version++;

    code = kcdb_credset_collect_core(
        rcs,
        r_sel,
        nr_sel,
        cs,
        c_sel,
        nc_sel,
        delta);

    LeaveCriticalSection(&(rcs->cs));
    LeaveCriticalSection(&(cs->cs));

    if(r_sel)
        PFREE(r_sel);
    if(c_sel)
        PFREE(c_sel);

    if (cs_dest == NULL) {
        kcdb_identity_refresh_all();
    }

    return code;
}
コード例 #2
0
ファイル: credset.c プロジェクト: aosm/Kerberos
KHMEXP khm_int32 KHMAPI 
kcdb_credset_collect(khm_handle cs_dest,
		     khm_handle cs_src, 
		     khm_handle identity, 
		     khm_int32 type,
		     khm_int32 * delta)
{
    kcdb_credset * cs;
    kcdb_credset * rcs;
    khm_int32 code = KHM_ERROR_SUCCESS;
    kcdb_cred ** r_sel = NULL;
    kcdb_cred ** c_sel = NULL;
    int nr_sel, nc_sel;
    int i;

    if((cs_src && !kcdb_credset_is_credset(cs_src)) ||
        (cs_dest && !kcdb_credset_is_credset(cs_dest)) ||
        (cs_src == cs_dest)) /* works because credsets use shared
                                handles */
        return KHM_ERROR_INVALID_PARAM;

    if(identity && !kcdb_is_active_identity(identity))
        return KHM_ERROR_INVALID_PARAM;

    if(cs_src)
        cs = (kcdb_credset *) cs_src;
    else
        cs = kcdb_root_credset;

    if(cs_dest)
        rcs = (kcdb_credset *) cs_dest;
    else
        rcs = kcdb_root_credset;

    if (kcdb_credset_is_sealed(rcs))
        return KHM_ERROR_INVALID_OPERATION;

    EnterCriticalSection(&(cs->cs));
    EnterCriticalSection(&(rcs->cs));

    /* enumerate through the root and given credential sets and select
       the ones we want */

    if(rcs->nclist > 0)
        r_sel = PMALLOC(sizeof(kcdb_cred *) * rcs->nclist);
    if(cs->nclist > 0)
        c_sel = PMALLOC(sizeof(kcdb_cred *) * cs->nclist);
    nr_sel = 0;
    nc_sel = 0;

    for(i=0; i<rcs->nclist; i++) {
        if(rcs->clist[i].cred &&
            (!identity || rcs->clist[i].cred->identity == identity) &&
            (type==KCDB_CREDTYPE_ALL || rcs->clist[i].cred->type == type))
        {
            r_sel[nr_sel++] = rcs->clist[i].cred;
        }
    }

    for(i=0; i<cs->nclist; i++) {
        if(cs->clist[i].cred &&
            (!identity || cs->clist[i].cred->identity == identity) &&
            (type==KCDB_CREDTYPE_ALL || cs->clist[i].cred->type == type))
        {
            c_sel[nc_sel++] = cs->clist[i].cred;
        }
    }

    rcs->version++;

    code = kcdb_credset_collect_core(
        rcs,
        r_sel,
        nr_sel,
        cs,
        c_sel,
        nc_sel,
        delta);

    LeaveCriticalSection(&(rcs->cs));
    LeaveCriticalSection(&(cs->cs));

    if(r_sel)
        PFREE(r_sel);
    if(c_sel)
        PFREE(c_sel);

    if (cs_dest == NULL) {
        kcdb_identity_refresh_all();
    }

    return code;
}
コード例 #3
0
ファイル: credset.c プロジェクト: secure-endpoints/netidmgr
KHMEXP khm_int32 KHMAPI
kcdb_credset_collect(khm_handle h_cs_dest,
		     khm_handle h_cs_src,
		     khm_handle identity,
		     khm_int32 type_id,
		     khm_int32 * delta)
{
    kcdb_credset * cs_source;
    kcdb_credset * cs_dest;
    khm_int32 code = KHM_ERROR_SUCCESS;
    kcdb_cred ** clist_dest = NULL;
    kcdb_cred ** clist_src = NULL;
    int nclist_dest, nclist_src;
    int i;

    if ((h_cs_src && !kcdb_credset_is_credset(h_cs_src)) ||
        (h_cs_dest && !kcdb_credset_is_credset(h_cs_dest)) ||
        (h_cs_src == h_cs_dest)) /* works because credsets use shared
                                    handles */
        return KHM_ERROR_INVALID_PARAM;

    if(identity && !kcdb_is_active_identity(identity))
        return KHM_ERROR_INVALID_PARAM;

    if(h_cs_src)
        cs_source = (kcdb_credset *) h_cs_src;
    else
        cs_source = kcdb_root_credset;

    if(h_cs_dest)
        cs_dest = (kcdb_credset *) h_cs_dest;
    else
        cs_dest = kcdb_root_credset;

    if (kcdb_credset_is_sealed(cs_dest))
        return KHM_ERROR_INVALID_OPERATION;

    if (cs_source < cs_dest) {
        EnterCriticalSection(&(cs_source->cs));
        EnterCriticalSection(&(cs_dest->cs));
    } else {
        EnterCriticalSection(&(cs_dest->cs));
        EnterCriticalSection(&(cs_source->cs));
    }

    /* enumerate through the root and given credential sets and select
       the ones we want */

    if(cs_dest->nclist > 0)
        clist_dest = PMALLOC(sizeof(kcdb_cred *) * cs_dest->nclist);
    if(cs_source->nclist > 0)
        clist_src = PMALLOC(sizeof(kcdb_cred *) * cs_source->nclist);
    nclist_dest = 0;
    nclist_src = 0;

    for(i=0; i < cs_dest->nclist; i++) {
        if(cs_dest->clist[i].cred &&
           (!identity || cs_dest->clist[i].cred->identity == identity) &&
           (type_id==KCDB_CREDTYPE_ALL || cs_dest->clist[i].cred->type == type_id)) {

            clist_dest[nclist_dest++] = cs_dest->clist[i].cred;
        }
    }

    for(i=0; i < cs_source->nclist; i++) {
        if(cs_source->clist[i].cred &&
           (!identity || cs_source->clist[i].cred->identity == identity) &&
           (type_id==KCDB_CREDTYPE_ALL || cs_source->clist[i].cred->type == type_id)) {

            clist_src[nclist_src++] = cs_source->clist[i].cred;
        }
    }

    cs_dest->version++;

    code = kcdb_credset_collect_core(cs_dest, clist_dest, nclist_dest,
                                     cs_source, clist_src, nclist_src,
                                     delta);

    LeaveCriticalSection(&(cs_dest->cs));
    LeaveCriticalSection(&(cs_source->cs));

    if(clist_dest)
        PFREE(clist_dest);
    if(clist_src)
        PFREE(clist_src);

    if (h_cs_dest == NULL) {
        kcdb_identity_refresh_all();
    }

    return code;
}
コード例 #4
0
ファイル: credset.c プロジェクト: secure-endpoints/netidmgr
KHMEXP khm_int32 KHMAPI
kcdb_credset_collect_filtered(khm_handle h_cs_dest,
			      khm_handle h_cs_src,
			      kcdb_cred_filter_func filter,
			      void * rock,
			      khm_int32 * delta)
{
    kcdb_credset * cs_src;
    kcdb_credset * cs_dest;
    khm_int32 code = KHM_ERROR_SUCCESS;
    kcdb_cred ** clist_dest = NULL;
    kcdb_cred ** clist_src = NULL;
    int nclist_dest, nclist_src;
    int i;
    khm_int32 cs_src_f = 0;
    khm_int32 cs_dest_f = 0;

    if((h_cs_src && !kcdb_credset_is_credset(h_cs_src)) ||
        (h_cs_dest && !kcdb_credset_is_credset(h_cs_dest)) ||
        (h_cs_src == h_cs_dest)) /* works because credsets use shared
                                handles */
        return KHM_ERROR_INVALID_PARAM;

    if(h_cs_src)
        cs_src = (kcdb_credset *) h_cs_src;
    else {
        cs_src = kcdb_root_credset;
        cs_src_f = KCDB_CREDCOLL_FILTER_ROOT;
    }

    if(h_cs_dest)
        cs_dest = (kcdb_credset *) h_cs_dest;
    else {
        cs_dest = kcdb_root_credset;
        cs_dest_f = KCDB_CREDCOLL_FILTER_ROOT;
    }

    if (kcdb_credset_is_sealed(cs_dest))
        return KHM_ERROR_INVALID_OPERATION;

    if (cs_src < cs_dest) {
        EnterCriticalSection(&(cs_src->cs));
        EnterCriticalSection(&(cs_dest->cs));
    } else {
        EnterCriticalSection(&(cs_dest->cs));
        EnterCriticalSection(&(cs_src->cs));
    }

#ifdef DEBUG
    assert(!(cs_dest->flags & KCDB_CREDSET_FLAG_ENUM));
    assert(!(cs_src->flags & KCDB_CREDSET_FLAG_ENUM));
#endif

    if (cs_dest->nclist)
        clist_dest = PMALLOC(sizeof(kcdb_cred *) * cs_dest->nclist);
    if (cs_src->nclist)
        clist_src = PMALLOC(sizeof(kcdb_cred *) * cs_src->nclist);
    nclist_dest = 0;
    nclist_src = 0;

    cs_dest->flags |= KCDB_CREDSET_FLAG_ENUM;

    for (i=0; i < cs_dest->nclist; i++) {
        if (cs_dest->clist[i].cred &&
            (*filter)((khm_handle)cs_dest->clist[i].cred,
                      KCDB_CREDCOLL_FILTER_DEST | cs_dest_f,
                      rock)) {
            clist_dest[nclist_dest++] = cs_dest->clist[i].cred;
        }
    }

    cs_dest->flags &= ~KCDB_CREDSET_FLAG_ENUM;
    cs_src->flags |= KCDB_CREDSET_FLAG_ENUM;

    for (i=0; i < cs_src->nclist; i++) {
        if (cs_src->clist[i].cred &&
            (*filter)((khm_handle)cs_src->clist[i].cred,
                      KCDB_CREDCOLL_FILTER_SRC | cs_src_f,
                      rock)) {
            clist_src[nclist_src++] = cs_src->clist[i].cred;
        }
    }

    cs_src->flags &= ~KCDB_CREDSET_FLAG_ENUM;

    cs_dest->version++;

    code = kcdb_credset_collect_core(cs_dest, clist_dest, nclist_dest,
                                     cs_src, clist_src, nclist_src,
                                     delta);

    LeaveCriticalSection(&(cs_dest->cs));
    LeaveCriticalSection(&(cs_src->cs));

    if(clist_dest)
        PFREE(clist_dest);
    if(clist_src)
        PFREE(clist_src);

    if (h_cs_dest == NULL) {
        kcdb_identity_refresh_all();
    }

    return code;
}
コード例 #5
0
ファイル: credfuncs.c プロジェクト: FarazShaikh/LikewiseSMB2
/* Completion handler for KMSG_CRED messages.  We control the overall
   logic of credentials acquisition and other operations here.  Once a
   credentials operation is triggered, each successive message
   completion notification will be used to dispatch the messages for
   the next step in processing the operation. */
void KHMAPI 
kmsg_cred_completion(kmq_message *m)
{
    khui_new_creds * nc;

#ifdef DEBUG
    assert(m->type == KMSG_CRED);
#else
    if(m->type != KMSG_CRED)
        return; /* huh? */
#endif

    switch(m->subtype) {
    case KMSG_CRED_PASSWORD:
        /* fallthrough */
    case KMSG_CRED_NEW_CREDS:
        /* Cred types have attached themselves.  Trigger the next
           phase. */
        kmq_post_message(KMSG_CRED, KMSG_CRED_DIALOG_SETUP, 0, 
                         m->vparam);
        break;

    case KMSG_CRED_RENEW_CREDS:
        nc = (khui_new_creds *) m->vparam;

        /* khm_cred_dispatch_process_message() deals with the case
           where there are no credential types that wants to
           participate in this operation. */
        khm_cred_dispatch_process_message(nc);
        break;

    case KMSG_CRED_DIALOG_SETUP:
        nc = (khui_new_creds *) m->vparam;

        khm_prep_newcredwnd(nc->hwnd);
            
        /* all the controls have been created.  Now initialize them */
        if (nc->n_types > 0) {
            kmq_post_subs_msg(nc->type_subs, 
                              nc->n_types, 
                              KMSG_CRED, 
                              KMSG_CRED_DIALOG_PRESTART, 
                              0, 
                              m->vparam);
        } else {
            PostMessage(nc->hwnd, KHUI_WM_NC_NOTIFY, 
                        MAKEWPARAM(0, WMNC_DIALOG_PROCESS_COMPLETE), 0);
        }
        break;

    case KMSG_CRED_DIALOG_PRESTART:
        /* all prestart stuff is done.  Now to activate the dialog */
        nc = (khui_new_creds *) m->vparam;
        khm_show_newcredwnd(nc->hwnd);
        
        kmq_post_subs_msg(nc->type_subs,
                          nc->n_types,
                          KMSG_CRED, 
                          KMSG_CRED_DIALOG_START, 
                          0, 
                          m->vparam);
        /* at this point, the dialog window takes over.  We let it run
           the show until KMSG_CRED_DIALOG_END is posted by the dialog
           procedure. */
        break;

    case KMSG_CRED_PROCESS:
        /* a wave of these messages have completed.  We should check
           if there's more */
        nc = (khui_new_creds *) m->vparam;

        /* if we are done processing all the plug-ins, then check if
           there were any errors reported.  Otherwise we dispatch
           another set of messages. */
        if(!khm_cred_dispatch_process_level(nc)) {

            if(kherr_is_error()) {
                khui_alert * alert;
                kherr_event * evt;
                kherr_context * ctx;
                wchar_t ws_tfmt[512];
                wchar_t w_idname[KCDB_IDENT_MAXCCH_NAME];
                wchar_t ws_title[ARRAYLENGTH(ws_tfmt) + KCDB_IDENT_MAXCCH_NAME];
                khm_size cb;

                /* For renewals, we suppress the error message for the
                   following case:

                   - The renewal was for an identity

                   - There are no identity credentials for the
                     identity (no credentials that have the same type
                     as the identity provider). */

                if (nc->subtype == KMSG_CRED_RENEW_CREDS &&
                    nc->ctx.scope == KHUI_SCOPE_IDENT &&
                    nc->ctx.identity != NULL) {
                    khm_handle tcs = NULL; /* credential set */
                    khm_size count = 0;
                    khm_int32 id_ctype = KCDB_CREDTYPE_INVALID;
                    khm_int32 delta = 0;

                    kcdb_identity_get_type(&id_ctype);
                    kcdb_credset_create(&tcs);
                    kcdb_credset_collect(tcs, NULL,
                                         nc->ctx.identity,
                                         id_ctype,
                                         &delta);
                    kcdb_credset_get_size(tcs, &count);
                    kcdb_credset_delete(tcs);

                    if (count == 0) {
                        goto done_with_op;
                    }
                }

                ctx = kherr_peek_context();
                evt = kherr_get_err_event(ctx);
                kherr_evaluate_event(evt);

                khui_alert_create_empty(&alert);

                if (nc->subtype == KMSG_CRED_NEW_CREDS) {

                    khui_alert_set_type(alert, KHUI_ALERTTYPE_ACQUIREFAIL);

                    cb = sizeof(w_idname);
                    if (nc->n_identities == 0 ||
                        KHM_FAILED(kcdb_identity_get_name(nc->identities[0],
                                                          w_idname, &cb))) {
                        /* an identity could not be determined */
                        LoadString(khm_hInstance, IDS_NC_FAILED_TITLE,
                                   ws_title, ARRAYLENGTH(ws_title));
                    } else {
                        LoadString(khm_hInstance, IDS_NC_FAILED_TITLE_I,
                                   ws_tfmt, ARRAYLENGTH(ws_tfmt));
                        StringCbPrintf(ws_title, sizeof(ws_title),
                                       ws_tfmt, w_idname);
                        khui_alert_set_ctx(alert,
                                           KHUI_SCOPE_IDENT,
                                           nc->identities[0],
                                           KCDB_CREDTYPE_INVALID,
                                           NULL);
                    }

                } else if (nc->subtype == KMSG_CRED_PASSWORD) {

                    khui_alert_set_type(alert, KHUI_ALERTTYPE_CHPW);

                    cb = sizeof(w_idname);
                    if (nc->n_identities == 0 ||
                        KHM_FAILED(kcdb_identity_get_name(nc->identities[0],
                                                          w_idname, &cb))) {
                        LoadString(khm_hInstance, IDS_NC_PWD_FAILED_TITLE,
                                   ws_title, ARRAYLENGTH(ws_title));
                    } else {
                        LoadString(khm_hInstance, IDS_NC_PWD_FAILED_TITLE_I,
                                   ws_tfmt, ARRAYLENGTH(ws_tfmt));
                        StringCbPrintf(ws_title, sizeof(ws_title),
                                       ws_tfmt, w_idname);
                        khui_alert_set_ctx(alert,
                                           KHUI_SCOPE_IDENT,
                                           nc->identities[0],
                                           KCDB_CREDTYPE_INVALID,
                                           NULL);
                    }

                } else if (nc->subtype == KMSG_CRED_RENEW_CREDS) {

                    khui_alert_set_type(alert, KHUI_ALERTTYPE_RENEWFAIL);

                    cb = sizeof(w_idname);
                    if (nc->ctx.identity == NULL ||
                        KHM_FAILED(kcdb_identity_get_name(nc->ctx.identity,
                                                          w_idname, &cb))) {
                        LoadString(khm_hInstance, IDS_NC_REN_FAILED_TITLE,
                                   ws_title, ARRAYLENGTH(ws_title));
                    } else {
                        LoadString(khm_hInstance, IDS_NC_REN_FAILED_TITLE_I,
                                   ws_tfmt, ARRAYLENGTH(ws_tfmt));
                        StringCbPrintf(ws_title, sizeof(ws_title),
                                       ws_tfmt, w_idname);
                        khui_alert_set_ctx(alert,
                                           KHUI_SCOPE_IDENT,
                                           nc->ctx.identity,
                                           KCDB_CREDTYPE_INVALID,
                                           NULL);
                    }

                } else {
#ifdef DEBUG
                    assert(FALSE);
#endif
                }

                khui_alert_set_title(alert, ws_title);
                khui_alert_set_severity(alert, evt->severity);

                if(!evt->long_desc)
                    khui_alert_set_message(alert, evt->short_desc);
                else
                    khui_alert_set_message(alert, evt->long_desc);

                if(evt->suggestion)
                    khui_alert_set_suggestion(alert, evt->suggestion);

                if (nc->subtype == KMSG_CRED_RENEW_CREDS &&
                    nc->ctx.identity != NULL) {

                    khm_int32 n_cmd;

                    n_cmd = khm_get_identity_new_creds_action(nc->ctx.identity);

                    if (n_cmd != 0) {
                        khui_alert_add_command(alert, n_cmd);
                        khui_alert_add_command(alert, KHUI_PACTION_CLOSE);

                        khui_alert_set_flags(alert, KHUI_ALERT_FLAG_DISPATCH_CMD,
                                             KHUI_ALERT_FLAG_DISPATCH_CMD);
                    }
                }

                khui_alert_show(alert);
                khui_alert_release(alert);

                kherr_release_context(ctx);

                kherr_clear_error();
            }

        done_with_op:

            if (nc->subtype == KMSG_CRED_RENEW_CREDS) {
                kmq_post_message(KMSG_CRED, KMSG_CRED_END, 0, 
                                 m->vparam);
            } else {
                PostMessage(nc->hwnd, KHUI_WM_NC_NOTIFY, 
                            MAKEWPARAM(0, WMNC_DIALOG_PROCESS_COMPLETE),
                            0);
            }
        }
        break;

    case KMSG_CRED_END:
        /* all is done. */
        {
            khui_new_creds * nc;
            khm_boolean continue_cmdline = TRUE;

            nc = (khui_new_creds *) m->vparam;

            if (nc->subtype == KMSG_CRED_NEW_CREDS ||
                nc->subtype == KMSG_CRED_PASSWORD) {

                khm_cred_end_dialog(nc);

            } else if (nc->subtype == KMSG_CRED_RENEW_CREDS) {

                /* if this is a renewal that was triggered while we
                   were processing the commandline, then we need to
                   update the pending renewal count. */

                if (khm_startup.processing) {
                    LONG renewals;
                    renewals = InterlockedDecrement(&khm_startup.pending_renewals);

                    if (renewals != 0) {
                        continue_cmdline = FALSE;
                    }
                }
            }

            khui_cw_destroy_cred_blob(nc);

            kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);

            if (continue_cmdline)
                kmq_post_message(KMSG_ACT, KMSG_ACT_CONTINUE_CMDLINE, 0, 0);
        }
        break;

        /* property sheet stuff */

    case KMSG_CRED_PP_BEGIN:
        /* all the pages should have been added by now.  Just send out
           the precreate message */
        kmq_post_message(KMSG_CRED, KMSG_CRED_PP_PRECREATE, 0, 
                         m->vparam);
        break;

    case KMSG_CRED_PP_END:
        kmq_post_message(KMSG_CRED, KMSG_CRED_PP_DESTROY, 0, 
                         m->vparam);
        break;

    case KMSG_CRED_DESTROY_CREDS:
#ifdef DEBUG
        assert(m->vparam != NULL);
#endif
        khui_context_release((khui_action_context *) m->vparam);
        PFREE(m->vparam);

        kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);

        kmq_post_message(KMSG_ACT, KMSG_ACT_CONTINUE_CMDLINE, 0, 0);
        break;

    case KMSG_CRED_IMPORT:
        {
            khm_boolean continue_cmdline = FALSE;
            LONG pending_renewals;

            /* once an import operation ends, we have to trigger a
               renewal so that other plug-ins that didn't participate
               in the import operation can have a chance at getting
               the necessary credentials.

               If we are in the middle of processing the commandline,
               we have to be a little bit careful.  We can't issue a
               commandline conituation message right now because the
               import action is still ongoing (since the renewals are
               part of the action).  Once the renewals have completed,
               the completion handler will automatically issue a
               commandline continuation message.  However, if there
               were no identities to renew, then we have to issue the
               message ourselves.
            */

            InterlockedIncrement(&khm_startup.pending_renewals);

            khm_cred_renew_all_identities();

            pending_renewals = InterlockedDecrement(&khm_startup.pending_renewals);

            if (pending_renewals == 0 && khm_startup.processing)
                kmq_post_message(KMSG_ACT, KMSG_ACT_CONTINUE_CMDLINE, 0, 0);
        }
        break;

    case KMSG_CRED_REFRESH:
        kcdb_identity_refresh_all();
        break;
    }
}