<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/cxx/ApplicationPool_PoolTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/ApplicationPool_PoolTestCases.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/ApplicationPool_ServerTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/ApplicationPool_Server_PoolTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/Base64Test.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/CachedFileStatTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/CxxTestMain.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/FileChangeCheckerTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/FileDescriptorTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/HttpStatusExtractorTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/MessageChannelTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/MessageServerTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/PoolOptionsTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/ScgiRequestParserTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/ServerInstanceDirTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/SpawnManagerTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/StaticStringTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/SystemTimeTest.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/TestSupport.cpp</filename>
    </added>
    <added>
      <filename>test/cxx/TestSupport.h</filename>
    </added>
    <added>
      <filename>test/cxx/UtilsTest.cpp</filename>
    </added>
    <added>
      <filename>test/tut/tut.h</filename>
    </added>
    <added>
      <filename>test/tut/tut_reporter.h</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -12,7 +12,6 @@ ext/apache2/*.la
 ext/apache2/*.lo
 ext/apache2/*.slo
 ext/apache2/.libs
-ext/apache2/ApplicationPoolServerExecutable
 ext/apache2/PassengerWatchdog
 ext/apache2/PassengerHelperServer
 ext/nginx/HelperServer
@@ -25,8 +24,7 @@ test/test.log
 test/apache2.log
 test/config.yml
 test/coverage
-test/CxxTests
-test/ApplicationPoolServerExecutable
+test/cxx/CxxTestMain
 test/oxt/oxt_test_main
 test/stub/railsapp/app/controllers/bar_controller.rb
 test/stub/apache2/*.log</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -392,33 +392,61 @@ end
 		'syscall_interruption_test.o' =&gt; %w(syscall_interruption_test.cpp)
 	}
 	
+	desc &quot;Run unit tests for the OXT library&quot;
+	task 'test:oxt' =&gt; 'test/oxt/oxt_test_main' do
+		sh &quot;cd test &amp;&amp; ./oxt/oxt_test_main&quot;
+	end
+	
+	# Define task for test/oxt/oxt_test_main.
+	oxt_test_main_dependencies = TEST_OXT_OBJECTS.keys.map do |object|
+		&quot;test/oxt/#{object}&quot;
+	end
+	oxt_test_main_dependencies &lt;&lt; TEST_BOOST_OXT_LIBRARY
+	file 'test/oxt/oxt_test_main' =&gt; oxt_test_main_dependencies do
+		objects = TEST_OXT_OBJECTS.keys.map{ |x| &quot;test/oxt/#{x}&quot; }.join(' ')
+		create_executable(&quot;test/oxt/oxt_test_main&quot;, objects, TEST_OXT_LDFLAGS)
+	end
+	
+	# Define tasks for each OXT test source file.
+	TEST_OXT_OBJECTS.each_pair do |target, sources|
+		file &quot;test/oxt/#{target}&quot; =&gt; sources.map{ |x| &quot;test/oxt/#{x}&quot; } do
+			Dir.chdir('test/oxt') do
+				puts &quot;### In test/oxt:&quot;
+				compile_cxx sources[0], TEST_OXT_CFLAGS
+			end
+		end
+	end
+	
+	
+	### C++ components tests ###
+	
 	TEST_CXX_CFLAGS = &quot;-Iext -Iext/common -Iext/nginx -Itest/support &quot; &lt;&lt;
 		&quot;#{PlatformInfo.apr_flags} #{PlatformInfo.apu_flags} #{TEST_COMMON_CFLAGS}&quot;
 	TEST_CXX_LDFLAGS = &quot;#{PlatformInfo.apr_libs} #{PlatformInfo.apu_libs} &quot; &lt;&lt;
 		&quot;#{TEST_COMMON_LIBRARY} #{TEST_BOOST_OXT_LIBRARY} &quot; &lt;&lt;
 		&quot;#{PlatformInfo.portability_ldflags} #{EXTRA_LDFLAGS}&quot;
 	TEST_CXX_OBJECTS = {
-		'test/CxxTestMain.o' =&gt; %w(
-			test/CxxTestMain.cpp),
-		'test/support/Support.o' =&gt; %w(
-			test/support/Support.cpp
-			test/support/Support.h),
-		'test/MessageChannelTest.o' =&gt; %w(
-			test/MessageChannelTest.cpp
+		'test/cxx/CxxTestMain.o' =&gt; %w(
+			test/cxx/CxxTestMain.cpp),
+		'test/cxx/TestSupport.o' =&gt; %w(
+			test/cxx/TestSupport.cpp
+			test/cxx/TestSupport.h),
+		'test/cxx/MessageChannelTest.o' =&gt; %w(
+			test/cxx/MessageChannelTest.cpp
 			ext/common/MessageChannel.h
 			ext/common/Exceptions.h
 			ext/common/Timer.h
 			ext/common/Utils.h),
-		'test/SpawnManagerTest.o' =&gt; %w(
-			test/SpawnManagerTest.cpp
+		'test/cxx/SpawnManagerTest.o' =&gt; %w(
+			test/cxx/SpawnManagerTest.cpp
 			ext/common/SpawnManager.h
 			ext/common/AbstractSpawnManager.h
 			ext/common/PoolOptions.h
 			ext/common/StringListCreator.h
 			ext/common/Application.h
 			ext/common/MessageChannel.h),
-		'test/ApplicationPool_ServerTest.o' =&gt; %w(
-			test/ApplicationPool_ServerTest.cpp
+		'test/cxx/ApplicationPool_ServerTest.o' =&gt; %w(
+			test/cxx/ApplicationPool_ServerTest.cpp
 			ext/common/ApplicationPool/Interface.h
 			ext/common/ApplicationPool/Server.h
 			ext/common/ApplicationPool/Client.h
@@ -429,9 +457,9 @@ end
 			ext/common/PoolOptions.h
 			ext/common/StringListCreator.h
 			ext/common/MessageChannel.h),
-		'test/ApplicationPool_Server_PoolTest.o' =&gt; %w(
-			test/ApplicationPool_Server_PoolTest.cpp
-			test/ApplicationPool_PoolTestCases.cpp
+		'test/cxx/ApplicationPool_Server_PoolTest.o' =&gt; %w(
+			test/cxx/ApplicationPool_Server_PoolTest.cpp
+			test/cxx/ApplicationPool_PoolTestCases.cpp
 			ext/common/ApplicationPool/Interface.h
 			ext/common/ApplicationPool/Server.h
 			ext/common/ApplicationPool/Client.h
@@ -445,9 +473,9 @@ end
 			ext/common/StringListCreator.h
 			ext/common/Application.h
 			ext/common/MessageChannel.h),
-		'test/ApplicationPool_PoolTest.o' =&gt; %w(
-			test/ApplicationPool_PoolTest.cpp
-			test/ApplicationPool_PoolTestCases.cpp
+		'test/cxx/ApplicationPool_PoolTest.o' =&gt; %w(
+			test/cxx/ApplicationPool_PoolTest.cpp
+			test/cxx/ApplicationPool_PoolTestCases.cpp
 			ext/common/ApplicationPool/Interface.h
 			ext/common/ApplicationPool/Pool.h
 			ext/common/AbstractSpawnManager.h
@@ -457,102 +485,74 @@ end
 			ext/common/FileChangeChecker.h
 			ext/common/CachedFileStat.hpp
 			ext/common/Application.h),
-		'test/PoolOptionsTest.o' =&gt; %w(
-			test/PoolOptionsTest.cpp
+		'test/cxx/PoolOptionsTest.o' =&gt; %w(
+			test/cxx/PoolOptionsTest.cpp
 			ext/common/PoolOptions.h
 			ext/common/StringListCreator.h),
-		'test/StaticStringTest.o' =&gt; %w(
-			test/StaticStringTest.cpp
+		'test/cxx/StaticStringTest.o' =&gt; %w(
+			test/cxx/StaticStringTest.cpp
 			ext/common/StaticString.h),
-		'test/Base64Test.o' =&gt; %w(
-			test/Base64Test.cpp
+		'test/cxx/Base64Test.o' =&gt; %w(
+			test/cxx/Base64Test.cpp
 			ext/common/Base64.h
 			ext/common/Base64.cpp),
-		'test/ScgiRequestParserTest.o' =&gt; %w(
-			test/ScgiRequestParserTest.cpp
+		'test/cxx/ScgiRequestParserTest.o' =&gt; %w(
+			test/cxx/ScgiRequestParserTest.cpp
 			ext/nginx/ScgiRequestParser.h
 			ext/common/StaticString.h),
-		'test/HttpStatusExtractorTest.o' =&gt; %w(
-			test/HttpStatusExtractorTest.cpp
+		'test/cxx/HttpStatusExtractorTest.o' =&gt; %w(
+			test/cxx/HttpStatusExtractorTest.cpp
 			ext/nginx/HttpStatusExtractor.h),
-		'test/MessageServerTest.o' =&gt; %w(
-			test/MessageServerTest.cpp
+		'test/cxx/MessageServerTest.o' =&gt; %w(
+			test/cxx/MessageServerTest.cpp
 			ext/common/ApplicationPool/Client.h
 			ext/common/Account.h
 			ext/common/AccountsDatabase.h
 			ext/common/MessageServer.h
 			ext/common/MessageChannel.h),
-		'test/ServerInstanceDir.o' =&gt; %w(
-			test/ServerInstanceDirTest.cpp
+		'test/cxx/ServerInstanceDir.o' =&gt; %w(
+			test/cxx/ServerInstanceDirTest.cpp
 			ext/common/ServerInstanceDir.h
 			ext/common/Utils.h),
-		'test/FileChangeCheckerTest.o' =&gt; %w(
-			test/FileChangeCheckerTest.cpp
+		'test/cxx/FileChangeCheckerTest.o' =&gt; %w(
+			test/cxx/FileChangeCheckerTest.cpp
 			ext/common/FileChangeChecker.h
 			ext/common/CachedFileStat.hpp),
-		'test/FileDescriptorTest.o' =&gt; %w(
-			test/FileDescriptorTest.cpp
+		'test/cxx/FileDescriptorTest.o' =&gt; %w(
+			test/cxx/FileDescriptorTest.cpp
 			ext/common/FileDescriptor.h),
-		'test/SystemTimeTest.o' =&gt; %w(
-			test/SystemTimeTest.cpp
+		'test/cxx/SystemTimeTest.o' =&gt; %w(
+			test/cxx/SystemTimeTest.cpp
 			ext/common/SystemTime.h
 			ext/common/SystemTime.cpp),
-		'test/CachedFileStatTest.o' =&gt; %w(
-			test/CachedFileStatTest.cpp
+		'test/cxx/CachedFileStatTest.o' =&gt; %w(
+			test/cxx/CachedFileStatTest.cpp
 			ext/common/CachedFileStat.hpp
 			ext/common/CachedFileStat.cpp),
-		'test/UtilsTest.o' =&gt; %w(
-			test/UtilsTest.cpp
+		'test/cxx/UtilsTest.o' =&gt; %w(
+			test/cxx/UtilsTest.cpp
 			ext/common/Utils.h)
 	}
 	
-	desc &quot;Run unit tests for the OXT library&quot;
-	task 'test:oxt' =&gt; 'test/oxt/oxt_test_main' do
-		sh &quot;cd test &amp;&amp; ./oxt/oxt_test_main&quot;
-	end
-	
-	# Define task for test/oxt/oxt_test_main.
-	oxt_test_main_dependencies = TEST_OXT_OBJECTS.keys.map do |object|
-		&quot;test/oxt/#{object}&quot;
-	end
-	oxt_test_main_dependencies &lt;&lt; TEST_BOOST_OXT_LIBRARY
-	file 'test/oxt/oxt_test_main' =&gt; oxt_test_main_dependencies do
-		objects = TEST_OXT_OBJECTS.keys.map{ |x| &quot;test/oxt/#{x}&quot; }.join(' ')
-		create_executable(&quot;test/oxt/oxt_test_main&quot;, objects, TEST_OXT_LDFLAGS)
-	end
-	
-	# Define tasks for each OXT test source file.
-	TEST_OXT_OBJECTS.each_pair do |target, sources|
-		file &quot;test/oxt/#{target}&quot; =&gt; sources.map{ |x| &quot;test/oxt/#{x}&quot; } + ['test/support/Support.h'] do
-			Dir.chdir('test/oxt') do
-				puts &quot;### In test/oxt:&quot;
-				compile_cxx sources[0], TEST_OXT_CFLAGS
-			end
-		end
-	end
-	
-	
-	### C++ components tests ###
-	
 	desc &quot;Run unit tests for the Apache 2 and Nginx C++ components&quot;
-	task 'test:cxx' =&gt; ['test/CxxTests', :native_support] do
+	task 'test:cxx' =&gt; ['test/cxx/CxxTestMain', :native_support] do
 	        if ENV['GROUPS'].to_s.empty?
-		        sh &quot;cd test &amp;&amp; ./CxxTests&quot;
+		        sh &quot;cd test &amp;&amp; ./cxx/CxxTestMain&quot;
 	        else
 	                args = ENV['GROUPS'].split(&quot;,&quot;).map{ |name| &quot;-g #{name}&quot; }
-	                sh &quot;cd test &amp;&amp; ./CxxTests #{args.join(' ')}&quot;
+	                sh &quot;cd test &amp;&amp; ./cxx/CxxTestMain #{args.join(' ')}&quot;
                 end
 	end
 	
 	cxx_tests_dependencies = [TEST_CXX_OBJECTS.keys,
 		TEST_BOOST_OXT_LIBRARY, TEST_COMMON_LIBRARY]
-	file 'test/CxxTests' =&gt; cxx_tests_dependencies.flatten do
+	file 'test/cxx/CxxTestMain' =&gt; cxx_tests_dependencies.flatten do
 		objects = TEST_CXX_OBJECTS.keys.join(' ')
-		create_executable(&quot;test/CxxTests&quot;, objects, TEST_CXX_LDFLAGS)
+		create_executable(&quot;test/cxx/CxxTestMain&quot;, objects, TEST_CXX_LDFLAGS)
 	end
 	
 	TEST_CXX_OBJECTS.each_pair do |target, sources|
-		file(target =&gt; sources) do
+		file(target =&gt; sources + ['test/cxx/TestSupport.h']) do
 			compile_cxx sources[0], &quot;-o #{target} #{TEST_CXX_CFLAGS}&quot;
 		end
 	end
@@ -753,9 +753,10 @@ spec = Gem::Specification.new do |s|
 		'misc/*',
 		'misc/*/*',
 		'vendor/**/*',
