From ad7eea89336e3ba658b0b3af75bdf316888cc73e Mon Sep 17 00:00:00 2001 From: Juan Carlos Luciani Date: Fri, 28 Apr 2006 20:57:31 +0000 Subject: [PATCH] Changes due to continued development effort. --- .../client/mechanisms/krb5/win32/dllsup.c | 2 +- auth_token/client/mechanisms/krb5/win32/get.c | 36 +++++++++++-------- .../client/mechanisms/krb5/win32/platform.c | 35 ++++++++++++++++++ .../client/mechanisms/krb5/win32/platform.h | 30 +++++++++------- 4 files changed, 75 insertions(+), 28 deletions(-) create mode 100644 auth_token/client/mechanisms/krb5/win32/platform.c diff --git a/auth_token/client/mechanisms/krb5/win32/dllsup.c b/auth_token/client/mechanisms/krb5/win32/dllsup.c index 8eecacef..1fbf8cc8 100644 --- a/auth_token/client/mechanisms/krb5/win32/dllsup.c +++ b/auth_token/client/mechanisms/krb5/win32/dllsup.c @@ -61,7 +61,7 @@ BOOL APIENTRY DllMain( if (InitializeLibrary() != 0) { // Failed to initialize the library - OutputDebugString("CASA_PW_MECH -DllMain- Library initialization failed\n"); + OutputDebugString("CASA_KRB5_MECH -DllMain- Library initialization failed\n"); retStatus = FALSE; } break; diff --git a/auth_token/client/mechanisms/krb5/win32/get.c b/auth_token/client/mechanisms/krb5/win32/get.c index fa1cdb7d..a3ac6000 100644 --- a/auth_token/client/mechanisms/krb5/win32/get.c +++ b/auth_token/client/mechanisms/krb5/win32/get.c @@ -85,16 +85,16 @@ AuthTokenIf_GetAuthToken( // Description: // Get authentication token to authenticate user to specified service. // -// L0 +// L2 //=======================================================================-- { - CasaStatus retStatus; - char *pKrbServiceName = pMechInfo; - + CasaStatus retStatus; + char *pKrbServiceName = pMechInfo; SECURITY_STATUS secStatus; TimeStamp expiry; CredHandle hCredentials = {0}; + DbgTrace(1, "-AuthTokenIf_GetAuthToken- Start\n", 0); // Validate input parameters @@ -161,7 +161,6 @@ AuthTokenIf_GetAuthToken( int encodedTokenLen; // The security context was initialized, now return it to the caller after base64 encoding it. - // The token has been assembled, now encode it. retStatus = EncodeData(sendTok.pvBuffer, (const int) sendTok.cbBuffer, &pEncodedToken, @@ -172,8 +171,6 @@ AuthTokenIf_GetAuthToken( if (encodedTokenLen > *pTokenBufLen) { // The buffer is not big enough - DbgTrace(1, "-AuthTokenIf_GetAuthToken- Insufficient buffer space provided\n", 0); - retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, CASA_FACILITY_KRB5TOKEN, CASA_STATUS_BUFFER_OVERFLOW); @@ -199,9 +196,8 @@ AuthTokenIf_GetAuthToken( } else { - DbgTrace(1, "-AuthTokenIf_GetAuthToken- Failed to obtain the credentials handle, error = %08X\n", secStatus); + DbgTrace(0, "-AuthTokenIf_GetAuthToken- Failed to initialize the security context, error = %08X\n", secStatus); - // tdb - Set retStatus based on secStatus retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, CASA_FACILITY_KRB5TOKEN, CASA_STATUS_UNSUCCESSFUL); @@ -219,11 +215,20 @@ AuthTokenIf_GetAuthToken( { DbgTrace(1, "-AuthTokenIf_GetAuthToken- Failed to obtain the credentials handle, error = %08X\n", secStatus); - // tdb - Set retStatus based on secStatus - - retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, - CASA_FACILITY_KRB5TOKEN, - CASA_STATUS_NO_CREDENTIALS); + // Set retStatus based on secStatus + if (secStatus == SEC_E_NOT_OWNER + || secStatus == SEC_E_NO_CREDENTIALS) + { + retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, + CASA_FACILITY_KRB5TOKEN, + CASA_STATUS_NO_CREDENTIALS); + } + else + { + retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR, + CASA_FACILITY_KRB5TOKEN, + CASA_STATUS_UNSUCCESSFUL); + } } exit: @@ -246,13 +251,14 @@ InitializeLibrary(void) // // Notes: // -// L0 +// L2 //=======================================================================-- { int retStatus = 0; DbgTrace(1, "-InitializeLibrary- Start\n", 0); + // Nothing to do at this time. DbgTrace(1, "-InitializeLibrary- End, retStatus = %08X\n", retStatus); diff --git a/auth_token/client/mechanisms/krb5/win32/platform.c b/auth_token/client/mechanisms/krb5/win32/platform.c new file mode 100644 index 00000000..869b581c --- /dev/null +++ b/auth_token/client/mechanisms/krb5/win32/platform.c @@ -0,0 +1,35 @@ +/*********************************************************************** + * + * Copyright (C) 2006 Novell, Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, Novell, Inc. + * + * To contact Novell about this file by physical or electronic mail, + * you may find current contact information at www.novell.com. + * + * Author: Juan Carlos Luciani + * + ***********************************************************************/ + +//===[ Include files ]===================================================== + +#include "internal.h" + +//===[ Type definitions ]================================================== + +//===[ Function prototypes ]=============================================== + +//===[ Global variables ]================================================== + + diff --git a/auth_token/client/mechanisms/krb5/win32/platform.h b/auth_token/client/mechanisms/krb5/win32/platform.h index e6ea6f1d..1b3f0f7f 100644 --- a/auth_token/client/mechanisms/krb5/win32/platform.h +++ b/auth_token/client/mechanisms/krb5/win32/platform.h @@ -44,18 +44,24 @@ // // DbgTrace macro define // -#define DbgTrace(LEVEL, X, Y) { \ -char printBuff[256]; \ - if (LEVEL == 0) \ - { \ - _snprintf(printBuff, sizeof(printBuff), X, Y); \ - printf("Krb5Mech %s", printBuff); \ - } \ - else if (DebugLevel >= LEVEL) \ - { \ - _snprintf(printBuff, sizeof(printBuff), X, Y); \ - printf("Krb5Mech %s", printBuff); \ - } \ +//#define DbgTrace(LEVEL, X, Y) { \ +//char printBuff[256]; \ +// if (LEVEL == 0 || DebugLevel >= LEVEL) \ +// { \ +// _snprintf(printBuff, sizeof(printBuff), X, Y); \ +// printf("Krb5Mech %s", printBuff); \ +// } \ +//} +#define DbgTrace(LEVEL, X, Y) { \ +char formatBuff[128]; \ +char printBuff[256]; \ + if (LEVEL == 0 || DebugLevel >= LEVEL) \ + { \ + strcpy(formatBuff, "Krb5Mech "); \ + strncat(formatBuff, X, sizeof(formatBuff) - 9); \ + _snprintf(printBuff, sizeof(printBuff), formatBuff, Y); \ + OutputDebugString(printBuff); \ + } \ } #define bool BOOLEAN