confname[sizeof(confname) - 2] = '\0';
}
- /*
- * Talk about DUMB! It turns out that there is a bug in
- * pr_Initialize -- even if you give a different cell name
- * to it, it still uses a connection to a previous AFS server
- * if one exists. The way to fix this is to change the
- * _filename_ argument to pr_Initialize - that forces it to
- * re-initialize the connection. We do this by adding and
- * removing a "/" on the end of the configuration directory name.
- */
-
- if (lastcell[0] != '\0' && (strcmp(lastcell, aserver->cell) != 0)) {
- int i = strlen(confname);
- if (confname[i - 1] == '/') {
- confname[i - 1] = '\0';
- } else {
- confname[i] = '/';
- confname[i + 1] = '\0';
- }
- }
-
strcpy(lastcell, aserver->cell);
if (!pr_Initialize (0, confname, aserver->cell))
strncpy(aclient->cell, realm_of_user, MAXKTCREALMLEN - 1);
if (status = ktc_SetToken(aserver, atoken, aclient, 0))
return status;
-
- /*
- * In case you're wondering, we don't need to change the
- * filename here because we're still connecting to the
- * same cell -- we're just using a different authentication
- * level
- */
-
if (status = pr_Initialize(1L, confname, aserver->cell))
return status;
if (status = pr_CreateUser(username, &id))
return success;
}
-#define AFS_LOGON_EVENT_NAME TEXT("AFS Logon")
-
-static void DebugEvent0(char *a)
-{
- HANDLE h; char *ptbuf[1];
- h = RegisterEventSource(NULL, AFS_LOGON_EVENT_NAME);
- ptbuf[0] = a;
- ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);
- DeregisterEventSource(h);
-}
-
-#define MAXBUF_ 512
-static void DebugEvent(char *b,...)
-{
- HANDLE h; char *ptbuf[1],buf[MAXBUF_+1];
- va_list marker;
- h = RegisterEventSource(NULL, AFS_LOGON_EVENT_NAME);
- va_start(marker,b);
- vsprintf(buf, b, marker);
- buf[MAXBUF_] = '\0';
- ptbuf[0] = buf;
- ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);
- DeregisterEventSource(h);
- va_end(marker);
-}
-
-
void
KFW_AFS_copy_cache_to_system_file(char * user, char * szLogonId)
{
strcat(cachename, filename);
- DebugEvent("Copy2File %s", filename);
-
DeleteFile(filename);
code = pkrb5_init_context(&ctx);
code = pkrb5_cc_initialize(ctx, ncc, princ);
if (code) goto cleanup;
- DebugEvent0("Copy2File copying");
-
code = pkrb5_cc_copy_creds(ctx,cc,ncc);
- DebugEvent("Copy2File copy_creds=%d", code);
-
cleanup:
if ( cc ) {
pkrb5_cc_close(ctx, cc);
strcat(cachename, filename);
- DebugEvent("Copy2Cache %s", cachename);
-
code = pkrb5_init_context(&ctx);
if (code) ctx = 0;
code = pkrb5_cc_resolve(ctx, cachename, &cc);
if (code) goto cleanup;
- DebugEvent("Copy2Cache resolve=%d", code);
-
code = pkrb5_cc_get_principal(ctx, cc, &princ);
code = pkrb5_cc_default(ctx, &ncc);
- DebugEvent("Copy2Cache default=%d", code);
-
if (!code) {
code = pkrb5_cc_initialize(ctx, ncc, princ);
- DebugEvent("Copy2Cache initialize=%d", code);
- code = pkrb5_cc_copy_creds(ctx,cc,ncc);
- DebugEvent("Copy2Cache copy_creds=%d", code);
+ if (!code)
+ code = pkrb5_cc_copy_creds(ctx,cc,ncc);
}
if ( ncc ) {
pkrb5_cc_close(ctx, ncc);