]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Define macro for "Permission Denied" message returned from RpcChannel send APIs.
authorOliver Kurth <okurth@vmware.com>
Mon, 4 May 2020 18:54:12 +0000 (11:54 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 4 May 2020 18:54:12 +0000 (11:54 -0700)
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.

open-vm-tools/lib/include/vmware/tools/guestrpc.h
open-vm-tools/lib/rpcChannel/rpcChannel.c
open-vm-tools/services/plugins/serviceDiscovery/serviceDiscovery.c

index b10972962402ca1f2eef4e42aab5a5e0748eb021..667023b7f48022df2d10eb4292dfb1ee0c97c16c 100644 (file)
@@ -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. */
index 1631fee0e15faadc513ca89682c853404bcff65b..111efa40dc47bcb81ce154895df187470e060645 100644 (file)
@@ -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);
          }
index a5da6e965ddf6e5b17bb3ee686e22828081e1171..f57f02446920f26db6728be2d8dd3dee3bb11641 100644 (file)
@@ -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);