Add some key debug-to-vmx messages to help debug SAML tokens.
Fix a potential issue in the logging code.
Always use a local version of htonll() since Visual Studio has
changed its mind about its existance in vs2017.
/* end code copied from vmci_sockets.h */
-#if !defined(_MSC_VER) || _MSC_VER <= 1900
/*
- * htonll() for older compilers and non-Windows.
+ * Local version of htonll() which is missing in many environments.
* Assumes the host is little-endian.
*/
static uint64
-htonll(uint64 s)
+_vmxlog_htonll(uint64 s)
{
uint64 out;
unsigned char *buf = (unsigned char *) &out;
return out;
}
-#endif
/*
/* network byte order is important here */
hdr.type = htonl(1); // DMFIELDTYPE_INT64
hdr.fieldId = htonl(1); // GUESTRPCPKT_FIELD_TYPE
- hdr.value = htonll(1); // GUESTRPCPKT_TYPE_DATA
+ hdr.value = _vmxlog_htonll(1); // GUESTRPCPKT_TYPE_DATA
/*
* this part of the data doesn't seem to care about network byte
*
* Possible optimization -- every N minutes, retry the new RPC.
*/
- buf[ret] = '\0';
- reply = &buf[18];
- g_debug("%s: RPC returned '%s'\n", __FUNCTION__, reply);
- if (g_strcmp0(reply, "disabled") == 0 ||
- g_strcmp0(reply, "Unknown") == 0) {
- g_warning("%s: RPC unknown or disabled\n", __FUNCTION__);
- retVal = VMX_RPC_UNKNOWN;
+ if (ret >= 18 && ret < sizeof buf) {
+ buf[ret] = '\0';
+ reply = &buf[18];
+ g_debug("%s: RPC returned '%s'\n", __FUNCTION__, reply);
+ if (g_strcmp0(reply, "disabled") == 0 ||
+ g_strcmp0(reply, "Unknown") == 0) {
+ g_warning("%s: RPC unknown or disabled\n", __FUNCTION__);
+ retVal = VMX_RPC_UNKNOWN;
+ }
+ } else {
+ g_warning("%s: recv() returned %d\n", __FUNCTION__, ret);
+ retVal = VMX_RPC_ERROR;
}
done:
void VMXLog_Log(int level, const char *fmt, ...) PRINTF_DECL(2, 3);
/*
- * XXX placeholder until we define levels for the new log RPC
+ * * XXX Future-proofing -- currently unused.
*/
-#define VMXLOG_LEVEL_INFO 1
+#define VMXLOG_LEVEL_INFO 1
+#define VMXLOG_LEVEL_WARNING 2
void VMXLog_LogV(int level, const char *fmt, va_list args);
#include "prefs.h"
#include "serviceInt.h"
#include "certverify.h"
+#include "vmxlog.h"
static int gClockSkewAdjustment = VGAUTH_PREF_DEFAULT_CLOCK_SKEW_SECS;
static xmlSchemaPtr gParsedSchemas = NULL;
g_warning("%s: FAILED SAML assertion (timeStamp %s, delta %d) %s.\n",
__FUNCTION__, timeAttr, (int) diff,
notBefore ? "is not yet valid" : "has expired");
+ VMXLog_Log(VMXLOG_LEVEL_WARNING,
+ "%s: FAILED SAML assertion (timeStamp %s, delta %d) %s.\n",
+ __FUNCTION__, timeAttr, (int) diff,
+ notBefore ? "is not yet valid" : "has expired");
retVal = FALSE;
goto done;
}
*/
if (dsigCtx->status != xmlSecDSigStatusSucceeded) {
g_warning("Signature is INVALID\n");
+ VMXLog_Log(VMXLOG_LEVEL_WARNING,
+ "%s: signature is invalid\n", __FUNCTION__);
goto done;
}
/*********************************************************
- * Copyright (C) 2011-2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2018 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#include <string.h>
#include "serviceInt.h"
#include "certverify.h"
+#include "vmxlog.h"
/*
******************************************************************************
* No username, no mapped certs, no chance.
*/
Warning("%s: no mapping entries or userName\n", __FUNCTION__);
+ VMXLog_Log(VMXLOG_LEVEL_WARNING,
+ "%s: no mapping entries or userName\n", __FUNCTION__);
err = VGAUTH_E_AUTHENTICATION_DENIED;
goto done;
}
if (NULL == queryUserName) {
Warning("%s: no matching cert and subject found in mapping file\n",
__FUNCTION__);
+ VMXLog_Log(VMXLOG_LEVEL_WARNING,
+ "%s: no matching cert and subject found in mapping file\n",
+ __FUNCTION__);
err = VGAUTH_E_AUTHENTICATION_DENIED;
goto done;
}
*/
if (!UsercheckUserExists(queryUserName)) {
Warning("%s: User '%s' doesn't exist\n", __FUNCTION__, queryUserName);
+ VMXLog_Log(VMXLOG_LEVEL_WARNING,
+ "%s: User '%s' doesn't exist\n", __FUNCTION__, queryUserName);
err = VGAUTH_E_AUTHENTICATION_DENIED;
goto done;
}
if (numTrusted == 0) {
err = VGAUTH_E_AUTHENTICATION_DENIED;
Warning("%s: No trusted certs in chain\n", __FUNCTION__);
+ VMXLog_Log(VMXLOG_LEVEL_WARNING,
+ "%s: No trusted certs in chain\n", __FUNCTION__);
goto done;
}
numTrusted,
(const char **) trustedCerts);
if (VGAUTH_E_OK != err) {
+ VMXLog_Log(VMXLOG_LEVEL_WARNING,
+ "%s: cert chain validation failed\n", __FUNCTION__);
goto done;
}