From: VMware, Inc <> Date: Mon, 26 Apr 2010 18:25:07 +0000 (-0700) Subject: suidWrapper: Ignore SIGUSR1, SIGUSR2. X-Git-Tag: 2010.04.25-253928~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b73b7f5e7012b8da77231cf479afae8d287a82d;p=thirdparty%2Fopen-vm-tools.git suidWrapper: Ignore SIGUSR1, SIGUSR2. 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 --- diff --git a/open-vm-tools/vmware-user-suid-wrapper/main.c b/open-vm-tools/vmware-user-suid-wrapper/main.c index e58f90fa3..a34c784ce 100644 --- a/open-vm-tools/vmware-user-suid-wrapper/main.c +++ b/open-vm-tools/vmware-user-suid-wrapper/main.c @@ -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); + } +} + + /* *---------------------------------------------------------------------------- *