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

« back to all changes in this revision

Viewing changes to vmware-user-suid-wrapper/wrapper-freebsd.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:
23
23
 */
24
24
 
25
25
 
26
 
#include <sys/param.h>
27
 
#include <sys/mount.h>
28
 
#include <sys/uio.h>    // for nmount(2)
29
 
#include <sys/linker.h> // for kldfind(2), kldload(2), etc.
30
 
 
31
26
#include <errno.h>
32
27
#include <stdio.h>
33
28
#include <stdlib.h>
43
38
 */
44
39
 
45
40
 
46
 
/*
47
 
 *----------------------------------------------------------------------------
48
 
 *
49
 
 * GetModuleId --
50
 
 *
51
 
 *      Finds the id of the provided loaded module.
52
 
 *
53
 
 * Results:
54
 
 *      The id on success, a negative error code on failure.
55
 
 *
56
 
 * Side effects:
57
 
 *      None.
58
 
 *
59
 
 *----------------------------------------------------------------------------
60
 
 */
61
 
 
62
 
int
63
 
GetModuleId(const char *name)   // IN: module name to search for
64
 
{
65
 
   return kldfind(name);
66
 
}
67
 
 
68
 
 
69
 
/*
70
 
 *-----------------------------------------------------------------------------
71
 
 *
72
 
 * UnloadModule --
73
 
 *
74
 
 *      Lookup and, if loaded, unload the VMBlock kernel module.
75
 
 *
76
 
 * Results:
77
 
 *      TRUE on success, FALSE otherwise
78
 
 *
79
 
 * Side effects:
80
 
 *      None.
81
 
 *
82
 
 *-----------------------------------------------------------------------------
83
 
 */
84
 
 
85
 
Bool
86
 
UnloadModule(int id)    // IN: module id for kldunload(2) 
87
 
{
88
 
   if (kldunload(id) < 0) {
89
 
      Error("failed to unload vmblock: %s\n", strerror(errno));
90
 
      return FALSE;
91
 
   }
92
 
 
93
 
   return TRUE;
94
 
}
95
 
 
96
 
 
97
 
/*
98
 
 *-----------------------------------------------------------------------------
99
 
 *
100
 
 * LoadVMBlock --
101
 
 *
102
 
 *      Load the VMBlock kernel module.
103
 
 *
104
 
 * Results:
105
 
 *      TRUE on success, FALSE otherwise
106
 
 *
107
 
 * Side effects:
108
 
 *      None.
109
 
 *
110
 
 *-----------------------------------------------------------------------------
111
 
 */
112
 
 
113
 
Bool
114
 
LoadVMBlock(void)
115
 
{
116
 
   /*
117
 
    * Kldload(2) will handle module search paths for us.
118
 
    */
119
 
   if (kldload(MODULE_NAME) == -1) {
120
 
      Error("failed to load vmblock: %s\n", strerror(errno));
121
 
      return FALSE;
122
 
   }
123
 
 
124
 
   return TRUE;
125
 
}
126
 
 
127
 
 
128
 
/*
129
 
 *-----------------------------------------------------------------------------
130
 
 *
131
 
 * UnmountVMBlock --
132
 
 *
133
 
 *      Unmount the VMBlock file system.
134
 
 *
135
 
 * Results:
136
 
 *      TRUE on success, FALSE otherwise.
137
 
 *
138
 
 * Side effects:
139
 
 *      None.
140
 
 *
141
 
 *-----------------------------------------------------------------------------
142
 
 */
143
 
 
144
 
Bool
145
 
UnmountVMBlock(const char *mountPoint)  // IN: VMBlock mount point
146
 
{
147
 
   if (unmount(mountPoint, 0) == -1) {
148
 
      return FALSE;
149
 
   }
150
 
   return TRUE;
151
 
}
152
 
 
153
 
 
154
 
/*
155
 
 *-----------------------------------------------------------------------------
156
 
 *
157
 
 * MountVMBlock --
158
 
 *
159
 
 *      Mount the VMBlock file system.
160
 
 *
161
 
 * Results:
162
 
 *      TRUE on success, FALSE otherwise
163
 
 *
164
 
 * Side effects:
165
 
 *      None.
166
 
 *
167
 
 *-----------------------------------------------------------------------------
168
 
 */
169
 
 
170
 
Bool
171
 
MountVMBlock(void)
172
 
{
173
 
   /*
174
 
    * These arguments are given as interleaved key => value pairs.  We're
175
 
    * requesting mount of the VMBlock filesystem (fstype), with TMP_DIR (target)
176
 
    * remounted over VMBLOCK_MOUNT_POINT (fspath).
177
 
    */
178
 
   struct iovec iov[] = {
179
 
      { .iov_base = "fstype", .iov_len = sizeof "fstype" },
180
 
      { .iov_base = "vmblock", .iov_len = sizeof "vmblock" },
181
 
      { .iov_base = "fspath", .iov_len = sizeof "fspath" },
182
 
      { .iov_base = VMBLOCK_MOUNT_POINT, .iov_len = sizeof VMBLOCK_MOUNT_POINT },
183
 
      { .iov_base = "target", .iov_len = sizeof "target" },
184
 
      { .iov_base = TMP_DIR, .iov_len = sizeof TMP_DIR }
185
 
   };
186
 
 
187
 
   if (nmount(iov, ARRAYSIZE(iov), MNT_NOSUID) == -1) {
188
 
      Error("failed to mount vmblock file system: %s\n", strerror(errno));
189
 
      return FALSE;
190
 
   }
191
 
 
192
 
   return TRUE;
193
 
}
194
 
 
195
 
 
196
41
#ifdef USES_LOCATIONS_DB
197
42
/*
198
43
 *-----------------------------------------------------------------------------