passenger 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (244) hide show
  1. data/Rakefile +7 -5
  2. data/doc/Architectural overview.html +729 -1
  3. data/doc/Architectural overview.txt +0 -5
  4. data/doc/Security of user switching support.html +605 -1
  5. data/doc/Users guide.html +110 -106
  6. data/doc/Users guide.txt +49 -0
  7. data/doc/cxxapi/ApplicationPoolServer_8h-source.html +400 -372
  8. data/doc/cxxapi/ApplicationPool_8h-source.html +1 -1
  9. data/doc/cxxapi/Application_8h-source.html +1 -1
  10. data/doc/cxxapi/Bucket_8h-source.html +1 -1
  11. data/doc/cxxapi/CachedFileStat_8h-source.html +56 -65
  12. data/doc/cxxapi/Configuration_8h-source.html +40 -32
  13. data/doc/cxxapi/DirectoryMapper_8h-source.html +1 -1
  14. data/doc/cxxapi/DummySpawnManager_8h-source.html +1 -1
  15. data/doc/cxxapi/Exceptions_8h-source.html +1 -1
  16. data/doc/cxxapi/FileChecker_8h-source.html +29 -30
  17. data/doc/cxxapi/Hooks_8h-source.html +1 -1
  18. data/doc/cxxapi/Logging_8h-source.html +1 -1
  19. data/doc/cxxapi/MessageChannel_8h-source.html +1 -1
  20. data/doc/cxxapi/PoolOptions_8h-source.html +1 -1
  21. data/doc/cxxapi/SpawnManager_8h-source.html +225 -219
  22. data/doc/cxxapi/StandardApplicationPool_8h-source.html +451 -445
  23. data/doc/cxxapi/SystemTime_8h-source.html +1 -1
  24. data/doc/cxxapi/Utils_8h-source.html +201 -140
  25. data/doc/cxxapi/annotated.html +2 -2
  26. data/doc/cxxapi/classClient-members.html +1 -1
  27. data/doc/cxxapi/classClient.html +1 -1
  28. data/doc/cxxapi/classHooks-members.html +1 -1
  29. data/doc/cxxapi/classHooks.html +1 -1
  30. data/doc/cxxapi/classPassenger_1_1Application-members.html +1 -1
  31. data/doc/cxxapi/classPassenger_1_1Application.html +1 -1
  32. data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +1 -1
  33. data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +1 -1
  34. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +1 -1
  35. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +1 -1
  36. data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.png +0 -0
  37. data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +1 -1
  38. data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +1 -1
  39. data/doc/cxxapi/{classPassenger_1_1TempFile-members.html → classPassenger_1_1BufferedUpload-members.html} +5 -5
  40. data/doc/cxxapi/{classPassenger_1_1TempFile.html → classPassenger_1_1BufferedUpload.html} +33 -43
  41. data/doc/cxxapi/classPassenger_1_1BusyException-members.html +1 -1
  42. data/doc/cxxapi/classPassenger_1_1BusyException.html +1 -1
  43. data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +1 -1
  44. data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +1 -1
  45. data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +1 -1
  46. data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +1 -1
  47. data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +1 -1
  48. data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +1 -1
  49. data/doc/cxxapi/classPassenger_1_1FileChecker-members.html +1 -1
  50. data/doc/cxxapi/classPassenger_1_1FileChecker.html +2 -2
  51. data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +1 -1
  52. data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +1 -1
  53. data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.png +0 -0
  54. data/doc/cxxapi/classPassenger_1_1FileSystemException-members.html +1 -1
  55. data/doc/cxxapi/classPassenger_1_1FileSystemException.html +1 -1
  56. data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.png +0 -0
  57. data/doc/cxxapi/classPassenger_1_1IOException-members.html +1 -1
  58. data/doc/cxxapi/classPassenger_1_1IOException.html +1 -1
  59. data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.png +0 -0
  60. data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +1 -1
  61. data/doc/cxxapi/classPassenger_1_1MessageChannel.html +1 -1
  62. data/doc/cxxapi/classPassenger_1_1RuntimeException-members.html +1 -1
  63. data/doc/cxxapi/classPassenger_1_1RuntimeException.html +1 -1
  64. data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +1 -1
  65. data/doc/cxxapi/classPassenger_1_1SpawnException.html +1 -1
  66. data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +1 -1
  67. data/doc/cxxapi/classPassenger_1_1SpawnManager.html +1 -1
  68. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +1 -1
  69. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +1 -1
  70. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.png +0 -0
  71. data/doc/cxxapi/classPassenger_1_1SystemException-members.html +1 -1
  72. data/doc/cxxapi/classPassenger_1_1SystemException.html +1 -1
  73. data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.png +0 -0
  74. data/doc/cxxapi/classPassenger_1_1SystemTime-members.html +1 -1
  75. data/doc/cxxapi/classPassenger_1_1SystemTime.html +1 -1
  76. data/doc/cxxapi/definitions_8h-source.html +1 -1
  77. data/doc/cxxapi/files.html +1 -1
  78. data/doc/cxxapi/functions.html +12 -11
  79. data/doc/cxxapi/functions_func.html +9 -7
  80. data/doc/cxxapi/functions_type.html +1 -1
  81. data/doc/cxxapi/functions_vars.html +2 -4
  82. data/doc/cxxapi/graph_legend.html +1 -1
  83. data/doc/cxxapi/graph_legend.png +0 -0
  84. data/doc/cxxapi/group__Configuration.html +3 -3
  85. data/doc/cxxapi/group__Configuration.png +0 -0
  86. data/doc/cxxapi/group__Core.html +1 -1
  87. data/doc/cxxapi/group__Core.png +0 -0
  88. data/doc/cxxapi/group__Exceptions.html +1 -1
  89. data/doc/cxxapi/group__Hooks.html +1 -1
  90. data/doc/cxxapi/group__Hooks.png +0 -0
  91. data/doc/cxxapi/group__Support.html +33 -16
  92. data/doc/cxxapi/hierarchy.html +2 -2
  93. data/doc/cxxapi/inherit__graph__0.png +0 -0
  94. data/doc/cxxapi/inherit__graph__1.png +0 -0
  95. data/doc/cxxapi/inherit__graph__10.map +1 -1
  96. data/doc/cxxapi/inherit__graph__10.md5 +1 -1
  97. data/doc/cxxapi/inherit__graph__10.png +0 -0
  98. data/doc/cxxapi/inherit__graph__11.map +1 -1
  99. data/doc/cxxapi/inherit__graph__11.md5 +1 -1
  100. data/doc/cxxapi/inherit__graph__11.png +0 -0
  101. data/doc/cxxapi/inherit__graph__12.map +1 -2
  102. data/doc/cxxapi/inherit__graph__12.md5 +1 -1
  103. data/doc/cxxapi/inherit__graph__12.png +0 -0
  104. data/doc/cxxapi/inherit__graph__13.map +2 -1
  105. data/doc/cxxapi/inherit__graph__13.md5 +1 -1
  106. data/doc/cxxapi/inherit__graph__13.png +0 -0
  107. data/doc/cxxapi/inherit__graph__14.map +1 -1
  108. data/doc/cxxapi/inherit__graph__14.md5 +1 -1
  109. data/doc/cxxapi/inherit__graph__14.png +0 -0
  110. data/doc/cxxapi/inherit__graph__15.map +1 -1
  111. data/doc/cxxapi/inherit__graph__15.md5 +1 -1
  112. data/doc/cxxapi/inherit__graph__15.png +0 -0
  113. data/doc/cxxapi/inherit__graph__16.map +1 -1
  114. data/doc/cxxapi/inherit__graph__16.md5 +1 -1
  115. data/doc/cxxapi/inherit__graph__16.png +0 -0
  116. data/doc/cxxapi/inherit__graph__17.map +1 -1
  117. data/doc/cxxapi/inherit__graph__17.md5 +1 -1
  118. data/doc/cxxapi/inherit__graph__17.png +0 -0
  119. data/doc/cxxapi/inherit__graph__18.map +1 -1
  120. data/doc/cxxapi/inherit__graph__18.md5 +1 -1
  121. data/doc/cxxapi/inherit__graph__18.png +0 -0
  122. data/doc/cxxapi/inherit__graph__19.map +1 -2
  123. data/doc/cxxapi/inherit__graph__19.md5 +1 -1
  124. data/doc/cxxapi/inherit__graph__19.png +0 -0
  125. data/doc/cxxapi/inherit__graph__2.png +0 -0
  126. data/doc/cxxapi/inherit__graph__20.map +2 -1
  127. data/doc/cxxapi/inherit__graph__20.md5 +1 -1
  128. data/doc/cxxapi/inherit__graph__20.png +0 -0
  129. data/doc/cxxapi/inherit__graph__21.map +1 -1
  130. data/doc/cxxapi/inherit__graph__21.md5 +1 -1
  131. data/doc/cxxapi/inherit__graph__21.png +0 -0
  132. data/doc/cxxapi/inherit__graph__3.png +0 -0
  133. data/doc/cxxapi/inherit__graph__4.png +0 -0
  134. data/doc/cxxapi/inherit__graph__5.png +0 -0
  135. data/doc/cxxapi/inherit__graph__6.png +0 -0
  136. data/doc/cxxapi/inherit__graph__7.map +1 -1
  137. data/doc/cxxapi/inherit__graph__7.md5 +1 -1
  138. data/doc/cxxapi/inherit__graph__7.png +0 -0
  139. data/doc/cxxapi/inherit__graph__8.map +1 -1
  140. data/doc/cxxapi/inherit__graph__8.md5 +1 -1
  141. data/doc/cxxapi/inherit__graph__8.png +0 -0
  142. data/doc/cxxapi/inherit__graph__9.map +1 -1
  143. data/doc/cxxapi/inherit__graph__9.md5 +1 -1
  144. data/doc/cxxapi/inherit__graph__9.png +0 -0
  145. data/doc/cxxapi/inherits.html +18 -18
  146. data/doc/cxxapi/main.html +1 -1
  147. data/doc/cxxapi/modules.html +1 -1
  148. data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +1 -1
  149. data/doc/cxxapi/structPassenger_1_1AnythingToString.html +1 -1
  150. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +1 -1
  151. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +1 -1
  152. data/doc/cxxapi/structPassenger_1_1PoolOptions-members.html +1 -1
  153. data/doc/cxxapi/structPassenger_1_1PoolOptions.html +1 -1
  154. data/doc/cxxapi/tree.html +4 -4
  155. data/doc/rdoc/classes/ConditionVariable.html +58 -58
  156. data/doc/rdoc/classes/Exception.html +11 -11
  157. data/doc/rdoc/classes/GC.html +4 -4
  158. data/doc/rdoc/classes/IO.html +14 -14
  159. data/doc/rdoc/classes/PhusionPassenger.html +11 -11
  160. data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +1 -1
  161. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +40 -39
  162. data/doc/rdoc/classes/PhusionPassenger/Application.html +14 -14
  163. data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +12 -12
  164. data/doc/rdoc/classes/PhusionPassenger/Railz.html +1 -1
  165. data/doc/rdoc/classes/PhusionPassenger/Utils.html +15 -8
  166. data/doc/rdoc/classes/PlatformInfo.html +257 -253
  167. data/doc/rdoc/classes/RakeExtensions.html +2 -2
  168. data/doc/rdoc/classes/Signal.html +26 -26
  169. data/doc/rdoc/created.rid +1 -1
  170. data/doc/rdoc/files/DEVELOPERS_TXT.html +1 -1
  171. data/doc/rdoc/files/README.html +1 -1
  172. data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +1 -1
  173. data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +1 -1
  174. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +1 -1
  175. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +1 -1
  176. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +1 -1
  177. data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +1 -1
  178. data/doc/rdoc/files/lib/phusion_passenger/application_rb.html +1 -1
  179. data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +1 -1
  180. data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +1 -1
  181. data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +1 -1
  182. data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +1 -1
  183. data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +1 -1
  184. data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +1 -1
  185. data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +1 -1
  186. data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +1 -1
  187. data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +1 -1
  188. data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +1 -1
  189. data/doc/rdoc/files/lib/phusion_passenger/railz/application_spawner_rb.html +1 -1
  190. data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +1 -1
  191. data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +1 -1
  192. data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +1 -1
  193. data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +1 -1
  194. data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +1 -1
  195. data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +9 -9
  196. data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +1 -1
  197. data/doc/rdoc/files/{lib → misc}/rake/extensions_rb.html +2 -2
  198. data/doc/rdoc/fr_file_index.html +1 -1
  199. data/doc/rdoc/fr_method_index.html +22 -22
  200. data/ext/apache2/ApplicationPoolServer.h +43 -15
  201. data/ext/apache2/ApplicationPoolServerExecutable.cpp +27 -52
  202. data/ext/apache2/CachedFileStat.h +7 -16
  203. data/ext/apache2/Configuration.h +9 -1
  204. data/ext/apache2/FileChecker.h +4 -5
  205. data/ext/apache2/Hooks.cpp +20 -22
  206. data/ext/apache2/SpawnManager.h +6 -0
  207. data/ext/apache2/StandardApplicationPool.h +6 -0
  208. data/ext/apache2/Utils.cpp +174 -16
  209. data/ext/apache2/Utils.h +99 -38
  210. data/ext/boost/cstdint.hpp +2 -1
  211. data/ext/oxt/system_calls.cpp +20 -2
  212. data/ext/oxt/system_calls.hpp +2 -0
  213. data/lib/phusion_passenger/abstract_request_handler.rb +5 -1
  214. data/lib/phusion_passenger/admin_tools.rb +1 -1
  215. data/lib/phusion_passenger/admin_tools/control_process.rb +2 -1
  216. data/lib/phusion_passenger/dependencies.rb +7 -4
  217. data/lib/phusion_passenger/platform_info.rb +8 -2
  218. data/lib/phusion_passenger/rack/application_spawner.rb +1 -1
  219. data/lib/phusion_passenger/templates/version_not_found.html.erb +9 -0
  220. data/lib/phusion_passenger/utils.rb +13 -6
  221. data/lib/phusion_passenger/wsgi/application_spawner.rb +1 -1
  222. data/{lib → misc}/rake/cplusplus.rb +0 -0
  223. data/{lib → misc}/rake/extensions.rb +0 -0
  224. data/{lib → misc}/rake/gempackagetask.rb +0 -0
  225. data/{lib → misc}/rake/packagetask.rb +0 -0
  226. data/{lib → misc}/rake/rdoctask.rb +0 -0
  227. data/misc/render_error_pages.rb +6 -5
  228. data/test/CxxTestMain.cpp +109 -7
  229. data/test/UtilsTest.cpp +61 -51
  230. data/test/config.yml.example +6 -2
  231. data/test/integration_tests.rb +4 -0
  232. data/test/ruby/abstract_request_handler_spec.rb +9 -3
  233. data/test/ruby/rack/application_spawner_spec.rb +3 -2
  234. data/test/ruby/rails/application_spawner_spec.rb +15 -4
  235. data/test/ruby/rails/framework_spawner_spec.rb +4 -2
  236. data/test/ruby/rails/spawner_error_handling_spec.rb +4 -4
  237. data/test/ruby/spawn_manager_spec.rb +22 -9
  238. data/test/ruby/utils_spec.rb +18 -12
  239. data/test/ruby/wsgi/application_spawner_spec.rb +16 -7
  240. data/test/stub/apache2/httpd.conf.erb +1 -0
  241. data/test/stub/wsgi/passenger_wsgi.pyc +0 -0
  242. metadata +1064 -1090
  243. data/doc/Users guide Apache.html +0 -3127
  244. data/doc/Users guide Nginx.html +0 -1458