-		'test/*.{rb,cpp,example}',
+		'test/*.example',
 		'test/support/*.{cpp,h,rb}',
-		'test/oxt/*.cpp',
+		'test/cxx/*.{cpp,h}',
+		'test/oxt/*.{cpp,hpp}',
 		'test/ruby/**/*',
 		'test/integration_tests/**/*',
 		'test/stub/**/*'</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -605,9 +605,9 @@ public:
 	 * @throws boost::thread_resource_error Cannot spawn a new thread.
 	 */
 	Pool(const string &amp;spawnServerCommand,
+	     const ServerInstanceDir::GenerationPtr &amp;generation,
 	     const string &amp;logFile = &quot;&quot;,
-	     const string &amp;rubyCommand = &quot;ruby&quot;,
-	     const string &amp;user = &quot;&quot;)
+	     const string &amp;rubyCommand = &quot;ruby&quot;)
 	   : data(new SharedData()),
 		cstat(DEFAULT_MAX_POOL_SIZE),
 		lock(data-&gt;lock),
@@ -621,7 +621,7 @@ public:
 		appInstanceCount(data-&gt;appInstanceCount)
 	{
 		TRACE_POINT();
-		this-&gt;spawnManager = ptr(new SpawnManager(spawnServerCommand, logFile, rubyCommand, user));
+		this-&gt;spawnManager = ptr(new SpawnManager(spawnServerCommand, generation, logFile, rubyCommand));
 		initialize();
 	}
 	</diff>
      <filename>ext/common/ApplicationPool/Pool.h</filename>
    </modified>
    <modified>
      <diff>@@ -45,6 +45,7 @@
 #include &lt;signal.h&gt;
 
 #include &quot;AbstractSpawnManager.h&quot;
