Esempio n. 1
0
/*+*************************************************************************
**
** Fill_combo
**
** Fills the combo box with the contents of the host list. Item 0 goes
** into the edit portion and the rest go into the libt box.
**
***************************************************************************/
static void
fill_combo (HWND hDlg) {
	int i;										// Index
    char buff[256];
#ifdef USE_LEASH
    krb5_error_code retval;
    apiCB * cc_ctx = 0;
    struct _infoNC ** pNCi = 0;
#endif

	SendDlgItemMessage(hDlg, GSS_HOST_NAME, CB_RESETCONTENT, 0, 0);
	SetDlgItemText(hDlg, GSS_HOST_NAME, szHost);
	SendDlgItemMessage(hDlg, GSS_HOST_NAME, CB_SETEDITSEL, 0, 0);
	for (i = 1; i < MAX_SAVED; ++i) {			// Fill in the list box
		if (*hosts[i] == '\0')
			break;
		SendDlgItemMessage(hDlg, GSS_HOST_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) hosts[i]));
	}

	SendDlgItemMessage(hDlg, GSS_SERVICE_NAME, CB_RESETCONTENT, 0, 0);
	SetDlgItemText(hDlg, GSS_SERVICE_NAME, szService);
	SendDlgItemMessage(hDlg, GSS_SERVICE_NAME, CB_SETEDITSEL, 0, 0);
	for (i = 1; i < MAX_SAVED; ++i) {			// Fill in the list box
		if (*svcs[i] == '\0')
			break;
		SendDlgItemMessage(hDlg, GSS_SERVICE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) svcs[i]));
	}

	SendDlgItemMessage(hDlg, GSS_MECHANISM, CB_RESETCONTENT, 0, 0);
	SetDlgItemText(hDlg, GSS_MECHANISM, szMech);
	SendDlgItemMessage(hDlg, GSS_MECHANISM, CB_SETEDITSEL, 0, 0);
	for (i = 1; i < MAX_SAVED; ++i) {			// Fill in the list box
		if (*mechs[i] == '\0')
			break;
		SendDlgItemMessage(hDlg, GSS_MECHANISM, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) mechs[i]));
	}

    SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_RESETCONTENT, 0, 0);
	SetDlgItemText(hDlg, GSS_CCACHE_NAME, szCCache);
	SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_SETEDITSEL, 0, 0);

#ifdef USE_LEASH
    retval = cc_initialize(&cc_ctx, CC_API_VER_2, NULL, NULL);
    if (retval)
        goto skip_ccache;

    retval = cc_get_NC_info(cc_ctx, &pNCi);
    if (retval)
        goto clean_ccache;

    for ( i=0; pNCi[i]; i++ ) {
        if (pNCi[i]->vers == CC_CRED_V5) {
            sprintf(buff,"API:%s",pNCi[i]->name);
            SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) buff));
        }
    }

  clean_ccache:
    if (pNCi)
        cc_free_NC_info(cc_ctx, &pNCi);
    if (cc_ctx)
        cc_shutdown(&cc_ctx);
  skip_ccache:
