]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
suidWrapper: Ignore SIGUSR1, SIGUSR2.
authorVMware, Inc <>
Mon, 26 Apr 2010 18:25:07 +0000 (11:25 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 27 Apr 2010 03:48:53 +0000 (20:48 -0700)
Ubuntu 9.10+'s Upstart may result in the services script and
vmware-user launching concurrently.  When this happens, the services
script may deliver SIGUSR1 and/or SIGUSR2 to vmware-user while it's
still executing inside the suidWrapper or appLoader.  Neither were
handling SIGUSR1/2, and so they'd terminate.

This change sets the handler to SIG_IGN for these signals.
Note that SIG_IGN persists across fork() and execve(), so we
don't need to block the handles again inside the appLoader driver
(toolbox/linux/vmwareuser/loader).

As a setuid application, classically we avoided pulling in other
libraries, but the vmsignal library is safe.  It's tiny and doesn't
use bora/bora-vmsoft at all, so its use here is okay.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/vmware-user-suid-wrapper/main.c

index e58f90fa3b28b9de124795424a5adfca57148285..a34c784cec144623d5f9da3c5eebbcfddc5bcfb9 100644 (file)
@@ -51,6 +51,7 @@
 
 #include "vmware.h"
 #include "vmblock.h"
+#include "vmsignal.h"
 #include "wrapper.h"
 
 #include "wrapper_version.h"
@@ -70,6 +71,7 @@ static Bool MakeDirectory(const char *path, mode_t mode, uid_t uid, gid_t gid);
 static Bool ChmodChownDirectory(const char *path,
                                 mode_t mode, uid_t uid, gid_t gid);
 #endif
+static void MaskSignals(void);
 static Bool StartVMwareUser(char *const envp[]);
 
 
@@ -106,6 +108,8 @@ main(int argc,
      char *argv[],
      char *envp[])
 {
+   MaskSignals();
+
 #ifdef TOGGLE_VMBLOCK
    ToggleVMBlock();
 #endif
@@ -361,6 +365,42 @@ out:
 #endif  // ifdef TOGGLE_VMBLOCK
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * MaskSignals --
+ *
+ *      Sets SIG_IGN as the handler for SIGUSR1 and SIGUSR2 which may arrive
+ *      prematurely from our services script.  See bug 542135.
+ *
+ * Results:
+ *      Returns if applicable signals are blocked.
+ *      Exits with EXIT_FAILURE otherwise.
+ *
+ * Side effects:
+ *      SIG_IGN disposition persists across execve().  These signals will
+ *      remain masked until vmware-user defines its own handlers.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static void
+MaskSignals(void)
+{
+   int const signals[] = {
+      SIGUSR1,
+      SIGUSR2
+   };
+   struct sigaction olds[ARRAYSIZE(signals)];
+
+   if (Signal_SetGroupHandler(signals, olds, ARRAYSIZE(signals),
+                              SIG_IGN) == 0) {
+      /* Signal_SetGroupHandler will write error message to stderr. */
+      exit(EXIT_FAILURE);
+   }
+}
+
+
 /*
  *----------------------------------------------------------------------------
  *