From: Kruti Pendharkar Date: Wed, 10 Dec 2025 05:31:19 +0000 (-0800) Subject: Change to common source files not applicable to open-vm-tools. X-Git-Tag: stable-13.1.0~34 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3aac889dbd44e69bcab62bf45f22864623326fff;p=thirdparty%2Fopen-vm-tools.git Change to common source files not applicable to open-vm-tools. --- diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c index 654512c5e..694371d10 100644 --- a/open-vm-tools/services/plugins/vix/vixTools.c +++ b/open-vm-tools/services/plugins/vix/vixTools.c @@ -241,11 +241,6 @@ char *gImpersonatedUsername = NULL; #endif -/* - * The config file groupname for API configuration. - */ -#define VIX_TOOLS_CONFIG_API_GROUPNAME "guestoperations" - /* * Authentication configuration. * There are various forms of authentication supported, @@ -2645,65 +2640,6 @@ VixToolsTranslateVGAuthError(VGAuthError vgErr) #endif -#if defined(_WIN32) -/* - *----------------------------------------------------------------------------- - * - * VixTools_ConfigGetString -- - * - * Wrapper for VMTools_ConfigGetString to retrieve values - * from VIX_TOOLS_CONFIG_API_GROUPNAME group. - * - * Return value: - * Value of the key if the value was read successfully, or else - * a copy of defValue unless defValue is NULL, in which case it's NULL. - * The returned string should be freed with g_free when no longer - * needed. - * - * Side effects: - * None - * - *----------------------------------------------------------------------------- - */ -gchar * -VixTools_ConfigGetString(const gchar *key, // IN - const gchar *defValue) // In -{ - - return VMTools_ConfigGetString(gConfDictRef, - VIX_TOOLS_CONFIG_API_GROUPNAME, - key, defValue); -} - - -/* - *----------------------------------------------------------------------------- - * - * VixTools_ConfigLogInvalidString -- - * - * Log a warning when a config string from the - * VIX_TOOLS_CONFIG_API_GROUPNAME group has an invalid value. - * - * Return value: - * None - * - * Side effects: - * None - * - *----------------------------------------------------------------------------- - */ -void -VixTools_ConfigLogInvalidString(const gchar *function, // IN - const gchar *key, // IN - const gchar *confValue, // IN - const gchar *usedValue) // IN -{ - g_warning("%s: invalid value '%s' from tools.conf [%s] %s, using %s.\n", - function, confValue, VIX_TOOLS_CONFIG_API_GROUPNAME, key, usedValue); -} -#endif - - /* *----------------------------------------------------------------------------- * @@ -12238,6 +12174,28 @@ GuestAuthUnloadUserProfileAndToken(HANDLE hToken, CloseHandle(hToken); } } + + +/* + *----------------------------------------------------------------------------- + * + * VixTools_GetConfDict -- + * + * Return pointer to dictionary used during VixTools_ProcessVixCommand + * + * Return value: + * Pointer to GKeyFile for dictionary + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ +GKeyFile * +VixTools_GetConfDict(void) +{ + return gConfDictRef; +} #endif // _WIN32 #endif // SUPPORT_VGAUTH diff --git a/open-vm-tools/services/plugins/vix/vixToolsInt.h b/open-vm-tools/services/plugins/vix/vixToolsInt.h index b91a9e90b..834f411ed 100644 --- a/open-vm-tools/services/plugins/vix/vixToolsInt.h +++ b/open-vm-tools/services/plugins/vix/vixToolsInt.h @@ -43,6 +43,12 @@ #include "VGAuthAlias.h" #endif + +/* + * The config file groupname for API configuration. + */ +#define VIX_TOOLS_CONFIG_API_GROUPNAME "guestoperations" + #define PROCESS_CREATOR_USER_TOKEN ((void *)1) #ifdef _WIN32 @@ -73,15 +79,10 @@ VixError VixTools_Initialize(Bool thisProcessRunsAsRootArg, void VixTools_Uninitialize(void); #ifdef _WIN32 -VixError VixToolsTranslateVGAuthError(VGAuthError vgErr); -gchar *VixTools_ConfigGetString(const gchar *key, - const gchar *defValue); +GKeyFile *VixTools_GetConfDict(void); -void VixTools_ConfigLogInvalidString(const gchar *function, - const gchar *key, - const gchar *confValue, - const gchar *usedValue); +VixError VixToolsTranslateVGAuthError(VGAuthError vgErr); #endif diff --git a/open-vm-tools/vgauth/lib/VGAuthInt.h b/open-vm-tools/vgauth/lib/VGAuthInt.h index ef2472296..73ed659aa 100644 --- a/open-vm-tools/vgauth/lib/VGAuthInt.h +++ b/open-vm-tools/vgauth/lib/VGAuthInt.h @@ -287,14 +287,14 @@ VGAuthError VGAuth_NetworkReadBytes(VGAuthContext *ctx, gsize *len, gchar **buffer); - -VGAuthError VGAuthValidateUsernamePasswordImpl(VGAuthContext *ctx, - const char *userName, - const char *password, - const int numExtraParams, - const VGAuthExtraParams - *extraParams, - VGAuthUserHandle **handle); +VGAuthError VGAuthValidateUsernamePasswordImpl( + VGAuthContext *ctx, + const char *userName, + const char *password, + const int numExtraParams, + const VGAuthExtraParams *extraParams, + VGAuthUserHandle **handle + ); #ifdef UNITTEST VGAuthError VGAuthComm_SetTestBufferInput(VGAuthContext *ctx, diff --git a/open-vm-tools/vgauth/lib/common.c b/open-vm-tools/vgauth/lib/common.c index 366976a6e..1db3a4f70 100644 --- a/open-vm-tools/vgauth/lib/common.c +++ b/open-vm-tools/vgauth/lib/common.c @@ -195,8 +195,8 @@ VGAuthGetStringExtraParamImpl(const char *funcName, const char *defValue, const char **paramValue) { - gboolean paramSet = FALSE; int i; + int paramIndex; if ((numParams < 0) || (numParams > 0 && NULL == params)) { Warning("%s: invalid number of parameters: %d.\n", funcName, numParams); @@ -207,27 +207,27 @@ VGAuthGetStringExtraParamImpl(const char *funcName, return VGAUTH_E_INVALID_ARGUMENT; } + paramIndex = -1; for (i = 0; i < numParams; i++) { if (g_strcmp0(params[i].name, paramName) == 0) { - // only allow it to be set once - if (paramSet) { + // make sure it's only specified once + if (paramIndex >= 0) { Warning("%s: extraParam '%s' passed multiple times.\n", funcName, params[i].name); return VGAUTH_E_INVALID_ARGUMENT; } - if (params[i].value) { - *paramValue = params[i].value; - paramSet = TRUE; - } else { - Warning("%s: extraParam '%s' has NULL value.\n", - funcName, params[i].name); - return VGAUTH_E_INVALID_ARGUMENT; - } + paramIndex = i; } } - if (!paramSet) { + if (paramIndex < 0) { *paramValue = defValue; + } else if (params[paramIndex].value != NULL) { + *paramValue = params[paramIndex].value; + } else { + Warning("%s: extraParam '%s' has NULL value.\n", + funcName, params[i].name); + return VGAUTH_E_INVALID_ARGUMENT; } return VGAUTH_E_OK; }