@@ -72,7 +72,7 @@ private
72
72
  lower_privilege('passenger_wsgi.py', lowest_user)
73
73
  end
74
74
 
75
- socket_file = "#{passenger_tmpdir}/passenger_wsgi.#{Process.pid}.#{rand 10000000}"
75
+ socket_file = "#{passenger_tmpdir}/backends/wsgi_backend.#{Process.pid}.#{rand 10000000}"
76
76
  server = UNIXServer.new(socket_file)
77
77
  begin
78
78
  reader, writer = IO.pipe
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -15,10 +15,11 @@
15
15
  # with this program; if not, write to the Free Software Foundation, Inc.,
16
16
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
17
 
18
- $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
19
- require 'passenger/html_template'
20
- require 'passenger/spawn_manager'
21
- require 'passenger/platform_info'
18
+ $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib")
19
+ $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../ext")
20
+ require 'phusion_passenger/html_template'
21
+ require 'phusion_passenger/spawn_manager'
22
+ require 'phusion_passenger/platform_info'
22
23
  include PhusionPassenger
23
24
 
24
25
  if !defined?(Mysql::Error)
@@ -101,7 +102,7 @@ def start
101
102
  render_error_page(e, 'general_error.html',
102
103
  'general_error')
103
104
 
104
- e = StandardError.new("Some error message")
105
+ e = AppInitError.new("Some error message", create_dummy_exception)
105
106
  render_error_page(e, 'app_exited.html', 'app_exited_during_initialization')
