~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to services/plugins/hgfsServer/hgfsPlugin.c

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#define G_LOG_DOMAIN "hgfsd"
28
28
 
29
29
#include "hgfs.h"
30
 
#include "hgfsServerPolicy.h"
31
 
#include "hgfsServer.h"
32
 
#include "hgfsChannel.h"
 
30
#include "hgfsServerManager.h"
33
31
#include "vm_assert.h"
34
32
#include "vmware/guestrpc/tclodefs.h"
35
33
#include "vmware/tools/plugin.h"
36
34
#include "vmware/tools/utils.h"
37
35
 
 
36
 
38
37
#if !defined(__APPLE__)
39
38
#include "embed_version.h"
40
39
#include "vmtoolsd_version.h"
43
42
 
44
43
 
45
44
/**
46
 
 * Sets up the channel for HGFS.
47
 
 *
48
 
 * NOTE: Initialize the Hgfs server for only for now.
49
 
 * This will move into a separate file when full interface implemented.
50
 
 *
51
 
 * @param[in]  data  Unused RPC request data.
52
 
 *
53
 
 * @return TRUE on success, FALSE on error.
54
 
 */
55
 
 
56
 
Bool
57
 
HgfsChannel_Init(void *data)     // IN: Unused data
58
 
{
59
 
   HgfsServerSessionCallbacks *serverCBTable = NULL;
60
 
   return HgfsServer_InitState(&serverCBTable, NULL);
61
 
}
62
 
 
63
 
 
64
 
/**
65
 
 * Close up the channel for HGFS.
66
 
 *
67
 
 * NOTE: Close open sessions in the HGFS server currently.
68
 
 * This will move into a separate file when full interface implemented.
69
 
 *
70
 
 * @param[in]  data  Unused RPC request data.
71
 
 *
72
 
 * @return None.
73
 
 */
74
 
 
75
 
void
76
 
HgfsChannel_Exit(void *data)
77
 
{
78
 
   ASSERT(data != NULL);
79
 
   HgfsServer_ExitState();
 
45
 * Clean up internal state on shutdown.
 
46
 *
 
47
 * @param[in]  src      The source object.
 
48
 * @param[in]  ctx      Unused.
 
49
 * @param[in]  plugin   Plugin registration data.
 
50
 */
 
51
 
 
52
static void
 
53
HgfsServerShutdown(gpointer src,
 
54
                   ToolsAppCtx *ctx,
 
55
                   ToolsPluginData *plugin)
 
56
{
 
57
   HgfsServerMgrData *mgrData = plugin->_private;
 
58
   HgfsServerManager_Unregister(mgrData);
 
59
   g_free(mgrData);
80
60
}
81
61
 
82
62
 
89
69
 */
90
70
 
91
71
static gboolean
92
 
HgfsServerRpcInDispatch(RpcInData *data)
 
72
HgfsServerRpcDispatch(RpcInData *data)
93
73
{
94
 
   size_t packetSize;
95
 
   static char packet[HGFS_LARGE_PACKET_MAX];
96
 
 
97
 
 
98
 
   ASSERT(data->clientData == NULL);
 
74
   HgfsServerMgrData *mgrData;
 
75
   size_t replySize;
 
76
   static char reply[HGFS_LARGE_PACKET_MAX];
 
77
 
 
78
 
 
79
   ASSERT(data->clientData != NULL);
 
80
   mgrData = data->clientData;
99
81
 
100
82
   if (data->argsSize == 0) {
101
83
      return RPCIN_SETRETVALS(data, "1 argument required", FALSE);
102
84
   }
103
85
 
104
 
   packetSize = data->argsSize - 1;
105
 
   HgfsServer_ProcessPacket(data->args + 1, packet, &packetSize);
 
86
   replySize = sizeof reply;
 
87
   HgfsServerManager_ProcessPacket(mgrData, data->args + 1, data->argsSize - 1, reply, &replySize);
106
88
 
107
 
   data->result = packet;
108
 
   data->resultLen = packetSize;
 
89
   data->result = reply;
 
90
   data->resultLen = replySize;
109
91
   return TRUE;
110
92
}
111
93
 
125
107
HgfsServerCapReg(gpointer src,
126
108
                 ToolsAppCtx *ctx,
127
109
                 gboolean set,
128
 
                 gpointer data)
 
110
                 ToolsPluginData *plugin)
129
111
{
130
112
   gchar *msg;
131
113
   const char *appName = NULL;
135
117
   } else if (strcmp(ctx->name, VMTOOLS_USER_SERVICE) == 0) {
136
118
      appName = TOOLS_DND_NAME;
137
119
   } else {
138
 
      g_error("Shouldn't reach this.\n");
 
120
      NOT_REACHED();
139
121
   }
140
122
 
141
123
   msg = g_strdup_printf("tools.capability.hgfs_server %s %d",
175
157
      NULL,
176
158
      NULL
177
159
   };
 
160
   HgfsServerMgrData *mgrData;
178
161
 
179
162
   if (strcmp(ctx->name, VMTOOLS_GUEST_SERVICE) != 0 &&
180
163
       strcmp(ctx->name, VMTOOLS_USER_SERVICE) != 0) {
182
165
      return NULL;
183
166
   }
184
167
 
185
 
   /*
186
 
    * Passing NULL here is safe because the shares maintained by the guest
187
 
    * policy server never change, invalidating the need for an invalidate
188
 
    * function.
189
 
    */
190
 
   if (!HgfsServerPolicy_Init(NULL)) {
191
 
      g_warning("HgfsServerPolicy_Init() failed, aborting HGFS server init.\n");
192
 
      return NULL;
193
 
   }
 
168
   mgrData = g_malloc0(sizeof *mgrData);
 
169
   HgfsServerManager_DataInit(mgrData,
 
170
                              ctx->name,
 
171
                              NULL,       // rpc channel unused
 
172
                              NULL);      // no rpc callback
194
173
 
195
 
   if (!HgfsChannel_Init(NULL)) {
 
174
   if (!HgfsServerManager_Register(mgrData)) {
196
175
      g_warning("HgfsServer_InitState() failed, aborting HGFS server init.\n");
197
 
      HgfsServerPolicy_Cleanup();
 
176
      g_free(mgrData);
198
177
      return NULL;
199
178
   }
200
179
 
201
180
   {
202
181
      RpcChannelCallback rpcs[] = {
203
 
         { HGFS_SYNC_REQREP_CMD, HgfsServerRpcInDispatch, NULL, NULL, NULL, 0 }
 
182
         { HGFS_SYNC_REQREP_CMD, HgfsServerRpcDispatch, mgrData, NULL, NULL, 0 }
204
183
      };
205
184
      ToolsPluginSignalCb sigs[] = {
206
 
         { TOOLS_CORE_SIG_CAPABILITIES, HgfsServerCapReg, &regData }
 
185
         { TOOLS_CORE_SIG_CAPABILITIES, HgfsServerCapReg, &regData },
 
186
         { TOOLS_CORE_SIG_SHUTDOWN, HgfsServerShutdown, &regData }
207
187
      };
208
188
      ToolsAppReg regs[] = {
209
189
         { TOOLS_APP_GUESTRPC, VMTools_WrapArray(rpcs, sizeof *rpcs, ARRAYSIZE(rpcs)) },
212
192
 
213
193
      regData.regs = VMTools_WrapArray(regs, sizeof *regs, ARRAYSIZE(regs));
214
194
   }
 
195
   regData._private = mgrData;
215
196
 
216
197
   return &regData;
217
198
}