From: Oliver Kurth Date: Mon, 4 May 2020 18:54:12 +0000 (-0700) Subject: Define macro for "Permission Denied" message returned from RpcChannel send APIs. X-Git-Tag: stable-11.2.0~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7058e42e6fa34dcf60438d27827d9b9ba20f5bd1;p=thirdparty%2Fopen-vm-tools.git Define macro for "Permission Denied" message returned from RpcChannel send APIs. In error cases, RpcChannel Send APIs (RpcChannel_SendOneRaw, RpcChannel_SendOneRawPriv return 'hard coded' "Permission Denied" error message. This changeset adds the MACRO for that error message. If there are any callers who compare the results (ex: ServiceDiscovery), they don't have to use 'hardcoded' messages and can reuse the MACROs. --- diff --git a/open-vm-tools/lib/include/vmware/tools/guestrpc.h b/open-vm-tools/lib/include/vmware/tools/guestrpc.h index b10972962..667023b7f 100644 --- a/open-vm-tools/lib/include/vmware/tools/guestrpc.h +++ b/open-vm-tools/lib/include/vmware/tools/guestrpc.h @@ -45,6 +45,10 @@ G_BEGIN_DECLS #define RPCIN_SETRETVALS RpcChannel_SetRetVals #define RPCIN_SETRETVALSF RpcChannel_SetRetValsF +/** Error messages returned by RpcChannel Send APIs **/ + +#define RPCCHANNEL_SEND_PERMISSION_DENIED "Permission denied" + typedef struct _RpcChannel RpcChannel; /** Data structure passed to RPC callbacks. */ diff --git a/open-vm-tools/lib/rpcChannel/rpcChannel.c b/open-vm-tools/lib/rpcChannel/rpcChannel.c index 1631fee0e..111efa40d 100644 --- a/open-vm-tools/lib/rpcChannel/rpcChannel.c +++ b/open-vm-tools/lib/rpcChannel/rpcChannel.c @@ -1194,7 +1194,7 @@ RpcChannelSendOneRaw(const char *data, goto sent; } else if (priv && RpcChannel_GetType(chan) != RPCCHANNEL_TYPE_PRIV_VSOCK) { if (result != NULL) { - *result = Util_SafeStrdup("Permission denied"); + *result = Util_SafeStrdup(RPCCHANNEL_SEND_PERMISSION_DENIED); if (resultLen != NULL) { *resultLen = strlen(*result); } diff --git a/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c b/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c index a5da6e965..f57f02446 100644 --- a/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c +++ b/open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c @@ -224,11 +224,11 @@ SendRpcMessage(ToolsAppCtx *ctx, status = RpcChannel_SendOneRawPriv(msg, msgLen, result, resultLen); /* - * RpcChannel_SendOneRawPriv returns 'Permission denied' if the - * privileged vsocket can not be established. + * RpcChannel_SendOneRawPriv returns RPCCHANNEL_SEND_PERMISSION_DENIED + * if the privileged vsocket can not be established. */ if (!status && result != NULL && - strcmp(*result, "Permission denied") == 0) { + strcmp(*result, RPCCHANNEL_SEND_PERMISSION_DENIED) == 0) { g_debug("%s: Retrying RPC send", __FUNCTION__); free(*result); g_usleep(SERVICE_DISCOVERY_RPC_WAIT_TIME * 1000);