Mounting /tmp at TMP or TEMP as a last resort
Thu Sep 9 23:06:00 GMT 2010
On 09/09/2010 2:16 PM, Pierre A. Humblet wrote:
> So, for example, if the user logs in interactively while a cron job (or another service)
> is running, /tmp may be mapped differently than if no cron job is running, because
> TMP may be defined differently in the service environment.
> That is not desirable.
I believe that information is kept in Cygwin shared memory regions on a per-user
basis. I imagine there would other other unwanted side-effects if this were not the
Assuming this to be the case, services running as SYSTEM or another user
cannot influence the mount decision of /tmp for the current user.
So the only consideration is if there is a service running alongside the
currently logged in user.
1. /tmp specified in /etc/fstab
2. /tmp present on filesystem.
No difference in behaviour with proposed patch in these cases.
3. /tmp not present in either /etc/fstab or filesystem, and no TMP or TEMP
No /tmp is available. Programs will have manage without it.
4. /tmp not present in either /etc/fstab or filesystem, but either TMP or TEMP present
Without the patch, this is the same as case (3).
Settings for TMP or TEMP are injected into the Win32 process via the
User Environment Variables:
Thus the service-running-as-user and the logged in user would inherit
the same values.
I can see one way to subvert (4). It is possible for a service to run as
a plain Win32 process, modify TMP (or TEMP), then launch the first
Cygwin process which would then mount /tmp at the modified location.
A similar scenario could occur the other way around too.
I think these scenarios are not likely to occur often. Usually TMP and TEMP
are set as User Environment Variables and don't get changed.
If it's important to lock down the location of /tmp, then either create /tmp
in the filesystem or create an entry in /etc/fstab. This is what you're
required to do in the current implementation anyway because without it, no
/tmp is made available (and bash will complain, etc).
More information about the Cygwin-patches