106
107
  end
107
108
 
@@ -1,25 +1,127 @@
1
1
  #include "tut.h"
2
2
  #include "tut_reporter.h"
3
+ #include <string>
3
4
  #include <apr_general.h>
4
5
  #include <signal.h>
6
+ #include <cstdio>
5
7
  #include <cstdlib>
6
8
 
9
+ #include "Utils.h"
10
+
11
+ using namespace std;
12
+
7
13
  namespace tut {
8
14
  test_runner_singleton runner;
9
15
  }
10
16
 
11
- int main() {
17
+ typedef tut::groupnames::const_iterator groupnames_iterator;
18
+
19
+ /** All available groups. */
20
+ static tut::groupnames allGroups;
21
+
22
+ /** Whether the user wants to run all test groups, or only the specified test groups. */
23
+ static enum { RUN_ALL_GROUPS, RUN_SPECIFIED_GROUPS } runMode = RUN_ALL_GROUPS;
24
+
25
+ /** The test groups the user wants to run. Only meaningful if runMode == RUN_SPECIFIED_GROUPS. */
26
+ static tut::groupnames groupsToRun;
27
+
28
+
29
+ static void
30
+ usage(int exitCode) {
31
+ printf("Usage: ./Apache2ModuleTests [options]\n");
32
+ printf("Runs the unit tests for the Apache 2 module.\n\n");
33
+ printf("Options:\n");
34
+ printf(" -g GROUP_NAME Instead of running all unit tests, only run the test group\n");
35
+ printf(" named GROUP_NAME. You can specify -g multiple times, which\n");
36
+ printf(" will result in only the specified test groups being run.\n\n");
37
+ printf(" Available test groups:\n\n");
38
+ for (groupnames_iterator it = allGroups.begin(); it != allGroups.end(); it++) {
39
+ printf(" %s\n", it->c_str());
40
+ }
41
+ printf("\n");
42
+ printf(" -h Print this usage information.\n");
43
+ exit(exitCode);
44
+ }
45
+
46
+ static bool
47
+ groupExists(const string &name) {
48
+ for (groupnames_iterator it = allGroups.begin(); it != allGroups.end(); it++) {
49
+ if (name == *it) {
50
+ return true;
51
+ }
52
+ }
53
+ return false;
54
+ }
55
+
56
+ static void
57
+ parseOptions(int argc, char *argv[]) {
58
+ for (int i = 1; i < argc; i++) {
59
+ if (strcmp(argv[i], "-h") == 0) {
60
+ usage(0);
61
+ } else if (strcmp(argv[i], "-g") == 0) {
62
+ if (argv[i + 1] == NULL) {
63
+ fprintf(stderr, "*** ERROR: A -g option must be followed by a test group name.\n");
64
+ exit(1);
65
+ } else if (!groupExists(argv[i + 1])) {
66
+ fprintf(stderr,
67
+ "*** ERROR: Invalid test group '%s'. Available test groups are:\n\n",
68
+ argv[i + 1]);
69
+ for (groupnames_iterator it = allGroups.begin(); it != allGroups.end(); it++) {
70
+ printf("%s\n", it->c_str());
71
+ }
72
+ exit(1);
73
+ } else {
74
+ runMode = RUN_SPECIFIED_GROUPS;
75
+ groupsToRun.push_back(argv[i + 1]);
76
+ i++;
77
+ }
78
+ } else {
79
+ fprintf(stderr, "*** ERROR: Unknown option: %s\n", argv[i]);
80
+ fprintf(stderr, "Please pass -h for a list of valid options.\n");
81
+ exit(1);
82
+ }
83
+ }
84
+ }
85
+
86
+ struct Finalizer {
87
+ ~Finalizer() {
88
+ Passenger::removeDirTree(Passenger::getPassengerTempDir());
89
+ }
90
+ };
91
+
92
+ int
93
+ main(int argc, char *argv[]) {
12
94
  apr_initialize();
13
- tut::reporter reporter;
14
- tut::runner.get().set_callback(&reporter);
15
95
  signal(SIGPIPE, SIG_IGN);
16
96
  setenv("RAILS_ENV", "production", 1);
17
97
  setenv("TESTING_PASSENGER", "1", 1);
98
+
99
+ tut::reporter reporter;
100
+ tut::runner.get().set_callback(&reporter);
101
+ allGroups = tut::runner.get().list_groups();
102
+ parseOptions(argc, argv);
103
+
104
+ Finalizer finalizer;
105
+
18
106
  try {
19
- tut::runner.get().run_tests();
107
+ bool all_ok = true;
108
+ if (runMode == RUN_ALL_GROUPS) {
109
+ tut::runner.get().run_tests();
110
+ all_ok = reporter.all_ok();
111
+ } else {
112
+ all_ok = true;
113
+ for (groupnames_iterator it = groupsToRun.begin(); it != groupsToRun.end(); it++) {
114
+ tut::runner.get().run_tests(*it);
115
+ all_ok = all_ok && reporter.all_ok();
116
+ }
117
+ }
118
+ if (all_ok) {
119
+ return 0;
120
+ } else {
121
+ return 1;
122
+ }
20
123
  } catch (const std::exception &ex) {
21
- std::cerr << "Exception raised: " << ex.what() << std::endl;
22
- return 1;
124
+ cerr << "*** Exception raised: " << ex.what() << endl;
125
+ return 2;
23
126
  }
24
- return 0;
25
127
  }
@@ -6,6 +6,7 @@
6
6
  #include <dirent.h>
7
7
  #include <unistd.h>
8
8
  #include <limits.h>
9
+ #include <string.h>
9
10
 
10
11
  using namespace Passenger;
11
12
  using namespace std;
@@ -14,17 +15,28 @@ namespace tut {
14
15
  struct UtilsTest {
15
16
  vector<string> output;
16
17
  string oldPath;
18
+ char *oldInstanceTempDir;
17
19
 
18
20
  UtilsTest() {
19
21
  oldPath = getenv("PATH");
22
+ oldInstanceTempDir = getenv("PASSENGER_INSTANCE_TEMP_DIR");
23
+ if (oldInstanceTempDir != NULL) {
24
+ oldInstanceTempDir = strdup(oldInstanceTempDir);
25
+ }
26
+
20
27
  unsetenv("TMPDIR");
21
- unsetenv("PHUSION_PASSENGER_TMP");
28
+ unsetenv("PASSENGER_INSTANCE_TEMP_DIR");
22
29
  }
23
30
 
24
31
  ~UtilsTest() {
25
32
  setenv("PATH", oldPath.c_str(), 1);
26
33
  unsetenv("TMPDIR");
27
- unsetenv("PHUSION_PASSENGER_TMP");
34
+ if (oldInstanceTempDir == NULL) {
35
+ unsetenv("PASSENGER_INSTANCE_TEMP_DIR");
36
+ } else {
37
+ setenv("PASSENGER_INSTANCE_TEMP_DIR", oldInstanceTempDir, 1);
38
+ free(oldInstanceTempDir);
39
+ }
28
40
  }
29
41
  };
30
42
 
@@ -123,23 +135,23 @@ namespace tut {
123
135
  }
124
136
 
125
137
 
126
- /***** Test getTempDir() *****/
138
+ /***** Test getSystemTempDir() *****/
127
139
 
128
140
  TEST_METHOD(11) {
129
141
  // It returns "/tmp" if the TMPDIR environment is NULL.
130
- ensure_equals(string(getTempDir()), "/tmp");
142
+ ensure_equals(string(getSystemTempDir()), "/tmp");
131
143
  }
132
144
 
133
145
  TEST_METHOD(12) {
134
146
  // It returns "/tmp" if the TMPDIR environment is an empty string.
135
147
  setenv("TMPDIR", "", 1);
136
- ensure_equals(string(getTempDir()), "/tmp");
148
+ ensure_equals(string(getSystemTempDir()), "/tmp");
137
149
  }
138
150
 
139
151
  TEST_METHOD(13) {
140
152
  // It returns the value of the TMPDIR environment if it is not NULL and not empty.
141
153
  setenv("TMPDIR", "/foo", 1);
142
- ensure_equals(string(getTempDir()), "/foo");
154
+ ensure_equals(string(getSystemTempDir()), "/foo");
143
155
  }
144
156
 
145
157
 
@@ -154,74 +166,72 @@ namespace tut {
154
166
  }
155
167
 
156
168
  TEST_METHOD(16) {
157
- // It caches the result into the PHUSION_PASSENGER_TMP environment variable.
169
+ // It caches the result into the PASSENGER_INSTANCE_TEMP_DIR environment variable.
158
170
  char dir[128];
159
171
 
160
172
  snprintf(dir, sizeof(dir), "/tmp/passenger.%lu", (unsigned long) getpid());
161
173
  getPassengerTempDir();
162
- ensure_equals(getenv("PHUSION_PASSENGER_TMP"), string(dir));
174
+ ensure_equals(getenv("PASSENGER_INSTANCE_TEMP_DIR"), string(dir));
163
175
  }
164
176
 
165
177
  TEST_METHOD(17) {
166
- // It returns the value of the PHUSION_PASSENGER_TMP environment variable if it's not NULL and not an empty string.
167
- setenv("PHUSION_PASSENGER_TMP", "/foo", 1);
178
+ // It returns the value of the PASSENGER_INSTANCE_TEMP_DIR environment
179
+ // variable if it's not NULL and not an empty string.
180
+ setenv("PASSENGER_INSTANCE_TEMP_DIR", "/foo", 1);
168
181
  ensure_equals(getPassengerTempDir(), "/foo");
169
182
  }
170
183
 
171
184
  TEST_METHOD(18) {
172
- // It does not use query the PHUSION_PASSENGER_TMP environment variable if bypassCache is true.
185
+ // It does not use query the PASSENGER_INSTANCE_TEMP_DIR environment variable if bypassCache is true.
173
186
  char dir[128];
174
187
 
175
- setenv("PHUSION_PASSENGER_TMP", "/foo", 1);
188
+ setenv("PASSENGER_INSTANCE_TEMP_DIR", "/foo", 1);
176
189
  snprintf(dir, sizeof(dir), "/tmp/passenger.%lu", (unsigned long) getpid());
177
190
  ensure_equals(getPassengerTempDir(true), dir);
178
191
  }
179
192
 
193
+ TEST_METHOD(19) {
194
+ // It uses the systemTempDir argument if it's not the empty string.
195
+ char dir[128];
196
+
197
+ snprintf(dir, sizeof(dir), "/foo/passenger.%lu", (unsigned long) getpid());
198
+ ensure_equals(getPassengerTempDir(false, "/foo"), dir);
199
+ }
200
+
201
+
202
+ /***** Test BufferedUpload *****/
180
203
 
181
- /***** Test TempFile *****/
204
+ struct TemporarilySetInstanceTempDir {
205
+ TemporarilySetInstanceTempDir() {
206
+ setenv("PASSENGER_INSTANCE_TEMP_DIR", "utils_test.tmp", 1);
207
+ mkdir("utils_test.tmp", S_IRWXU);
208
+ mkdir(BufferedUpload::getDir().c_str(), S_IRWXU);
209
+ }
210
+
211
+ ~TemporarilySetInstanceTempDir() {
212
+ removeDirTree("utils_test.tmp");
213
+ }
214
+ };
182
215
 
183
216
  TEST_METHOD(20) {
184
- // It creates a temp file inside getPassengerTempDir().
185
- setenv("PHUSION_PASSENGER_TMP", "utils_test.tmp", 1);
186
- mkdir("utils_test.tmp", S_IRWXU);
187
- TempFile t("temp", false);
188
- unsigned int size = listDir("utils_test.tmp").size();
189
- removeDirTree("utils_test.tmp");
190
- ensure_equals(size, 1u);
217
+ // The resulting file handle is readable and writable.
218
+ TemporarilySetInstanceTempDir d;
219
+ BufferedUpload t;
220
+ char line[30];
221
+
222
+ fprintf(t.handle, "hello world!");
223
+ fflush(t.handle);
224
+ fseek(t.handle, 0, SEEK_SET);
225
+ memset(line, 0, sizeof(line));
226
+ fgets(line, sizeof(line), t.handle);
227
+ ensure_equals(string(line), "hello world!");
191
228
  }
192
229
 
193
230
  TEST_METHOD(21) {
194
- // It deletes the temp file upon destruction.
195
- setenv("PHUSION_PASSENGER_TMP", "utils_test.tmp", 1);
196
- mkdir("utils_test.tmp", S_IRWXU);
197
- {
198
- TempFile t("temp", false);
199
- }
200
- bool dirEmpty = listDir("utils_test.tmp").empty();
201
- removeDirTree("utils_test.tmp");
202
- ensure(dirEmpty);
203
- }
204
-
205
- TEST_METHOD(22) {
206
- // The temp file's filename is constructed using the given identifier.
207
- setenv("PHUSION_PASSENGER_TMP", "utils_test.tmp", 1);
208
- mkdir("utils_test.tmp", S_IRWXU);
209
- TempFile t("foobar", false);
210
- vector<string> files(listDir("utils_test.tmp"));
211
- removeDirTree("utils_test.tmp");
212
-
213
- ensure(files[0].find("foobar") != string::npos);
214
- }
215
-
216
- TEST_METHOD(23) {
217
- // It immediately unlinks the temp file if 'anonymous' is true.
218
- // It creates a temp file inside getPassengerTempDir().
219
- setenv("PHUSION_PASSENGER_TMP", "utils_test.tmp", 1);
220
- mkdir("utils_test.tmp", S_IRWXU);
221
- TempFile t;
222
- unsigned int size = listDir("utils_test.tmp").size();
223
- removeDirTree("utils_test.tmp");
224
- ensure_equals(size, 0u);
231
+ // It immediately unlinks the temp file.
232
+ TemporarilySetInstanceTempDir d;
233
+ BufferedUpload t;
234
+ ensure_equals(listDir(BufferedUpload::getDir().c_str()).size(), 0u);
225
235
  }
226
236
 
227
237
  /***** Test escapeForXml() *****/
@@ -10,8 +10,12 @@ normal_user_1: games
10
10
  normal_user_2: daemon
11
11
 
12
12
  # The username of a user that has less privileges than a normal user.
13
- # NOTE: this user MUST be able to access this 'test' directory, otherwise
14
- # the tests will fail.
13
+ #
14
+ # NOTES:
15
+ # - this user MUST be able to access this 'test' directory, otherwise
16
+ # the tests will fail.
17
+ # - this user MUST NOT have a negative UID value. So on OS X, this may
18
+ # not be the 'nobody' user.
15
19
  lowest_user: nobody
16
20
 
17
21
  # A nonexistant username.
@@ -188,6 +188,7 @@ shared_examples_for "HelloWorld Rack application" do
188
188
  run app
189
189
  })