#endif /* USE_LEASH */
    if ( szCCache[0] )
        SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) szCCache));
    SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) "MSLSA:"));

	SendDlgItemMessage(hDlg, GSS_MESSAGE, CB_RESETCONTENT, 0, 0);
	SetDlgItemText(hDlg, GSS_MESSAGE, szMessage);
	SendDlgItemMessage(hDlg, GSS_MESSAGE, CB_SETEDITSEL, 0, 0);
	for (i = 1; i < MAX_SAVED; ++i) {			// Fill in the list box
		if (*msgs[i] == '\0')
			break;
		SendDlgItemMessage(hDlg, GSS_MESSAGE, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) msgs[i]));
	}

    wsprintf(buff, "%d", port);
    SetDlgItemText(hDlg, GSS_PORT, buff);

    CheckDlgButton(hDlg, GSS_VERBOSE, verbose);
    CheckDlgButton(hDlg, GSS_DELEGATION, delegate);
    CheckDlgButton(hDlg, GSS_MUTUAL, mutual);
    CheckDlgButton(hDlg, GSS_REPLAY, replay);
    CheckDlgButton(hDlg, GSS_SEQUENCE, sequence);
    CheckDlgButton(hDlg, GSS_VERSION_ONE, gssv1);
    CheckDlgButton(hDlg, GSS_NO_AUTH, noauth);
    CheckDlgButton(hDlg, GSS_NO_WRAP, nowrap);
    CheckDlgButton(hDlg, GSS_NO_ENCRYPT, nocrypt);
    CheckDlgButton(hDlg, GSS_NO_MIC, nomic);

    if ( noauth ) {
        // disable the other no_xxx options
        EnableWindow(GetDlgItem(hDlg, GSS_NO_WRAP), FALSE);
        EnableWindow(GetDlgItem(hDlg, GSS_NO_ENCRYPT), FALSE);
        EnableWindow(GetDlgItem(hDlg, GSS_NO_MIC), FALSE);
    } else {
        // enable the other no_xxx options
        EnableWindow(GetDlgItem(hDlg, GSS_NO_WRAP), TRUE);
        EnableWindow(GetDlgItem(hDlg, GSS_NO_ENCRYPT), TRUE);
        EnableWindow(GetDlgItem(hDlg, GSS_NO_MIC), TRUE);
    }

    SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 1);
    SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETRANGEMAX, (WPARAM) FALSE, (LPARAM) 20);
    SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETPOS, (WPARAM) FALSE, (LPARAM) ccount);
    sprintf(buff,"Call Count: %d",ccount);
    SetWindowText(GetDlgItem(hDialog, IDC_STATIC_CCOUNT),buff);

    SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 1);
    SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETRANGEMAX, (WPARAM) FALSE, (LPARAM) 20);
    SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETPOS, (WPARAM) FALSE, (LPARAM) mcount);
    sprintf(buff,"Message Count: %d",mcount);
    SetWindowText(GetDlgItem(hDialog, IDC_STATIC_MSG_COUNT),buff);
}
Esempio n. 2
0
void krb5_stdcc_shutdown()
{
	if (gCntrlBlock)
		cc_shutdown(&gCntrlBlock);
	gCntrlBlock = NULL;
}
Esempio n. 3
0
void main(void)
{
    // XXX (3) - infoNC not properly filled out when returned.
    infoNC**		allCacheInfo = 0; // XXX (2) - bug in krbcc32
    infoNC*		cacheInfo;
    ccache_p*		theCache = 0;
    ccache_cit*		iterator = 0;
    cred_union*		theCreds = 0;
    cc_uint32		err;
    unsigned long	index;
    apiCB*		context = 0; // XXX (1) - bug in krbcc32
    cc_int32		version;

    printf ("Dumping all credential caches... (times are in GMT)\n");

    err = cc_initialize (&context, CC_API_VER_2, &version, NULL); // XXX (1)
    if (err != CC_NOERROR) {
        printf ("*** cc_initialize returned %d ***\n", err);
        return;
    }

    err = cc_get_NC_info (context, &allCacheInfo); // XXX (2) - another bug
    if (err != CC_NOERROR) {
        printf ("*** cc_get_NC_info returned %d ***\n", err);
        return;
    }

    for (index = 0; allCacheInfo [index] != 0; index++) {
        cacheInfo = allCacheInfo [index];

        switch (cacheInfo->vers) {
        case CC_CRED_V4:
            printf ("\tv4 credentials\n");
            break;

        case CC_CRED_V5:
            printf ("\tv5 credentials\n");
            break;

        default:
            printf ("\t*** bogus credentials type %d***\n", cacheInfo->vers);
            continue;
        }

        printf ("\tfor %s\n\tin %s\n", cacheInfo->principal, cacheInfo->name);

        err = cc_open (context, cacheInfo->name, cacheInfo->vers, 0L, 
                       &theCache);
        if (err != CC_NOERROR) {
            printf ("\t*** cc_open returned %d ***\n", err);
            continue;
        }

        err = cc_seq_fetch_creds_begin (context, theCache, &iterator);
        if (err != CC_NOERROR) {
            printf ("\t*** cc_seq_fetch_creds_begin returned %d ***\n", err);
            continue;
        }

        for (;;) {
            err = cc_seq_fetch_creds_next (context,
                                           &theCreds, iterator);
            if (err == CC_END)
                break;

            if (err != CC_NOERROR) {
                printf ("\t\t*** seq_fetch_creds returned %d ***\n", err);
                continue;
            }

            switch (theCreds->cred_type) {
            case CC_CRED_V4: {
                char start [26];
                char end [26];
                printf ("\t\t%s - %s: %s.%s@%s\n",
                        datestring (start, 
                                    theCreds->cred.pV4Cred->issue_date),
                        datestring (end, 
                                    theCreds->cred.pV4Cred->issue_date + 
                                    theCreds->cred.pV4Cred->lifetime * 5 * 60),
                        theCreds->cred.pV4Cred->service,
                        theCreds->cred.pV4Cred->service_instance,
                        theCreds->cred.pV4Cred->realm);
                break;
            }

            case CC_CRED_V5: {
                char start [26];
                char end [26];
                printf ("\t\t%s - %s: %s\n",
                        datestring (start, theCreds->cred.pV5Cred->starttime),
                        datestring (end, theCreds->cred.pV5Cred->endtime),
                        theCreds->cred.pV5Cred->server);
                break;
            }
            }
            cc_free_creds (context, &theCreds);
        }

        cc_seq_fetch_creds_end (context, &iterator);
        cc_close (context, &theCache);

        printf ("\n");
    }

    cc_free_NC_info (context, &allCacheInfo);

    cc_shutdown (&context);
}