+#include &quot;ServerInstanceDir.h&quot;
 #include &quot;MessageChannel.h&quot;
 #include &quot;Exceptions.h&quot;
 #include &quot;Logging.h&quot;
@@ -87,9 +88,9 @@ private:
 	static const int SPAWN_SERVER_INPUT_FD = 3;
 
 	string spawnServerCommand;
+	ServerInstanceDir::GenerationPtr generation;
 	string logFile;
 	string rubyCommand;
-	string user;
 	
 	boost::mutex lock;
 	
@@ -172,45 +173,10 @@ private:
 				close(i);
 			}
 			
-			if (!user.empty()) {
-				struct passwd *entry = getpwnam(user.c_str());
-				if (entry != NULL) {
-					if (initgroups(user.c_str(), entry-&gt;pw_gid) != 0) {
-						int e = errno;
-						fprintf(stderr, &quot;*** Passenger: cannot set supplementary &quot;
-							&quot;groups for user %s: %s (%d)\n&quot;,
-							user.c_str(),
-							strerror(e),
-							e);
-					}
-					if (setgid(entry-&gt;pw_gid) != 0) {
-						int e = errno;
-						fprintf(stderr, &quot;*** Passenger: cannot run spawn &quot;
-							&quot;manager as group %d: %s (%d)\n&quot;,
-							entry-&gt;pw_gid,
-							strerror(e),
-							e);
-					}
-					if (setuid(entry-&gt;pw_uid) != 0) {
-						int e = errno;
-						fprintf(stderr, &quot;*** Passenger: cannot run spawn &quot;
-							&quot;manager as user %s (%d): %s (%d)\n&quot;,
-							user.c_str(), entry-&gt;pw_uid,
-							strerror(e),
-							e);
-					}
-				} else {
-					fprintf(stderr, &quot;*** Passenger: cannot run spawn manager &quot;
-						&quot;as nonexistant user '%s'.\n&quot;,
-						user.c_str());
-				}
-				fflush(stderr);
-			}
-			
 			execlp(rubyCommand.c_str(),
 				rubyCommand.c_str(),
 				spawnServerCommand.c_str(),
-				getPassengerTempDir().c_str(),
+				generation-&gt;getPath().c_str(),
 				// The spawn server changes the process names of the subservers
 				// that it starts, for better usability. However, the process name length
 				// (as shown by ps) is limited. Here, we try to expand that limit by
@@ -424,6 +390,8 @@ public:
 	 * Construct a new SpawnManager.
 	 *
 	 * @param spawnServerCommand The filename of the spawn server to use.
+	 * @param generation The server instance dir generation in which
+	 *                   generation-specific are stored.
 	 * @param logFile Specify a log file that the spawn server should use.
 	 *            Messages on its standard output and standard error channels
 	 *            will be written to this log file. If an empty string is
@@ -431,23 +399,18 @@ public:
 	 *            will use the same standard output/error channels as the
 	 *            current process.
 	 * @param rubyCommand The Ruby interpreter's command.
-	 * @param user The user that the spawn manager should run as. This
-	 *             parameter only has effect if the current process is
-	 *             running as root. If the empty string is given, or if
-	 *             the &lt;tt&gt;user&lt;/tt&gt; is not a valid username, then
-	 *             the spawn manager will be run as the current user.
 	 * @throws SystemException An error occured while trying to setup the spawn server.
 	 * @throws IOException The specified log file could not be opened.
 	 */
 	SpawnManager(const string &amp;spawnServerCommand,
+	             const ServerInstanceDir::GenerationPtr &amp;generation,
 	             const string &amp;logFile = &quot;&quot;,
-	             const string &amp;rubyCommand = &quot;ruby&quot;,
-	             const string &amp;user = &quot;&quot;) {
+	             const string &amp;rubyCommand = &quot;ruby&quot;) {
 		TRACE_POINT();
 		this-&gt;spawnServerCommand = spawnServerCommand;
+		this-&gt;generation = generation;
 		this-&gt;logFile = logFile;
 		this-&gt;rubyCommand = rubyCommand;
-		this-&gt;user = user;
 		pid = 0;
 		this_thread::disable_interruption di;
 		this_thread::disable_syscall_interruption dsi;</diff>
      <filename>ext/common/SpawnManager.h</filename>
    </modified>
    <modified>
      <diff>@@ -385,143 +385,6 @@ getSystemTempDir() {
 	return temp_dir;
 }
 
-string
-getPassengerTempDir(bool bypassCache, const string &amp;parentDir) {
-	if (!bypassCache &amp;&amp; !passengerTempDir.empty()) {
-		return passengerTempDir;
-	} else {
-		string theParentDir;
-		char buffer[PATH_MAX];
-		
-		if (parentDir.empty()) {
-			theParentDir = getSystemTempDir();
-		} else {
-			theParentDir = parentDir;
-		}
-		snprintf(buffer, sizeof(buffer), &quot;%s/passenger.%lu&quot;,
-			theParentDir.c_str(), (unsigned long) getpid());
-		buffer[sizeof(buffer) - 1] = '\0';
-		passengerTempDir = buffer;
-		return passengerTempDir;
-	}
-}
-
-void
-setPassengerTempDir(const string &amp;dir) {
-	passengerTempDir = dir;
-}
-
-void
-createPassengerTempDir(const string &amp;parentDir, bool userSwitching,
-                       const string &amp;lowestUser, uid_t workerUid, gid_t workerGid) {
-	string tmpDir(getPassengerTempDir(false, parentDir));
-	uid_t lowestUid;
-	gid_t lowestGid;
-	string structureVersionFile;
-	int ret;
-	
-	determineLowestUserAndGroup(lowestUser, lowestUid, lowestGid);
-	
-	/* Create the temp directory with the current user as owner (which
-	 * is root if the web server was started as root). Only the owner
-	 * may write to this directory. Everybody else may only access the
-	 * directory. The permissions on the subdirectories will determine
-	 * whether a user may access that specific subdirectory.
-	 */
-	makeDirTree(tmpDir, &quot;u=wxs,g=x,o=x&quot;);
-	
-	/* Write structure version file. If you change the version here don't forget
-	 * to do it in lib/phusion_passenger/admin_tools/server_instance.rb too.
-	 *
-	 * Once written, nobody may write to it; only reading is possible.
-	 */
-	structureVersionFile = tmpDir + &quot;/structure_version.txt&quot;;
-	createFile(structureVersionFile, &quot;1.0&quot;, S_IRUSR | S_IRGRP | S_IROTH);
-	do {
-		// Try to make it root-owned, but don't care if it fails.
-		ret = chown(structureVersionFile.c_str(), 0, 0);
-	} while (ret == -1 &amp;&amp; errno == EINTR);
-	
-	/* We want this upload buffer directory to be only accessible by the web server's
-	 * worker processs.
-	 *
-	 * It only makes sense to chown webserver_private to workerUid and workerGid if the web server
-	 * is actually able to change the user of the worker processes. That is, if the web server
-	 * is running as root.
-	 */
-	if (geteuid() == 0) {
-		makeDirTree(tmpDir + &quot;/webserver_private&quot;, &quot;u=wxs,g=,o=&quot;, workerUid, workerGid);
-	} else {
-		makeDirTree(tmpDir + &quot;/webserver_private&quot;, &quot;u=wxs,g=,o=&quot;);
-	}
-	
-	/* If the web server is running as root (i.e. user switching is possible to begin with)
-	 * but user switching is off...
-	 */
-	if (geteuid() == 0 &amp;&amp; !userSwitching) {
-		/* ...then the 'info' subdirectory must be owned by lowestUser, so that only root
-		 * or lowestUser (which all backend processes are running as) can query
-		 * Phusion Passenger information.
-		 */
-		makeDirTree(tmpDir + &quot;/info&quot;, &quot;u=rwxs,g=,o=&quot;, lowestUid, lowestGid);
-	} else {
-		/* Otherwise just use the current user as the directory's owner.
-		 * This way, only the user that the web server's control process
-		 * is running as will be able to query information. We do this
-		 * because backend processes may be running as arbitrary users.
-		 */
-		makeDirTree(tmpDir + &quot;/info&quot;, &quot;u=rwxs,g=,o=&quot;);
-	}
-	
-	if (geteuid() == 0) {
-		if (userSwitching) {
-			/* When Apache is installed with mpm-itk, there may be multiple
-			 * users under which worker processes are running. To ensure that
-			 * all worker processes can connect to the server socket, we make
-			 * this subdirectory world-executable.
-			 */
-			makeDirTree(tmpDir + &quot;/master&quot;, &quot;u=wxs,g=x,o=x&quot;, workerUid, workerGid);
-		} else {
-			makeDirTree(tmpDir + &quot;/master&quot;, &quot;u=wxs,g=x,o=x&quot;, lowestUid, lowestGid);
-		}
-	} else {
-		makeDirTree(tmpDir + &quot;/master&quot;, &quot;u=wxs,g=,o=&quot;);
-	}
-	
-	if (geteuid() == 0) {
-		if (userSwitching) {
-			/* If user switching is possible and turned on, then each backend
-			 * process may be running as a different user, so the backends
-			 * subdirectory must be world-writable. However we don't want
-			 * everybody to be able to know the sockets' filenames, so
-			 * the directory is not readable, not even by its owner.
-			 */
-			makeDirTree(tmpDir + &quot;/backends&quot;, &quot;u=wxs,g=wx,o=wx&quot;);
-		} else {
-			/* If user switching is off then all backend processes will be
-			 * running as lowestUser, so make lowestUser the owner of the
-			 * directory. Nobody else (except root) may access this directory.
-			 *
-			 * The directory is not readable as a security precaution:
-			 * nobody should be able to know the sockets' filenames without
-			 * having access to the application pool.
-			 */
-			makeDirTree(tmpDir + &quot;/backends&quot;, &quot;u=wxs,g=,o=&quot;, lowestUid, lowestGid);
-		}
-	} else {
-		/* If user switching is not possible then all backend processes will
-		 * be running as the same user as the web server. So we'll make the
-		 * backends subdirectory only writable by this user. Nobody else
-		 * (except root) may access this subdirectory.
-		 *
-		 * The directory is not readable as a security precaution:
-		 * nobody should be able to know the sockets' filenames without having
-		 * access to the application pool.
-		 */
-		makeDirTree(tmpDir + &quot;/backends&quot;, &quot;u=wxs,g=,o=&quot;);
-	}
-}
-
 void
 makeDirTree(const string &amp;path, const char *mode, uid_t owner, gid_t group) {
 	char command[PATH_MAX + 10];</diff>
      <filename>ext/common/Utils.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -282,36 +282,6 @@ void determineLowestUserAndGroup(const string &amp;user, uid_t &amp;uid, gid_t &amp;gid);
  */
 const char *getSystemTempDir();
 
-/**
- * Return the path name for the directory in which Phusion Passenger-specific
- * temporary files are to be stored. This directory is unique for this instance
- * of the web server in which Phusion Passenger is running.
- *
- * The calculated value will be stored in an internal variable, so that subsequent
- * calls will return the same value. To bypass the usage of this internal variable,
- * set &lt;tt&gt;bypassCache&lt;/tt&gt; to true. In this case, the value of the internal
- * variable will be set to the newly calculated value.
- *
- * @param bypassCache Whether the value of the internal variable should be bypassed.
- * @param parentDir The directory under which the Phusion Passenger-specific
- *                  temp directory should be located. If set to the empty string,
- *                  then the return value of getSystemTempDir() will be used.
- *                  This argument only has effect if the value of the internal
- *                  variable is not consulted.
- * @ensure !result.empty()
- * @ingroup Support
- */
-string getPassengerTempDir(bool bypassCache = false, const string &amp;parentDir = &quot;&quot;);
-
-/**
- * Force subsequent calls to &lt;tt&gt;getPassengerTempDir(false, ...)&lt;/tt&gt; to return the given value.
- * &lt;tt&gt;dir&lt;/tt&gt; is not created automatically if it doesn't exist.
- *
- * &lt;tt&gt;dir&lt;/tt&gt; may also be an empty string, in which case it will cause the next
- * call to &lt;tt&gt;getPassengerTempDir()&lt;/tt&gt; to re-calculate the temp directory's path.
- */
-void setPassengerTempDir(const string &amp;dir);
-
 /* Create a temporary directory for storing Phusion Passenger instance-specific
  * temp files, such as temporarily buffered uploads, sockets for backend
  * processes, etc.
@@ -358,9 +328,9 @@ void setPassengerTempDir(const string &amp;dir);
  * @throws SystemException Something went wrong.
  * @throws FileSystemException Something went wrong.
  */
-void createPassengerTempDir(const string &amp;parentDir, bool userSwitching,
+/* void createPassengerTempDir(const string &amp;parentDir, bool userSwitching,
                             const string &amp;lowestUser,
-                            uid_t workerUid, gid_t workerGid);
+                            uid_t workerUid, gid_t workerGid); */
 
 /**
  * Create the directory at the given path, creating intermediate directories</diff>
      <filename>ext/common/Utils.h</filename>
    </modified>
    <modified>
      <diff>@@ -79,7 +79,14 @@ private
 			lower_privilege('passenger_wsgi.py', lowest_user)
 		end
 		
-		socket_file = &quot;#{passenger_tmpdir}/backends/wsgi_backend.#{Process.pid}.#{rand 10000000}&quot;
+		if defined?(NativeSupport)
+			unix_path_max = NativeSupport::UNIX_PATH_MAX
+		else
+			unix_path_max = 100
+		end
+		
+		socket_file = &quot;#{passenger_tmpdir}/backends/wsgi.#{Process.pid}.#{rand 10000000}&quot;
+		socket_file = socket_file.slice(0, unix_path_max - 1)
 		server = UNIXServer.new(socket_file)
 		begin
 			reader, writer = IO.pipe</diff>
      <filename>lib/phusion_passenger/wsgi/application_spawner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-#include &quot;tut.h&quot;
+#include &quot;../tut/tut.h&quot;
 #include &quot;counter.hpp&quot;
 #include &lt;oxt/backtrace.hpp&gt;
 #include &lt;oxt/tracable_exception.hpp&gt;</diff>
      <filename>test/oxt/backtrace_test.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-#include &quot;tut.h&quot;
+#include &quot;../tut/tut.h&quot;
 #include &quot;counter.hpp&quot;
 #include &lt;boost/bind.hpp&gt;
 #include &lt;boost/thread/thread_time.hpp&gt;</diff>
      <filename>test/oxt/dynamic_thread_group_test.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
-#include &quot;tut.h&quot;
-#include &quot;tut_reporter.h&quot;
+#include &quot;../tut/tut.h&quot;
+#include &quot;../tut/tut_reporter.h&quot;
 #include &lt;oxt/system_calls.hpp&gt;
 #include &lt;signal.h&gt;
 #include &lt;cstdlib&gt;</diff>
      <filename>test/oxt/oxt_test_main.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-#include &quot;tut.h&quot;
+#include &quot;../tut/tut.h&quot;
 #include &lt;boost/bind.hpp&gt;
 #include &lt;boost/thread.hpp&gt;
 #include &lt;oxt/spin_lock.hpp&gt;</diff>
      <filename>test/oxt/spin_lock_test.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-#include &quot;tut.h&quot;
+#include &quot;../tut/tut.h&quot;
 #include &lt;boost/bind.hpp&gt;
 #include &lt;oxt/thread.hpp&gt;
 #include &lt;oxt/system_calls.hpp&gt;</diff>
      <filename>test/oxt/syscall_interruption_test.cpp</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>ext/common/ApplicationPoolController.h</filename>
    </removed>
    <removed>
      <filename>ext/common/ApplicationPoolServerExecutable.cpp</filename>
    </removed>
    <removed>
      <filename>test/ApplicationPool_PoolTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/ApplicationPool_PoolTestCases.cpp</filename>
    </removed>
    <removed>
      <filename>test/ApplicationPool_ServerTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/ApplicationPool_Server_PoolTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/Base64Test.cpp</filename>
    </removed>
    <removed>
      <filename>test/CachedFileStatTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/CxxTestMain.cpp</filename>
    </removed>
    <removed>
      <filename>test/FileChangeCheckerTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/FileDescriptorTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/HttpStatusExtractorTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/MessageChannelTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/MessageServerTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/PoolOptionsTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/ScgiRequestParserTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/ServerInstanceDirTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/SpawnManagerTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/StaticStringTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/SystemTimeTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/UtilsTest.cpp</filename>
    </removed>
    <removed>
      <filename>test/support/Support.cpp</filename>
    </removed>
    <removed>
      <filename>test/support/Support.h</filename>
    </removed>
    <removed>
      <filename>test/support/tut.h</filename>
    </removed>
    <removed>
      <filename>test/support/tut_reporter.h</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>9d766c7847cfeb8a35deb3617cbf1c8e22220d0a</id>
    </parent>
  </parents>
  <author>
    <name>Hongli Lai (Phusion)</name>
    <email>hongli@phusion.nl</email>
  </author>
  <url>http://github.com/FooBarWidget/passenger/commit/195f00f3ef64000d9989072d3f7ea6f3aaaf3bc1</url>
  <id>195f00f3ef64000d9989072d3f7ea6f3aaaf3bc1</id>
  <committed-date>2009-09-13T07:20:59-07:00</committed-date>
  <authored-date>2009-09-13T07:20:59-07:00</authored-date>
  <message>Correctly propagate generation directory information to the spawn manager; refactor unit tests to better handle server instance directories; get rid of getPassengerTempDir() and createPassengerTempDir().</message>
  <tree>210b1fd6df622739a9cedaf24ed5d4b9c684a757</tree>
  <committer>
    <name>Hongli Lai (Phusion)</name>
    <email>hongli@phusion.nl</email>
  </committer>
</commit>