190
190
  File.new("#{@stub.app_root}/tmp/restart.txt", "w").close
191
+ File.utime(2, 2, "#{@stub.app_root}/tmp/restart.txt")
191
192
  get('/').should == "changed"
192
193
  end
193
194
 
@@ -197,6 +198,7 @@ shared_examples_for "HelloWorld Rack application" do
197
198
  File.new('foo.txt', 'w').close
198
199
  })
199
200
  File.new("#{@stub.app_root}/tmp/restart.txt", "w").close
201
+ File.utime(1, 1, "#{@stub.app_root}/tmp/restart.txt")
200
202
  get('/')
201
203
  stat = File.stat("#{@stub.app_root}/foo.txt")
202
204
  stat.uid.should_not == 0
@@ -229,6 +231,7 @@ shared_examples_for "HelloWorld WSGI application" do
229
231
 
230
232
  File.write("#{@stub.app_root}/passenger_wsgi.py", code)
231
233
  File.new("#{@stub.app_root}/tmp/restart.txt", "w").close
234
+ File.utime(2, 2, "#{@stub.app_root}/tmp/restart.txt")
232
235
  get('/').should == "changed"
233
236
  end
234
237
 
@@ -237,6 +240,7 @@ shared_examples_for "HelloWorld WSGI application" do
237
240
  File.prepend("#{@stub.app_root}/passenger_wsgi.py",
238
241
  "file('foo.txt', 'w').close()\n")
239
242
  File.new("#{@stub.app_root}/tmp/restart.txt", "w").close
243
+ File.utime(1, 1, "#{@stub.app_root}/tmp/restart.txt")
240
244
  get('/')
241
245
  stat = File.stat("#{@stub.app_root}/foo.txt")
242
246
  stat.uid.should_not == 0
@@ -8,7 +8,8 @@ include PhusionPassenger
8
8
 
9
9
  describe AbstractRequestHandler do
10
10
  before :each do
11
- ENV['PHUSION_PASSENGER_TMP'] = "abstract_request_handler_spec.tmp"
11
+ @old_instance_temp_dir = ENV['PASSENGER_INSTANCE_TEMP_DIR']
12
+ ENV['PASSENGER_INSTANCE_TEMP_DIR'] = "abstract_request_handler_spec.tmp"
12
13
  @owner_pipe = IO.pipe
13
14
  @request_handler = AbstractRequestHandler.new(@owner_pipe[1])
14
15
  def @request_handler.process_request(*args)
@@ -19,7 +20,11 @@ describe AbstractRequestHandler do
19
20
  after :each do
20
21
  @request_handler.cleanup
21
22
  @owner_pipe[0].close rescue nil
22
- ENV.delete('PHUSION_PASSENGER_TMP')
23
+ if @old_instance_temp_dir
24
+ ENV['PASSENGER_INSTANCE_TEMP_DIR'] = @old_instance_temp_dir
25
+ else
26
+ ENV.delete('PASSENGER_INSTANCE_TEMP_DIR')
27
+ end
23
28
  FileUtils.rm_rf("abstract_request_handler_spec.tmp")
24
29
  end
25
30
 
@@ -54,7 +59,8 @@ describe AbstractRequestHandler do
54
59
 
55
60
  it "creates a socket file in the Phusion Passenger temp folder, unless when using TCP sockets" do
56
61
  if @request_handler.socket_type == "unix"
57
- Dir["abstract_request_handler_spec.tmp/*"].should_not be_empty
62
+ File.chmod(0700, "abstract_request_handler_spec.tmp/backends")
63
+ Dir["abstract_request_handler_spec.tmp/backends/*"].should_not be_empty
58
64
  end
59
65
  end
60
66
 
@@ -34,8 +34,9 @@ describe PhusionPassenger::Rack::ApplicationSpawner do
34
34
  config_ru_owner.should == touch_txt_owner
35
35
  end if Process.euid == 0
36
36
 
37
- def spawn(*args)
38
- PhusionPassenger::Rack::ApplicationSpawner.spawn_application(*args)
37
+ def spawn(app_root)
38
+ PhusionPassenger::Rack::ApplicationSpawner.spawn_application(app_root,
39
+ "lowest_user" => CONFIG['lowest_user'])
39
40
  end
40
41
  end
41
42