passenger 5.0.4 → 5.0.5

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 (550) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/.editorconfig +10 -0
  5. data/CHANGELOG +21 -0
  6. data/build/agents.rb +2 -2
  7. data/build/apache2.rb +6 -5
  8. data/build/common_library.rb +22 -7
  9. data/build/cxx_tests.rb +0 -3
  10. data/build/misc.rb +1 -1
  11. data/dev/parse_file_descriptor_log +119 -0
  12. data/doc/CloudLicensingConfiguration.html +387 -0
  13. data/doc/Design and Architecture.html +2430 -0
  14. data/doc/Packaging.html +488 -0
  15. data/doc/Security of user switching support.html +1833 -0
  16. data/doc/ServerOptimizationGuide.html +659 -0
  17. data/doc/ServerOptimizationGuide.txt.md +8 -0
  18. data/doc/Users guide Apache.html +9116 -0
  19. data/doc/Users guide Apache.idmap.txt +6 -2
  20. data/doc/Users guide Apache.txt +26 -7
  21. data/doc/Users guide Nginx.html +9025 -0
  22. data/doc/Users guide Nginx.idmap.txt +7 -3
  23. data/doc/Users guide Nginx.txt +29 -6
  24. data/doc/Users guide Standalone.html +3983 -0
  25. data/doc/Users guide.html +1748 -0
  26. data/doc/users_guide_snippets/installation.txt +4 -4
  27. data/ext/apache2/Configuration.cpp +16 -5
  28. data/ext/apache2/Configuration.hpp +4 -2
  29. data/ext/apache2/Hooks.cpp +44 -19
  30. data/ext/boost/libs/thread/src/pthread/once.cpp +2 -0
  31. data/ext/boost/libs/thread/src/pthread/once_atomic.cpp +6 -0
  32. data/ext/common/AgentsStarter.h +3 -2
  33. data/ext/common/ApplicationPool2/DirectSpawner.h +14 -4
  34. data/ext/common/ApplicationPool2/DummySpawner.h +12 -7
  35. data/ext/common/ApplicationPool2/Implementation.cpp +1 -1
  36. data/ext/common/ApplicationPool2/Process.h +2 -1
  37. data/ext/common/ApplicationPool2/Session.h +6 -6
  38. data/ext/common/ApplicationPool2/SmartSpawner.h +19 -4
  39. data/ext/common/ApplicationPool2/Socket.h +59 -27
  40. data/ext/common/ApplicationPool2/Spawner.h +2 -2
  41. data/ext/common/BackgroundEventLoop.cpp +6 -1
  42. data/ext/common/Constants.h +1 -1
  43. data/ext/common/EventedClient.h +1 -1
  44. data/ext/common/EventedServer.h +2 -2
  45. data/ext/common/FileDescriptor.h +25 -6
  46. data/ext/common/Logging.cpp +107 -52
  47. data/ext/common/Logging.h +146 -19
  48. data/ext/common/MessageClient.h +2 -2
  49. data/ext/common/MessageServer.h +3 -2
  50. data/ext/common/RandomGenerator.h +8 -7
  51. data/ext/common/SafeLibev.h +5 -1
  52. data/ext/common/ServerKit/AcceptLoadBalancer.h +9 -4
  53. data/ext/common/ServerKit/FdSinkChannel.h +5 -2
  54. data/ext/common/ServerKit/FdSourceChannel.h +5 -2
  55. data/ext/common/ServerKit/FileBufferedChannel.h +2 -0
  56. data/ext/common/ServerKit/FileBufferedFdSinkChannel.h +7 -2
  57. data/ext/common/ServerKit/HttpServer.h +6 -0
  58. data/ext/common/ServerKit/Server.h +40 -3
  59. data/ext/common/StaticString.h +20 -0
  60. data/ext/common/UnionStation/Connection.h +3 -1
  61. data/ext/common/UnionStation/Core.h +6 -4
  62. data/ext/common/Utils.cpp +4 -3
  63. data/ext/common/Utils/DateParsing.h +19 -5
  64. data/ext/common/Utils/FastStringStream.h +183 -0
  65. data/ext/common/Utils/IOUtils.cpp +47 -28
  66. data/ext/common/Utils/IOUtils.h +56 -12
  67. data/ext/common/Utils/MessagePassing.h +3 -3
  68. data/ext/common/Utils/ProcessMetricsCollector.h +2 -2
  69. data/ext/common/Utils/ScopeGuard.h +16 -5
  70. data/ext/common/Utils/SpeedMeter.h +2 -2
  71. data/ext/common/Utils/StrIntUtils.cpp +6 -6
  72. data/ext/common/Utils/StrIntUtils.h +2 -1
  73. data/ext/common/agents/Base.cpp +56 -4
  74. data/ext/common/agents/Base.h +2 -1
  75. data/ext/common/agents/HelperAgent/AdminServer.h +122 -11
  76. data/ext/common/agents/HelperAgent/Main.cpp +16 -5
  77. data/ext/common/agents/HelperAgent/OptionParser.h +7 -1
  78. data/ext/common/agents/HelperAgent/RequestHandler.h +1 -1
  79. data/ext/common/agents/HelperAgent/RequestHandler/Hooks.cpp +10 -1
  80. data/ext/common/agents/HelperAgent/RequestHandler/Request.h +8 -0
  81. data/ext/common/agents/HelperAgent/RequestHandler/TurboCaching.h +4 -3
  82. data/ext/common/agents/LoggingAgent/AdminServer.h +57 -11
  83. data/ext/common/agents/LoggingAgent/LoggingServer.h +3 -3
  84. data/ext/common/agents/LoggingAgent/Main.cpp +11 -3
  85. data/ext/common/agents/Watchdog/AdminServer.h +53 -11
  86. data/ext/common/agents/Watchdog/AgentWatcher.cpp +3 -3
  87. data/ext/common/agents/Watchdog/Main.cpp +13 -6
  88. data/ext/libeio/ecb.h +1 -1
  89. data/ext/libev/ev.c +13 -1
  90. data/ext/libev/ev.h +3 -0
  91. data/ext/nginx/Configuration.c +28 -6
  92. data/ext/nginx/Configuration.h +2 -1
  93. data/ext/nginx/ngx_http_passenger_module.c +5 -4
  94. data/ext/oxt/dynamic_thread_group.hpp +38 -5
  95. data/lib/phusion_passenger.rb +1 -1
  96. data/lib/phusion_passenger/common_library.rb +9 -5
  97. data/lib/phusion_passenger/config/reopen_logs_command.rb +2 -2
  98. data/lib/phusion_passenger/packaging.rb +23 -37
  99. data/passenger.gemspec +21 -21
  100. metadata +4 -453
  101. metadata.gz.asc +7 -7
  102. data/.gitignore +0 -68
  103. data/.travis.yml +0 -16
  104. data/Gemfile +0 -17
  105. data/Gemfile.lock +0 -39
  106. data/Vagrantfile +0 -54
  107. data/debian.template/README.Debian +0 -15
  108. data/debian.template/changelog +0 -316
  109. data/debian.template/compat +0 -1
  110. data/debian.template/control.erb +0 -91
  111. data/debian.template/copyright +0 -385
  112. data/debian.template/libapache2-mod-passenger.install +0 -3
  113. data/debian.template/libapache2-mod-passenger.postinst +0 -36
  114. data/debian.template/libapache2-mod-passenger.prerm +0 -15
  115. data/debian.template/locations.ini.erb +0 -14
  116. data/debian.template/passenger-dev.install.erb +0 -3
  117. data/debian.template/passenger-doc.install.erb +0 -2
  118. data/debian.template/passenger.conf +0 -6
  119. data/debian.template/passenger.docs +0 -4
  120. data/debian.template/passenger.install.erb +0 -14
  121. data/debian.template/passenger.load +0 -3
  122. data/debian.template/passenger.manpages +0 -3
  123. data/debian.template/patches/series +0 -0
  124. data/debian.template/rules.erb +0 -76
  125. data/debian.template/source/format +0 -1
  126. data/ext/common/EventedBufferedInput.h +0 -458
  127. data/packaging/rpm/LICENSE.txt +0 -19
  128. data/packaging/rpm/Makefile +0 -13
  129. data/packaging/rpm/README.md +0 -41
  130. data/packaging/rpm/Vagrantfile +0 -38
  131. data/packaging/rpm/Vagrantfile.centos +0 -30
  132. data/packaging/rpm/build +0 -170
  133. data/packaging/rpm/create_project +0 -41
  134. data/packaging/rpm/git_update +0 -88
  135. data/packaging/rpm/image/Dockerfile +0 -37
  136. data/packaging/rpm/image/Gemfile +0 -3
  137. data/packaging/rpm/image/Gemfile.lock +0 -12
  138. data/packaging/rpm/image/RPM-GPG-KEY-amazon-ga +0 -19
  139. data/packaging/rpm/image/amazon2014-i386.cfg +0 -96
  140. data/packaging/rpm/image/amazon2014-x86_64.cfg +0 -96
  141. data/packaging/rpm/image/site-defaults.cfg +0 -168
  142. data/packaging/rpm/internal/build_tasks.rb +0 -238
  143. data/packaging/rpm/internal/dummygpg +0 -11
  144. data/packaging/rpm/internal/exec_build +0 -42
  145. data/packaging/rpm/internal/get_distro_arch +0 -14
  146. data/packaging/rpm/internal/get_distro_id +0 -10
  147. data/packaging/rpm/internal/git_update +0 -27
  148. data/packaging/rpm/internal/inituidgid +0 -17
  149. data/packaging/rpm/internal/my_init +0 -344
  150. data/packaging/rpm/internal/python27 +0 -3
  151. data/packaging/rpm/internal/repo_update +0 -46
  152. data/packaging/rpm/internal/setuser +0 -26
  153. data/packaging/rpm/internal/tracking_helper +0 -40
  154. data/packaging/rpm/jenkins_release +0 -99
  155. data/packaging/rpm/lib/build_tasks_support.rb +0 -402
  156. data/packaging/rpm/lib/preprocessor.rb +0 -341
  157. data/packaging/rpm/nginx_spec/404.html +0 -119
  158. data/packaging/rpm/nginx_spec/50x.html +0 -119
  159. data/packaging/rpm/nginx_spec/index.html +0 -116
  160. data/packaging/rpm/nginx_spec/nginx-auto-cc-gcc.patch +0 -13
  161. data/packaging/rpm/nginx_spec/nginx-logo.png +0 -0
  162. data/packaging/rpm/nginx_spec/nginx-upgrade +0 -13
  163. data/packaging/rpm/nginx_spec/nginx-upgrade.8 +0 -151
  164. data/packaging/rpm/nginx_spec/nginx.conf +0 -131
  165. data/packaging/rpm/nginx_spec/nginx.init +0 -144
  166. data/packaging/rpm/nginx_spec/nginx.logrotate +0 -13
  167. data/packaging/rpm/nginx_spec/nginx.service +0 -15
  168. data/packaging/rpm/nginx_spec/nginx.spec.template +0 -560
  169. data/packaging/rpm/nginx_spec/nginx.sysconfig +0 -4
  170. data/packaging/rpm/nginx_spec/passenger.conf +0 -9
  171. data/packaging/rpm/nginx_spec/poweredby.png +0 -0
  172. data/packaging/rpm/passenger_spec/apache-passenger.conf.in +0 -26
  173. data/packaging/rpm/passenger_spec/config.json +0 -30
  174. data/packaging/rpm/passenger_spec/passenger.logrotate +0 -7
  175. data/packaging/rpm/passenger_spec/passenger.spec.template +0 -478
  176. data/packaging/rpm/passenger_spec/passenger_dynamic_thread_group.patch +0 -16
  177. data/packaging/rpm/passenger_spec/passenger_tests_default_config_example.patch +0 -44
  178. data/packaging/rpm/passenger_spec/rubygem-passenger-4.0.18-GLIBC_HAVE_LONG_LONG.patch +0 -21
  179. data/packaging/rpm/repo_update +0 -114
  180. data/packaging/rpm/setup-system +0 -61
  181. data/packaging/rpm/shell +0 -10
  182. data/test/.rspec +0 -4
  183. data/test/config.json.example +0 -42
  184. data/test/config.json.rpm-automation +0 -15
  185. data/test/config.json.travis +0 -15
  186. data/test/config.json.vagrant +0 -30
  187. data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +0 -124
  188. data/test/cxx/ApplicationPool2/OptionsTest.cpp +0 -30
  189. data/test/cxx/ApplicationPool2/PoolTest.cpp +0 -2062
  190. data/test/cxx/ApplicationPool2/ProcessTest.cpp +0 -130
  191. data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +0 -243
  192. data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +0 -823
  193. data/test/cxx/BufferedIOTest.cpp +0 -364
  194. data/test/cxx/CachedFileStatTest.cpp +0 -402
  195. data/test/cxx/CxxTestMain.cpp +0 -181
  196. data/test/cxx/DataStructures/LStringTest.cpp +0 -275
  197. data/test/cxx/DataStructures/StringKeyTableTest.cpp +0 -199
  198. data/test/cxx/DateParsingTest.cpp +0 -75
  199. data/test/cxx/DechunkerTest.cpp +0 -250
  200. data/test/cxx/EventedBufferedInputTest.cpp +0 -758
  201. data/test/cxx/EventedClientTest.cpp +0 -523
  202. data/test/cxx/FileChangeCheckerTest.cpp +0 -331
  203. data/test/cxx/FileDescriptorTest.cpp +0 -69
  204. data/test/cxx/FilterSupportTest.cpp +0 -433
  205. data/test/cxx/IOUtilsTest.cpp +0 -861
  206. data/test/cxx/MemoryKit/MbufTest.cpp +0 -213
  207. data/test/cxx/MessageIOTest.cpp +0 -360
  208. data/test/cxx/MessagePassingTest.cpp +0 -81
  209. data/test/cxx/MessageReadersWritersTest.cpp +0 -576
  210. data/test/cxx/MessageServerTest.cpp +0 -393
  211. data/test/cxx/ProcessMetricsCollectorTest.cpp +0 -123
  212. data/test/cxx/RequestHandlerTest.cpp +0 -1463
  213. data/test/cxx/ResponseCacheTest.cpp +0 -322
  214. data/test/cxx/ServerKit/ChannelTest.cpp +0 -1467
  215. data/test/cxx/ServerKit/CookieUtilsTest.cpp +0 -274
  216. data/test/cxx/ServerKit/FileBufferedChannelTest.cpp +0 -992
  217. data/test/cxx/ServerKit/HeaderTableTest.cpp +0 -177
  218. data/test/cxx/ServerKit/HttpServerTest.cpp +0 -1580
  219. data/test/cxx/ServerKit/ServerTest.cpp +0 -408
  220. data/test/cxx/StaticStringTest.cpp +0 -220
  221. data/test/cxx/StringMapTest.cpp +0 -131
  222. data/test/cxx/SystemTimeTest.cpp +0 -37
  223. data/test/cxx/TemplateTest.cpp +0 -118
  224. data/test/cxx/TestSupport.cpp +0 -207
  225. data/test/cxx/TestSupport.h +0 -333
  226. data/test/cxx/UnionStationTest.cpp +0 -741
  227. data/test/cxx/Utils/StrIntUtilsTest.cpp +0 -39
  228. data/test/cxx/UtilsTest.cpp +0 -672
  229. data/test/cxx/VariantMapTest.cpp +0 -191
  230. data/test/gdbinit.example +0 -34
  231. data/test/integration_tests/apache2_tests.rb +0 -585
  232. data/test/integration_tests/downloaded_binaries_tests.rb +0 -185
  233. data/test/integration_tests/native_packaging_spec.rb +0 -368
  234. data/test/integration_tests/nginx_tests.rb +0 -402
  235. data/test/integration_tests/shared/example_webapp_tests.rb +0 -289
  236. data/test/integration_tests/source_packaging_test.rb +0 -201
  237. data/test/integration_tests/spec_helper.rb +0 -22
  238. data/test/integration_tests/standalone_tests.rb +0 -392
  239. data/test/node/line_reader_spec.js +0 -338
  240. data/test/node/spec_helper.js +0 -65
  241. data/test/oxt/backtrace_test.cpp +0 -88
  242. data/test/oxt/counter.hpp +0 -55
  243. data/test/oxt/dynamic_thread_group_test.cpp +0 -131
  244. data/test/oxt/oxt_test_main.cpp +0 -27
  245. data/test/oxt/spin_lock_test.cpp +0 -59
  246. data/test/oxt/syscall_interruption_test.cpp +0 -39
  247. data/test/ruby/debug_logging_spec.rb +0 -145
  248. data/test/ruby/message_channel_spec.rb +0 -196
  249. data/test/ruby/rack/loader_spec.rb +0 -42
  250. data/test/ruby/rack/preloader_spec.rb +0 -48
  251. data/test/ruby/rails3.0/loader_spec.rb +0 -26
  252. data/test/ruby/rails3.0/preloader_spec.rb +0 -32
  253. data/test/ruby/rails3.1/loader_spec.rb +0 -26
  254. data/test/ruby/rails3.1/preloader_spec.rb +0 -32
  255. data/test/ruby/rails3.2/loader_spec.rb +0 -26
  256. data/test/ruby/rails3.2/preloader_spec.rb +0 -32
  257. data/test/ruby/rails4.0/loader_spec.rb +0 -28
  258. data/test/ruby/rails4.0/preloader_spec.rb +0 -34
  259. data/test/ruby/rails4.1/loader_spec.rb +0 -28
  260. data/test/ruby/rails4.1/preloader_spec.rb +0 -34
  261. data/test/ruby/request_handler_spec.rb +0 -747
  262. data/test/ruby/shared/loader_sharedspec.rb +0 -247
  263. data/test/ruby/shared/rails/union_station_extensions_sharedspec.rb +0 -357
  264. data/test/ruby/shared/ruby_loader_sharedspec.rb +0 -55
  265. data/test/ruby/spec_helper.rb +0 -114
  266. data/test/ruby/standalone/runtime_installer_spec.rb +0 -402
  267. data/test/ruby/union_station_spec.rb +0 -288
  268. data/test/ruby/utils/file_system_watcher_spec.rb +0 -229
  269. data/test/ruby/utils/hosts_file_parser.rb +0 -258
  270. data/test/ruby/utils/tee_input_spec.rb +0 -235
  271. data/test/ruby/utils/unseekable_socket_spec.rb +0 -66
  272. data/test/ruby/utils_spec.rb +0 -41
  273. data/test/stub/apache2/httpd.conf.erb +0 -122
  274. data/test/stub/apache2/mime.types +0 -748
  275. data/test/stub/garbage1.dat +0 -0
  276. data/test/stub/garbage2.dat +0 -0
  277. data/test/stub/garbage3.dat +0 -0
  278. data/test/stub/http_request.yml +0 -23
  279. data/test/stub/index.html +0 -1
  280. data/test/stub/nginx/koi-utf +0 -109
  281. data/test/stub/nginx/koi-win +0 -103
  282. data/test/stub/nginx/mime.types +0 -70
  283. data/test/stub/nginx/nginx.conf.erb +0 -70
  284. data/test/stub/nginx/win-utf +0 -126
  285. data/test/stub/node/app.js +0 -133
  286. data/test/stub/node/public/.gitignore +0 -0
  287. data/test/stub/node/tmp/.gitignore +0 -0
  288. data/test/stub/rack/config.ru +0 -95
  289. data/test/stub/rack/library.rb +0 -16
  290. data/test/stub/rack/public/.gitignore +0 -0
  291. data/test/stub/rack/start.rb +0 -52
  292. data/test/stub/rack/tmp/.gitignore +0 -0
  293. data/test/stub/rails3.0/.gitignore +0 -4
  294. data/test/stub/rails3.0/Gemfile +0 -22
  295. data/test/stub/rails3.0/Gemfile.lock +0 -80
  296. data/test/stub/rails3.0/Rakefile +0 -10
  297. data/test/stub/rails3.0/app/controllers/application_controller.rb +0 -4
  298. data/test/stub/rails3.0/app/helpers/application_helper.rb +0 -2
  299. data/test/stub/rails3.0/app/views/layouts/application.html.erb +0 -14
  300. data/test/stub/rails3.0/config.ru +0 -4
  301. data/test/stub/rails3.0/config/application.rb +0 -48
  302. data/test/stub/rails3.0/config/boot.rb +0 -13
  303. data/test/stub/rails3.0/config/database.yml +0 -22
  304. data/test/stub/rails3.0/config/environment.rb +0 -5
  305. data/test/stub/rails3.0/config/environments/development.rb +0 -19
  306. data/test/stub/rails3.0/config/environments/production.rb +0 -48
  307. data/test/stub/rails3.0/config/environments/test.rb +0 -32
  308. data/test/stub/rails3.0/config/initializers/backtrace_silencers.rb +0 -7
  309. data/test/stub/rails3.0/config/initializers/inflections.rb +0 -10
  310. data/test/stub/rails3.0/config/initializers/mime_types.rb +0 -5
  311. data/test/stub/rails3.0/config/initializers/passenger.rb +0 -2
  312. data/test/stub/rails3.0/config/initializers/secret_token.rb +0 -7
  313. data/test/stub/rails3.0/config/initializers/session_store.rb +0 -8
  314. data/test/stub/rails3.0/config/locales/en.yml +0 -5
  315. data/test/stub/rails3.0/config/routes.rb +0 -58
  316. data/test/stub/rails3.0/db/seeds.rb +0 -7
  317. data/test/stub/rails3.0/doc/README_FOR_APP +0 -2
  318. data/test/stub/rails3.0/lib/tasks/.gitkeep +0 -0
  319. data/test/stub/rails3.0/log/.gitignore +0 -0
  320. data/test/stub/rails3.0/public/404.html +0 -26
  321. data/test/stub/rails3.0/public/422.html +0 -26
  322. data/test/stub/rails3.0/public/500.html +0 -26
  323. data/test/stub/rails3.0/public/favicon.ico +0 -0
  324. data/test/stub/rails3.0/public/index.html +0 -279
  325. data/test/stub/rails3.0/public/robots.txt +0 -5
  326. data/test/stub/rails3.0/public/stylesheets/.gitkeep +0 -0
  327. data/test/stub/rails3.0/script/rails +0 -9
  328. data/test/stub/rails3.0/test/performance/browsing_test.rb +0 -9
  329. data/test/stub/rails3.0/test/test_helper.rb +0 -13
  330. data/test/stub/rails3.0/vendor/plugins/.gitkeep +0 -0
  331. data/test/stub/rails3.1/.gitignore +0 -15
  332. data/test/stub/rails3.1/Gemfile +0 -37
  333. data/test/stub/rails3.1/Gemfile.lock +0 -115
  334. data/test/stub/rails3.1/README +0 -261
  335. data/test/stub/rails3.1/Rakefile +0 -7
  336. data/test/stub/rails3.1/app/assets/images/rails.png +0 -0
  337. data/test/stub/rails3.1/app/assets/stylesheets/application.css +0 -7
  338. data/test/stub/rails3.1/app/controllers/application_controller.rb +0 -3
  339. data/test/stub/rails3.1/app/helpers/application_helper.rb +0 -2
  340. data/test/stub/rails3.1/app/mailers/.gitkeep +0 -0
  341. data/test/stub/rails3.1/app/models/.gitkeep +0 -0
  342. data/test/stub/rails3.1/app/views/layouts/application.html.erb +0 -14
  343. data/test/stub/rails3.1/config.ru +0 -4
  344. data/test/stub/rails3.1/config/application.rb +0 -48
  345. data/test/stub/rails3.1/config/boot.rb +0 -6
  346. data/test/stub/rails3.1/config/database.yml +0 -25
  347. data/test/stub/rails3.1/config/environment.rb +0 -5
  348. data/test/stub/rails3.1/config/environments/development.rb +0 -30
  349. data/test/stub/rails3.1/config/environments/production.rb +0 -60
  350. data/test/stub/rails3.1/config/environments/test.rb +0 -39
  351. data/test/stub/rails3.1/config/initializers/backtrace_silencers.rb +0 -7
  352. data/test/stub/rails3.1/config/initializers/inflections.rb +0 -10
  353. data/test/stub/rails3.1/config/initializers/mime_types.rb +0 -5
  354. data/test/stub/rails3.1/config/initializers/passenger.rb +0 -2
  355. data/test/stub/rails3.1/config/initializers/secret_token.rb +0 -7
  356. data/test/stub/rails3.1/config/initializers/session_store.rb +0 -8
  357. data/test/stub/rails3.1/config/initializers/wrap_parameters.rb +0 -14
  358. data/test/stub/rails3.1/config/locales/en.yml +0 -5
  359. data/test/stub/rails3.1/config/routes.rb +0 -58
  360. data/test/stub/rails3.1/db/seeds.rb +0 -7
  361. data/test/stub/rails3.1/doc/README_FOR_APP +0 -2
  362. data/test/stub/rails3.1/lib/assets/.gitkeep +0 -0
  363. data/test/stub/rails3.1/lib/tasks/.gitkeep +0 -0
  364. data/test/stub/rails3.1/log/.gitkeep +0 -0
  365. data/test/stub/rails3.1/public/404.html +0 -26
  366. data/test/stub/rails3.1/public/422.html +0 -26
  367. data/test/stub/rails3.1/public/500.html +0 -26
  368. data/test/stub/rails3.1/public/favicon.ico +0 -0
  369. data/test/stub/rails3.1/public/index.html +0 -241
  370. data/test/stub/rails3.1/public/robots.txt +0 -5
  371. data/test/stub/rails3.1/script/rails +0 -6
  372. data/test/stub/rails3.1/test/fixtures/.gitkeep +0 -0
  373. data/test/stub/rails3.1/test/functional/.gitkeep +0 -0
  374. data/test/stub/rails3.1/test/integration/.gitkeep +0 -0
  375. data/test/stub/rails3.1/test/performance/browsing_test.rb +0 -12
  376. data/test/stub/rails3.1/test/test_helper.rb +0 -13
  377. data/test/stub/rails3.1/test/unit/.gitkeep +0 -0
  378. data/test/stub/rails3.1/vendor/assets/stylesheets/.gitkeep +0 -0
  379. data/test/stub/rails3.1/vendor/plugins/.gitkeep +0 -0
  380. data/test/stub/rails3.2/.gitignore +0 -15
  381. data/test/stub/rails3.2/Gemfile +0 -39
  382. data/test/stub/rails3.2/Gemfile.lock +0 -113
  383. data/test/stub/rails3.2/Rakefile +0 -7
  384. data/test/stub/rails3.2/app/assets/images/rails.png +0 -0
  385. data/test/stub/rails3.2/app/assets/stylesheets/application.css +0 -13
  386. data/test/stub/rails3.2/app/controllers/application_controller.rb +0 -3
  387. data/test/stub/rails3.2/app/helpers/application_helper.rb +0 -2
  388. data/test/stub/rails3.2/app/mailers/.gitkeep +0 -0
  389. data/test/stub/rails3.2/app/models/.gitkeep +0 -0
  390. data/test/stub/rails3.2/app/views/layouts/application.html.erb +0 -14
  391. data/test/stub/rails3.2/config.ru +0 -4
  392. data/test/stub/rails3.2/config/application.rb +0 -62
  393. data/test/stub/rails3.2/config/boot.rb +0 -6
  394. data/test/stub/rails3.2/config/database.yml +0 -25
  395. data/test/stub/rails3.2/config/environment.rb +0 -5
  396. data/test/stub/rails3.2/config/environments/development.rb +0 -37
  397. data/test/stub/rails3.2/config/environments/production.rb +0 -67
  398. data/test/stub/rails3.2/config/environments/test.rb +0 -37
  399. data/test/stub/rails3.2/config/initializers/backtrace_silencers.rb +0 -7
  400. data/test/stub/rails3.2/config/initializers/inflections.rb +0 -15
  401. data/test/stub/rails3.2/config/initializers/mime_types.rb +0 -5
  402. data/test/stub/rails3.2/config/initializers/passenger.rb +0 -2
  403. data/test/stub/rails3.2/config/initializers/secret_token.rb +0 -7
  404. data/test/stub/rails3.2/config/initializers/session_store.rb +0 -8
  405. data/test/stub/rails3.2/config/initializers/wrap_parameters.rb +0 -14
  406. data/test/stub/rails3.2/config/locales/en.yml +0 -5
  407. data/test/stub/rails3.2/config/routes.rb +0 -58
  408. data/test/stub/rails3.2/db/seeds.rb +0 -7
  409. data/test/stub/rails3.2/doc/README_FOR_APP +0 -2
  410. data/test/stub/rails3.2/lib/assets/.gitkeep +0 -0
  411. data/test/stub/rails3.2/lib/tasks/.gitkeep +0 -0
  412. data/test/stub/rails3.2/log/.gitkeep +0 -0
  413. data/test/stub/rails3.2/public/404.html +0 -26
  414. data/test/stub/rails3.2/public/422.html +0 -26
  415. data/test/stub/rails3.2/public/500.html +0 -25
  416. data/test/stub/rails3.2/public/favicon.ico +0 -0
  417. data/test/stub/rails3.2/public/index.html +0 -241
  418. data/test/stub/rails3.2/public/robots.txt +0 -5
  419. data/test/stub/rails3.2/script/rails +0 -6
  420. data/test/stub/rails3.2/test/fixtures/.gitkeep +0 -0
  421. data/test/stub/rails3.2/test/functional/.gitkeep +0 -0
  422. data/test/stub/rails3.2/test/integration/.gitkeep +0 -0
  423. data/test/stub/rails3.2/test/performance/browsing_test.rb +0 -12
  424. data/test/stub/rails3.2/test/test_helper.rb +0 -13
  425. data/test/stub/rails3.2/test/unit/.gitkeep +0 -0
  426. data/test/stub/rails3.2/vendor/assets/stylesheets/.gitkeep +0 -0
  427. data/test/stub/rails3.2/vendor/plugins/.gitkeep +0 -0
  428. data/test/stub/rails4.0/.gitignore +0 -16
  429. data/test/stub/rails4.0/Gemfile +0 -45
  430. data/test/stub/rails4.0/Gemfile.lock +0 -126
  431. data/test/stub/rails4.0/README.rdoc +0 -28
  432. data/test/stub/rails4.0/Rakefile +0 -6
  433. data/test/stub/rails4.0/app/assets/images/.keep +0 -0
  434. data/test/stub/rails4.0/app/assets/javascripts/application.js +0 -16
  435. data/test/stub/rails4.0/app/assets/stylesheets/application.css +0 -13
  436. data/test/stub/rails4.0/app/controllers/application_controller.rb +0 -5
  437. data/test/stub/rails4.0/app/controllers/concerns/.keep +0 -0
  438. data/test/stub/rails4.0/app/helpers/application_helper.rb +0 -2
  439. data/test/stub/rails4.0/app/mailers/.keep +0 -0
  440. data/test/stub/rails4.0/app/models/.keep +0 -0
  441. data/test/stub/rails4.0/app/models/concerns/.keep +0 -0
  442. data/test/stub/rails4.0/app/views/layouts/application.html.erb +0 -14
  443. data/test/stub/rails4.0/bin/bundle +0 -3
  444. data/test/stub/rails4.0/bin/rails +0 -4
  445. data/test/stub/rails4.0/bin/rake +0 -4
  446. data/test/stub/rails4.0/config.ru +0 -4
  447. data/test/stub/rails4.0/config/application.rb +0 -23
  448. data/test/stub/rails4.0/config/boot.rb +0 -4
  449. data/test/stub/rails4.0/config/database.yml +0 -25
  450. data/test/stub/rails4.0/config/environment.rb +0 -5
  451. data/test/stub/rails4.0/config/environments/development.rb +0 -29
  452. data/test/stub/rails4.0/config/environments/production.rb +0 -80
  453. data/test/stub/rails4.0/config/environments/test.rb +0 -36
  454. data/test/stub/rails4.0/config/initializers/backtrace_silencers.rb +0 -7
  455. data/test/stub/rails4.0/config/initializers/filter_parameter_logging.rb +0 -4
  456. data/test/stub/rails4.0/config/initializers/inflections.rb +0 -16
  457. data/test/stub/rails4.0/config/initializers/mime_types.rb +0 -5
  458. data/test/stub/rails4.0/config/initializers/passenger.rb +0 -2
  459. data/test/stub/rails4.0/config/initializers/secret_token.rb +0 -12
  460. data/test/stub/rails4.0/config/initializers/session_store.rb +0 -3
  461. data/test/stub/rails4.0/config/initializers/wrap_parameters.rb +0 -14
  462. data/test/stub/rails4.0/config/locales/en.yml +0 -23
  463. data/test/stub/rails4.0/config/routes.rb +0 -57
  464. data/test/stub/rails4.0/db/seeds.rb +0 -7
  465. data/test/stub/rails4.0/lib/assets/.keep +0 -0
  466. data/test/stub/rails4.0/lib/tasks/.keep +0 -0
  467. data/test/stub/rails4.0/log/.keep +0 -0
  468. data/test/stub/rails4.0/public/404.html +0 -58
  469. data/test/stub/rails4.0/public/422.html +0 -58
  470. data/test/stub/rails4.0/public/500.html +0 -57
  471. data/test/stub/rails4.0/public/favicon.ico +0 -0
  472. data/test/stub/rails4.0/public/robots.txt +0 -5
  473. data/test/stub/rails4.0/test/controllers/.keep +0 -0
  474. data/test/stub/rails4.0/test/fixtures/.keep +0 -0
  475. data/test/stub/rails4.0/test/helpers/.keep +0 -0
  476. data/test/stub/rails4.0/test/integration/.keep +0 -0
  477. data/test/stub/rails4.0/test/mailers/.keep +0 -0
  478. data/test/stub/rails4.0/test/models/.keep +0 -0
  479. data/test/stub/rails4.0/test/test_helper.rb +0 -15
  480. data/test/stub/rails4.0/vendor/assets/javascripts/.keep +0 -0
  481. data/test/stub/rails4.0/vendor/assets/stylesheets/.keep +0 -0
  482. data/test/stub/rails4.1/.gitignore +0 -16
  483. data/test/stub/rails4.1/Gemfile +0 -45
  484. data/test/stub/rails4.1/Gemfile.lock +0 -129
  485. data/test/stub/rails4.1/README.rdoc +0 -28
  486. data/test/stub/rails4.1/Rakefile +0 -6
  487. data/test/stub/rails4.1/app/assets/images/.keep +0 -0
  488. data/test/stub/rails4.1/app/assets/javascripts/application.js +0 -16
  489. data/test/stub/rails4.1/app/assets/stylesheets/application.css +0 -13
  490. data/test/stub/rails4.1/app/controllers/application_controller.rb +0 -5
  491. data/test/stub/rails4.1/app/controllers/concerns/.keep +0 -0
  492. data/test/stub/rails4.1/app/helpers/application_helper.rb +0 -2
  493. data/test/stub/rails4.1/app/mailers/.keep +0 -0
  494. data/test/stub/rails4.1/app/models/.keep +0 -0
  495. data/test/stub/rails4.1/app/models/concerns/.keep +0 -0
  496. data/test/stub/rails4.1/app/views/layouts/application.html.erb +0 -14
  497. data/test/stub/rails4.1/bin/bundle +0 -3
  498. data/test/stub/rails4.1/bin/rails +0 -4
  499. data/test/stub/rails4.1/bin/rake +0 -4
  500. data/test/stub/rails4.1/config.ru +0 -4
  501. data/test/stub/rails4.1/config/application.rb +0 -23
  502. data/test/stub/rails4.1/config/boot.rb +0 -4
  503. data/test/stub/rails4.1/config/database.yml +0 -25
  504. data/test/stub/rails4.1/config/environment.rb +0 -5
  505. data/test/stub/rails4.1/config/environments/development.rb +0 -29
  506. data/test/stub/rails4.1/config/environments/production.rb +0 -80
  507. data/test/stub/rails4.1/config/environments/test.rb +0 -36
  508. data/test/stub/rails4.1/config/initializers/backtrace_silencers.rb +0 -7
  509. data/test/stub/rails4.1/config/initializers/filter_parameter_logging.rb +0 -4
  510. data/test/stub/rails4.1/config/initializers/inflections.rb +0 -16
  511. data/test/stub/rails4.1/config/initializers/mime_types.rb +0 -5
  512. data/test/stub/rails4.1/config/initializers/passenger.rb +0 -5
  513. data/test/stub/rails4.1/config/initializers/secret_token.rb +0 -12
  514. data/test/stub/rails4.1/config/initializers/session_store.rb +0 -3
  515. data/test/stub/rails4.1/config/initializers/wrap_parameters.rb +0 -14
  516. data/test/stub/rails4.1/config/locales/en.yml +0 -23
  517. data/test/stub/rails4.1/config/routes.rb +0 -57
  518. data/test/stub/rails4.1/db/seeds.rb +0 -7
  519. data/test/stub/rails4.1/lib/assets/.keep +0 -0
  520. data/test/stub/rails4.1/lib/tasks/.keep +0 -0
  521. data/test/stub/rails4.1/log/.keep +0 -0
  522. data/test/stub/rails4.1/public/404.html +0 -58
  523. data/test/stub/rails4.1/public/422.html +0 -58
  524. data/test/stub/rails4.1/public/500.html +0 -57
  525. data/test/stub/rails4.1/public/favicon.ico +0 -0
  526. data/test/stub/rails4.1/public/robots.txt +0 -5
  527. data/test/stub/rails4.1/test/controllers/.keep +0 -0
  528. data/test/stub/rails4.1/test/fixtures/.keep +0 -0
  529. data/test/stub/rails4.1/test/helpers/.keep +0 -0
  530. data/test/stub/rails4.1/test/integration/.keep +0 -0
  531. data/test/stub/rails4.1/test/mailers/.keep +0 -0
  532. data/test/stub/rails4.1/test/models/.keep +0 -0
  533. data/test/stub/rails4.1/test/test_helper.rb +0 -15
  534. data/test/stub/rails4.1/vendor/assets/javascripts/.keep +0 -0
  535. data/test/stub/rails4.1/vendor/assets/stylesheets/.keep +0 -0
  536. data/test/stub/start_error.pl +0 -24
  537. data/test/stub/upload_data.txt +0 -494
  538. data/test/stub/wsgi/passenger_wsgi.py +0 -212
  539. data/test/stub/wsgi/public/.gitignore +0 -0
  540. data/test/stub/wsgi/tmp/.gitignore +0 -0
  541. data/test/support/allocate_memory.c +0 -14
  542. data/test/support/apache2_controller.rb +0 -258
  543. data/test/support/multipart.rb +0 -62
  544. data/test/support/nginx_controller.rb +0 -97
  545. data/test/support/placebo-preloader.rb +0 -88
  546. data/test/support/test_helper.rb +0 -455
  547. data/test/support/valgrind.h +0 -2539
  548. data/test/tut/tut.h +0 -1310
  549. data/test/tut/tut_reporter.h +0 -256
  550. data/test/valgrind-osx.supp +0 -7
@@ -1,130 +0,0 @@
1
- #include <TestSupport.h>
2
- #include <ApplicationPool2/Process.h>
3
- #include <Utils/IOUtils.h>
4
-
5
- using namespace Passenger;
6
- using namespace Passenger::ApplicationPool2;
7
- using namespace std;
8
-
9
- namespace tut {
10
- struct ApplicationPool2_ProcessTest {
11
- BackgroundEventLoop bg;
12
- SocketList sockets;
13
- SocketPair adminSocket;
14
- Pipe errorPipe;
15
- FileDescriptor server1, server2, server3;
16
-
17
- ApplicationPool2_ProcessTest() {
18
- bg.start();
19
-
20
- struct sockaddr_in addr;
21
- socklen_t len = sizeof(addr);
22
-
23
- server1 = createTcpServer("127.0.0.1", 0);
24
- getsockname(server1, (struct sockaddr *) &addr, &len);
25
- sockets.add("main1",
26
- "tcp://127.0.0.1:" + toString(addr.sin_port),
27
- "session", 3);
28
-
29
- server2 = createTcpServer("127.0.0.1", 0);
30
- getsockname(server2, (struct sockaddr *) &addr, &len);
31
- sockets.add("main2",
32
- "tcp://127.0.0.1:" + toString(addr.sin_port),
33
- "session", 3);
34
-
35
- server3 = createTcpServer("127.0.0.1", 0);
36
- getsockname(server3, (struct sockaddr *) &addr, &len);
37
- sockets.add("main3",
38
- "tcp://127.0.0.1:" + toString(addr.sin_port),
39
- "session", 3);
40
-
41
- adminSocket = createUnixSocketPair();
42
- errorPipe = createPipe();
43
- }
44
-
45
- ProcessPtr createProcess() {
46
- ProcessPtr process = boost::make_shared<Process>(123,
47
- "123", adminSocket[0], errorPipe[0], sockets, 0, 0);
48
- process->dummy = true;
49
- process->requiresShutdown = false;
50
- return process;
51
- }
52
- };
53
-
54
- DEFINE_TEST_GROUP(ApplicationPool2_ProcessTest);
55
-
56
- TEST_METHOD(1) {
57
- // Test initial state.
58
- ProcessPtr process = createProcess();
59
- ensure_equals(process->busyness(), 0);
60
- ensure(!process->isTotallyBusy());
61
- }
62
-
63
- TEST_METHOD(2) {
64
- // Test opening and closing sessions.
65
- ProcessPtr process = createProcess();
66
- SessionPtr session = process->newSession();
67
- SessionPtr session2 = process->newSession();
68
- ensure_equals(process->sessions, 2);
69
- process->sessionClosed(session.get());
70
- ensure_equals(process->sessions, 1);
71
- process->sessionClosed(session2.get());
72
- ensure_equals(process->sessions, 0);
73
- }
74
-
75
- TEST_METHOD(3) {
76
- // newSession() checks out the socket with the smallest busyness number
77
- // and sessionClosed() restores the session busyness statistics.
78
- ProcessPtr process = createProcess();
79
-
80
- // The first 3 newSession() commands check out an idle socket.
81
- SessionPtr session1 = process->newSession();
82
- SessionPtr session2 = process->newSession();
83
- SessionPtr session3 = process->newSession();
84
- ensure(session1->getSocket()->name != session2->getSocket()->name);
85
- ensure(session1->getSocket()->name != session3->getSocket()->name);
86
- ensure(session2->getSocket()->name != session3->getSocket()->name);
87
-
88
- // The next 2 newSession() commands check out sockets with sessions == 1.
89
- SessionPtr session4 = process->newSession();
90
- SessionPtr session5 = process->newSession();
91
- ensure(session4->getSocket()->name != session5->getSocket()->name);
92
-
93
- // There should now be 1 process with 1 session
94
- // and 2 processes with 2 sessions.
95
- map<int, int> sessionCount;
96
- SocketList::const_iterator it;
97
- for (it = process->sockets.begin(); it != process->sockets.end(); it++) {
98
- sessionCount[it->sessions]++;
99
- }
100
- ensure_equals(sessionCount.size(), 2u);
101
- ensure_equals(sessionCount[1], 1);
102
- ensure_equals(sessionCount[2], 2);
103
-
104
- // Closing the first 3 sessions will result in no processes having 1 session
105
- // and 1 process having 2 sessions.
106
- process->sessionClosed(session1.get());
107
- process->sessionClosed(session2.get());
108
- process->sessionClosed(session3.get());
109
- sessionCount.clear();
110
- for (it = process->sockets.begin(); it != process->sockets.end(); it++) {
111
- sessionCount[it->sessions]++;
112
- }
113
- ensure_equals(sessionCount[0], 1);
114
- ensure_equals(sessionCount[1], 2);
115
- }
116
-
117
- TEST_METHOD(4) {
118
- // If all sockets are at their full capacity then newSession() will fail.
119
- ProcessPtr process = createProcess();
120
- vector<SessionPtr> sessions;
121
- for (int i = 0; i < 9; i++) {
122
- ensure(!process->isTotallyBusy());
123
- SessionPtr session = process->newSession();
124
- ensure(session != NULL);
125
- sessions.push_back(session);
126
- }
127
- ensure(process->isTotallyBusy());
128
- ensure(process->newSession() == NULL);
129
- }
130
- }
@@ -1,243 +0,0 @@
1
- #include <TestSupport.h>
2
- #include <ApplicationPool2/SmartSpawner.h>
3
- #include <Logging.h>
4
- #include <Utils/json.h>
5
- #include <unistd.h>
6
- #include <climits>
7
- #include <signal.h>
8
- #include <fcntl.h>
9
-
10
- using namespace std;
11
- using namespace Passenger;
12
- using namespace Passenger::ApplicationPool2;
13
-
14
- namespace tut {
15
- struct ApplicationPool2_SmartSpawnerTest {
16
- SpawnObject object;
17
- PipeWatcher::DataCallback gatherOutput;
18
- string gatheredOutput;
19
- boost::mutex gatheredOutputSyncher;
20
-
21
- ApplicationPool2_SmartSpawnerTest() {
22
- PipeWatcher::onData = PipeWatcher::DataCallback();
23
- gatherOutput = boost::bind(&ApplicationPool2_SmartSpawnerTest::_gatherOutput, this, _1, _2);
24
- setLogLevel(LVL_ERROR); // TODO: should be LVL_WARN
25
- setPrintAppOutputAsDebuggingMessages(true);
26
- }
27
-
28
- ~ApplicationPool2_SmartSpawnerTest() {
29
- setLogLevel(DEFAULT_LOG_LEVEL);
30
- setPrintAppOutputAsDebuggingMessages(false);
31
- unlink("stub/wsgi/passenger_wsgi.pyc");
32
- PipeWatcher::onData = PipeWatcher::DataCallback();
33
- }
34
-
35
- boost::shared_ptr<SmartSpawner> createSpawner(const Options &options, bool exitImmediately = false) {
36
- char buf[PATH_MAX + 1];
37
- getcwd(buf, PATH_MAX);
38
-
39
- vector<string> command;
40
- command.push_back("ruby");
41
- command.push_back(string(buf) + "/support/placebo-preloader.rb");
42
- if (exitImmediately) {
43
- command.push_back("exit-immediately");
44
- }
45
-
46
- return boost::make_shared<SmartSpawner>(command,
47
- options, createSpawnerConfig());
48
- }
49
-
50
- SpawnerConfigPtr createSpawnerConfig() {
51
- SpawnerConfigPtr config = boost::make_shared<SpawnerConfig>();
52
- config->resourceLocator = resourceLocator;
53
- config->finalize();
54
- return config;
55
- }
56
-
57
- Options createOptions() {
58
- Options options;
59
- options.spawnMethod = "smart";
60
- options.loadShellEnvvars = false;
61
- return options;
62
- }
63
-
64
- void _gatherOutput(const char *data, unsigned int size) {
65
- boost::lock_guard<boost::mutex> l(gatheredOutputSyncher);
66
- gatheredOutput.append(data, size);
67
- }
68
- };
69
-
70
- DEFINE_TEST_GROUP_WITH_LIMIT(ApplicationPool2_SmartSpawnerTest, 90);
71
-
72
- #include "SpawnerTestCases.cpp"
73
-
74
- TEST_METHOD(80) {
75
- // If the preloader has crashed then SmartSpawner will
76
- // restart it and try again.
77
- Options options = createOptions();
78
- options.appRoot = "stub/rack";
79
- options.startCommand = "ruby\t" "start.rb";
80
- options.startupFile = "start.rb";
81
- boost::shared_ptr<SmartSpawner> spawner = createSpawner(options);
82
- setLogLevel(LVL_CRIT);
83
- object = spawner->spawn(options);
84
- object.process->requiresShutdown = false;
85
-
86
- kill(spawner->getPreloaderPid(), SIGTERM);
87
- // Give it some time to exit.
88
- usleep(300000);
89
-
90
- // No exception at next spawn.
91
- object = spawner->spawn(options);
92
- object.process->requiresShutdown = false;
93
- }
94
-
95
- TEST_METHOD(81) {
96
- // If the preloader still crashes after the restart then
97
- // SmartSpawner will throw an exception.
98
- Options options = createOptions();
99
- options.appRoot = "stub/rack";
100
- options.startCommand = "ruby\t" "start.rb";
101
- options.startupFile = "start.rb";
102
- setLogLevel(LVL_CRIT);
103
- boost::shared_ptr<SmartSpawner> spawner = createSpawner(options, true);
104
- try {
105
- object = spawner->spawn(options);
106
- object.process->requiresShutdown = false;
107
- fail("SpawnException expected");
108
- } catch (const SpawnException &) {
109
- // Pass.
110
- }
111
- }
112
-
113
- TEST_METHOD(82) {
114
- // If the preloader didn't start within the timeout
115
- // then it's killed and an exception is thrown, with
116
- // whatever stderr output as error page.
117
- Options options = createOptions();
118
- options.appRoot = "stub/rack";
119
- options.startCommand = "ruby\t" "start.rb";
120
- options.startupFile = "start.rb";
121
- options.startTimeout = 100;
122
-
123
- vector<string> preloaderCommand;
124
- preloaderCommand.push_back("bash");
125
- preloaderCommand.push_back("-c");
126
- preloaderCommand.push_back("echo hello world >&2; sleep 60");
127
- SmartSpawner spawner(preloaderCommand, options, createSpawnerConfig());
128
- setLogLevel(LVL_CRIT);
129
-
130
- try {
131
- object = spawner.spawn(options);
132
- object.process->requiresShutdown = false;
133
- fail("SpawnException expected");
134
- } catch (const SpawnException &e) {
135
- ensure_equals(e.getErrorKind(),
136
- SpawnException::PRELOADER_STARTUP_TIMEOUT);
137
- if (e.getErrorPage().find("hello world\n") == string::npos) {
138
- // This might be caused by the machine being too slow.
139
- // Try again with a higher timeout.
140
- options.startTimeout = 1000;
141
- SmartSpawner spawner2(preloaderCommand, options, createSpawnerConfig());
142
- try {
143
- object = spawner2.spawn(options);
144
- object.process->requiresShutdown = false;
145
- fail("SpawnException expected");
146
- } catch (const SpawnException &e2) {
147
- ensure_equals(e2.getErrorKind(),
148
- SpawnException::PRELOADER_STARTUP_TIMEOUT);
149
- if (e2.getErrorPage().find("hello world\n") == string::npos) {
150
- fail(("Unexpected error page:\n" + e2.getErrorPage()).c_str());
151
- }
152
- }
153
- }
154
- }
155
- }
156
-
157
- TEST_METHOD(83) {
158
- // If the preloader crashed during startup without returning
159
- // a proper error response, then its stderr output is used
160
- // as error response instead.
161
- Options options = createOptions();
162
- options.appRoot = "stub/rack";
163
- options.startCommand = "ruby\t" "start.rb";
164
- options.startupFile = "start.rb";
165
-
166
- vector<string> preloaderCommand;
167
- preloaderCommand.push_back("bash");
168
- preloaderCommand.push_back("-c");
169
- preloaderCommand.push_back("echo hello world >&2");
170
- SmartSpawner spawner(preloaderCommand, options, createSpawnerConfig());
171
- setLogLevel(LVL_CRIT);
172
-
173
- try {
174
- object = spawner.spawn(options);
175
- object.process->requiresShutdown = false;
176
- fail("SpawnException expected");
177
- } catch (const SpawnException &e) {
178
- ensure_equals(e.getErrorKind(),
179
- SpawnException::PRELOADER_STARTUP_ERROR);
180
- ensure(e.getErrorPage().find("hello world\n") != string::npos);
181
- }
182
- }
183
-
184
- TEST_METHOD(84) {
185
- // If the preloader encountered an error, then the resulting SpawnException
186
- // takes note of the process's environment variables.
187
- string envvars = modp::b64_encode("PASSENGER_FOO\0foo\0",
188
- sizeof("PASSENGER_FOO\0foo\0") - 1);
189
- Options options = createOptions();
190
- options.appRoot = "stub/rack";
191
- options.startCommand = "ruby\t" "start.rb";
192
- options.startupFile = "start.rb";
193
- options.environmentVariables = envvars;
194
-
195
- vector<string> preloaderCommand;
196
- preloaderCommand.push_back("bash");
197
- preloaderCommand.push_back("-c");
198
- preloaderCommand.push_back("echo hello world >&2");
199
- SmartSpawner spawner(preloaderCommand, options, createSpawnerConfig());
200
- setLogLevel(LVL_CRIT);
201
-
202
- try {
203
- object = spawner.spawn(options);
204
- object.process->requiresShutdown = false;
205
- fail("SpawnException expected");
206
- } catch (const SpawnException &e) {
207
- ensure(containsSubstring(e["envvars"], "PASSENGER_FOO=foo\n"));
208
- }
209
- }
210
-
211
- TEST_METHOD(85) {
212
- // Test that the spawned process can still write to its stderr
213
- // after the SmartSpawner has been destroyed.
214
- DeleteFileEventually d("tmp.output");
215
- PipeWatcher::onData = gatherOutput;
216
- Options options = createOptions();
217
- options.appRoot = "stub/rack";
218
-
219
- {
220
- vector<string> preloaderCommand;
221
- preloaderCommand.push_back("ruby");
222
- preloaderCommand.push_back(resourceLocator->getHelperScriptsDir() + "/rack-preloader.rb");
223
- SmartSpawner spawner(preloaderCommand, options, createSpawnerConfig());
224
- object = spawner.spawn(options);
225
- object.process->requiresShutdown = false;
226
- }
227
-
228
- SessionPtr session = object.process->newSession();
229
- session->initiate();
230
-
231
- const char header[] =
232
- "REQUEST_METHOD\0GET\0"
233
- "PATH_INFO\0/print_stderr\0";
234
-
235
- writeScalarMessage(session->fd(), header, sizeof(header) - 1);
236
- shutdown(session->fd(), SHUT_WR);
237
- readAll(session->fd());
238
- EVENTUALLY(2,
239
- boost::lock_guard<boost::mutex> l(gatheredOutputSyncher);
240
- result = gatheredOutput.find("hello world!\n") != string::npos;
241
- );
242
- }
243
- }
@@ -1,823 +0,0 @@
1
- // Included in DirectSpawnerTest.cpp and SmartSpawnerTest.cpp.
2
-
3
- #define SETUP_USER_SWITCHING_TEST(code) \
4
- if (geteuid() != 0) { \
5
- return; \
6
- } \
7
- TempDirCopy copy("stub/wsgi", "tmp.wsgi"); \
8
- addUserSwitchingCode(); \
9
- \
10
- DeleteFileEventually info1("/tmp/info.txt"); \
11
- DeleteFileEventually info2("/tmp/info2.txt"); \
12
- \
13
- SpawnerPtr spawner; \
14
- Options options; \
15
- options = createOptions(); \
16
- options.appRoot = "tmp.wsgi"; \
17
- options.appType = "wsgi"; \
18
- options.defaultUser = testConfig["default_user"].asCString(); \
19
- options.defaultGroup = testConfig["default_group"].asCString(); \
20
- code \
21
- spawner = createSpawner(options)
22
-
23
- #define RUN_USER_SWITCHING_TEST() \
24
- object = spawner->spawn(options); \
25
- object.process->requiresShutdown = false; \
26
- BufferedIO io(FileDescriptor(open("/tmp/info.txt", O_RDONLY))); \
27
- uid_t uid = (uid_t) atol(io.readLine().c_str()); \
28
- gid_t gid = (gid_t) atol(io.readLine().c_str()); \
29
- string groups = strip(io.readLine()); \
30
- /* Avoid compiler warning. */ \
31
- (void) uid; (void) gid; (void) groups
32
-
33
- typedef boost::shared_ptr<Spawner> SpawnerPtr;
34
-
35
- static void addUserSwitchingCode() {
36
- FILE *f = fopen("tmp.wsgi/passenger_wsgi.py", "a");
37
- fputs(
38
- "\n"
39
- "import os\n"
40
- "f = open('/tmp/info.txt', 'w')\n"
41
- "f.write(str(os.getuid()) + '\\n')\n"
42
- "f.write(str(os.getgid()) + '\\n')\n"
43
- "f.write(os.popen('groups').read() + '\\n')\n"
44
- "f.close()\n",
45
- f);
46
- fclose(f);
47
-
48
- rename("tmp.wsgi/passenger_wsgi.py", "tmp.wsgi/passenger_wsgi.py.real");
49
- symlink("passenger_wsgi.py.real", "tmp.wsgi/passenger_wsgi.py");
50
- }
51
-
52
- static void checkin(ProcessPtr process, Connection *conn) {
53
- process->sockets.front().checkinConnection(*conn);
54
- }
55
-
56
- static string userNameForUid(uid_t uid) {
57
- return getpwuid(uid)->pw_name;
58
- }
59
-
60
- static string groupNameForGid(gid_t gid) {
61
- return getgrgid(gid)->gr_name;
62
- }
63
-
64
- static uid_t uidFor(const string &userName) {
65
- return getpwnam(userName.c_str())->pw_uid;
66
- }
67
-
68
- static gid_t gidFor(const string &groupName) {
69
- return getgrnam(groupName.c_str())->gr_gid;
70
- }
71
-
72
- static string primaryGroupFor(const string &userName) {
73
- gid_t gid = getpwnam(userName.c_str())->pw_gid;
74
- return getgrgid(gid)->gr_name;
75
- }
76
-
77
- TEST_METHOD(1) {
78
- // Basic spawning test.
79
- Options options = createOptions();
80
- options.appRoot = "stub/rack";
81
- options.startCommand = "ruby\t" "start.rb";
82
- options.startupFile = "start.rb";
83
- SpawnerPtr spawner = createSpawner(options);
84
- object = spawner->spawn(options);
85
- object.process->requiresShutdown = false;
86
- ensure_equals(object.process->sockets.size(), 1u);
87
-
88
- Connection conn = object.process->sockets.front().checkoutConnection();
89
- ScopeGuard guard(boost::bind(checkin, object.process, &conn));
90
- writeExact(conn.fd, "ping\n");
91
- ensure_equals(readAll(conn.fd), "pong\n");
92
- }
93
-
94
- TEST_METHOD(2) {
95
- // It enforces the given start timeout.
96
- Options options = createOptions();
97
- options.appRoot = "stub";
98
- options.startCommand = "sleep\t" "60";
99
- options.startupFile = ".";
100
- options.startTimeout = 300;
101
- SpawnerPtr spawner = createSpawner(options);
102
- setLogLevel(LVL_CRIT);
103
- try {
104
- object = spawner->spawn(options);
105
- object.process->requiresShutdown = false;
106
- fail("Timeout expected");
107
- } catch (const SpawnException &e) {
108
- ensure_equals(e.getErrorKind(),
109
- SpawnException::APP_STARTUP_TIMEOUT);
110
- }
111
- }
112
-
113
- TEST_METHOD(3) {
114
- // Any protocol errors during startup are caught and result
115
- // in exceptions.
116
- Options options = createOptions();
117
- options.appRoot = "stub";
118
- options.startCommand = "echo\t" "!> hello world";
119
- options.startupFile = ".";
120
- SpawnerPtr spawner = createSpawner(options);
121
- setLogLevel(LVL_CRIT);
122
- try {
123
- object = spawner->spawn(options);
124
- object.process->requiresShutdown = false;
125
- fail("Exception expected");
126
- } catch (const SpawnException &e) {
127
- ensure_equals(e.getErrorKind(),
128
- SpawnException::APP_STARTUP_PROTOCOL_ERROR);
129
- }
130
- }
131
-
132
- TEST_METHOD(4) {
133
- // The application may respond with a special Error response,
134
- // which will result in a SpawnException with the content.
135
- Options options = createOptions();
136
- options.appRoot = "stub";
137
- options.startCommand = "perl\t" "start_error.pl";
138
- options.startupFile = "start_error.pl";
139
- SpawnerPtr spawner = createSpawner(options);
140
- setLogLevel(LVL_CRIT);
141
- try {
142
- object = spawner->spawn(options);
143
- object.process->requiresShutdown = false;
144
- fail("SpawnException expected");
145
- } catch (const SpawnException &e) {
146
- ensure_equals(e.getErrorKind(),
147
- SpawnException::APP_STARTUP_EXPLAINABLE_ERROR);
148
- ensure_equals(e.getErrorPage(),
149
- "He's dead, Jim!\n"
150
- "Relax, I'm a doctor.\n");
151
- }
152
- }
153
-
154
- TEST_METHOD(5) {
155
- // The start timeout is enforced even while reading the error
156
- // response.
157
- Options options = createOptions();
158
- options.appRoot = "stub";
159
- options.startCommand = "perl\t" "start_error.pl\t" "freeze";
160
- options.startupFile = "start_error.pl";
161
- options.startTimeout = 300;
162
- SpawnerPtr spawner = createSpawner(options);
163
- setLogLevel(LVL_CRIT);
164
- try {
165
- object = spawner->spawn(options);
166
- object.process->requiresShutdown = false;
167
- fail("Timeout expected");
168
- } catch (const SpawnException &e) {
169
- ensure_equals(e.getErrorKind(),
170
- SpawnException::APP_STARTUP_TIMEOUT);
171
- }
172
- }
173
-
174
- TEST_METHOD(6) {
175
- // The reported PID is correct.
176
- Options options = createOptions();
177
- options.appRoot = "stub/rack";
178
- options.startCommand = "ruby\t" "start.rb";
179
- options.startupFile = "start.rb";
180
- SpawnerPtr spawner = createSpawner(options);
181
- object = spawner->spawn(options);
182
- object.process->requiresShutdown = false;
183
- ensure_equals(object.process->sockets.size(), 1u);
184
-
185
- Connection conn = object.process->sockets.front().checkoutConnection();
186
- ScopeGuard guard(boost::bind(checkin, object.process, &conn));
187
- writeExact(conn.fd, "pid\n");
188
- ensure_equals(readAll(conn.fd), toString(object.process->pid) + "\n");
189
- }
190
-
191
- TEST_METHOD(7) {
192
- // Custom environment variables can be passed.
193
- string envvars = modp::b64_encode("PASSENGER_FOO\0foo\0PASSENGER_BAR\0bar\0",
194
- sizeof("PASSENGER_FOO\0foo\0PASSENGER_BAR\0bar\0") - 1);
195
- Options options = createOptions();
196
- options.appRoot = "stub/rack";
197
- options.startCommand = "ruby\t" "start.rb";
198
- options.startupFile = "start.rb";
199
- options.environmentVariables = envvars;
200
- SpawnerPtr spawner = createSpawner(options);
201
- object = spawner->spawn(options);
202
- object.process->requiresShutdown = false;
203
- ensure_equals(object.process->sockets.size(), 1u);
204
-
205
- Connection conn = object.process->sockets.front().checkoutConnection();
206
- ScopeGuard guard(boost::bind(checkin, object.process, &conn));
207
- writeExact(conn.fd, "envvars\n");
208
- envvars = readAll(conn.fd);
209
- ensure("(1)", envvars.find("PASSENGER_FOO = foo\n") != string::npos);
210
- ensure("(2)", envvars.find("PASSENGER_BAR = bar\n") != string::npos);
211
- }
212
-
213
- TEST_METHOD(8) {
214
- // Any raised SpawnExceptions take note of the process's environment variables.
215
- string envvars = modp::b64_encode("PASSENGER_FOO\0foo\0",
216
- sizeof("PASSENGER_FOO\0foo\0") - 1);
217
- Options options = createOptions();
218
- options.appRoot = "stub";
219
- options.startCommand = "echo\t" "!> hello world";
220
- options.startupFile = ".";
221
- options.environmentVariables = envvars;
222
- SpawnerPtr spawner = createSpawner(options);
223
- setLogLevel(LVL_CRIT);
224
- try {
225
- object = spawner->spawn(options);
226
- object.process->requiresShutdown = false;
227
- fail("Exception expected");
228
- } catch (const SpawnException &e) {
229
- ensure(containsSubstring(e["envvars"], "PASSENGER_FOO=foo\n"));
230
- }
231
- }
232
-
233
- TEST_METHOD(9) {
234
- // It raises an exception if the user does not have a access to one
235
- // of the app root's parent directories, or the app root itself.
236
- runShellCommand("mkdir -p tmp.check/a/b/c");
237
- TempDirCopy dir("stub/rack", "tmp.check/a/b/c/d");
238
- TempDir dir2("tmp.check");
239
-
240
- char buffer[PATH_MAX];
241
- string cwd = getcwd(buffer, sizeof(buffer));
242
-
243
- Options options = createOptions();
244
- options.appRoot = "tmp.check/a/b/c/d";
245
- options.appType = "rack";
246
- SpawnerPtr spawner = createSpawner(options);
247
- setLogLevel(LVL_CRIT);
248
-
249
- if (getuid() != 0) {
250
- // TODO: implement this test for root too
251
- runShellCommand("chmod 000 tmp.check/a/b/c/d");
252
- runShellCommand("chmod 600 tmp.check/a/b/c");
253
- runShellCommand("chmod 600 tmp.check/a");
254
-
255
- try {
256
- object = spawner->spawn(options);
257
- object.process->requiresShutdown = false;
258
- fail("SpawnException expected");
259
- } catch (const SpawnException &e) {
260
- ensure("(1)", containsSubstring(e.getErrorPage(),
261
- "the parent directory '" + cwd + "/tmp.check/a' has wrong permissions"));
262
- }
263
-
264
- runShellCommand("chmod 700 tmp.check/a");
265
- try {
266
- object = spawner->spawn(options);
267
- object.process->requiresShutdown = false;
268
- fail("SpawnException expected");
269
- } catch (const SpawnException &e) {
270
- ensure("(2)", containsSubstring(e.getErrorPage(),
271
- "the parent directory '" + cwd + "/tmp.check/a/b/c' has wrong permissions"));
272
- }
273
-
274
- runShellCommand("chmod 700 tmp.check/a/b/c");
275
- try {
276
- object = spawner->spawn(options);
277
- object.process->requiresShutdown = false;
278
- fail("SpawnException expected");
279
- } catch (const SpawnException &e) {
280
- ensure("(3)", containsSubstring(e.getErrorPage(),
281
- "However this directory is not accessible because it has wrong permissions."));
282
- }
283
-
284
- runShellCommand("chmod 700 tmp.check/a/b/c/d");
285
- object = spawner->spawn(options); // Should not throw.
286
- object.process->requiresShutdown = false;
287
- }
288
- }
289
-
290
- TEST_METHOD(10) {
291
- // It forwards all stdout and stderr output, even after the corresponding
292
- // Process object has been destroyed.
293
- DeleteFileEventually d("tmp.output");
294
- PipeWatcher::onData = gatherOutput;
295
-
296
- Options options = createOptions();
297
- options.appRoot = "stub/rack";
298
- options.appType = "rack";
299
- SpawnerPtr spawner = createSpawner(options);
300
- object = spawner->spawn(options);
301
- object.process->requiresShutdown = false;
302
-
303
- SessionPtr session = object.process->newSession();
304
- session->initiate();
305
-
306
- setLogLevel(LVL_ERROR); // TODO: should be LVL_WARN
307
- const char header[] =
308
- "REQUEST_METHOD\0GET\0"
309
- "PATH_INFO\0/print_stdout_and_stderr\0";
310
-
311
- writeScalarMessage(session->fd(), StaticString(header, sizeof(header) - 1));
312
- shutdown(session->fd(), SHUT_WR);
313
- readAll(session->fd());
314
- session->close(true);
315
- session.reset();
316
- object.process.reset();
317
-
318
- EVENTUALLY(2,
319
- boost::lock_guard<boost::mutex> l(gatheredOutputSyncher);
320
- result = gatheredOutput.find("hello stdout!\n") != string::npos
321
- && gatheredOutput.find("hello stderr!\n") != string::npos;
322
- );
323
- }
324
-
325
- TEST_METHOD(11) {
326
- // It infers the code revision from the REVISION file.
327
- TempDirCopy dir("stub/rack", "tmp.rack");
328
- createFile("tmp.rack/REVISION", "hello\n");
329
-
330
- Options options = createOptions();
331
- options.appRoot = "tmp.rack";
332
- options.startCommand = "ruby\t" "start.rb";
333
- options.startupFile = "start.rb";
334
- SpawnerPtr spawner = createSpawner(options);
335
- object = spawner->spawn(options);
336
- object.process->requiresShutdown = false;
337
-
338
- ensure_equals(object.process->codeRevision, "hello");
339
- }
340
-
341
- TEST_METHOD(12) {
342
- // It infers the code revision from the app root symlink,
343
- // if the app root is called "current".
344
- TempDir dir1("tmp.rack");
345
- TempDirCopy dir2("stub/rack", "tmp.rack/today");
346
- symlink("today", "tmp.rack/current");
347
-
348
- Options options = createOptions();
349
- options.appRoot = "tmp.rack/current";
350
- options.startCommand = "ruby\t" "start.rb";
351
- options.startupFile = "start.rb";
352
- SpawnerPtr spawner = createSpawner(options);
353
- object = spawner->spawn(options);
354
- object.process->requiresShutdown = false;
355
-
356
- ensure_equals(object.process->codeRevision, "today");
357
- }
358
-
359
- // It raises an exception if getStartupCommand() is empty.
360
-
361
- /******* User switching tests *******/
362
-
363
- // If 'user' is set
364
- // and 'user' is 'root'
365
- TEST_METHOD(20) {
366
- // It changes the user to the value of 'defaultUser'.
367
- SETUP_USER_SWITCHING_TEST(
368
- options.user = "root";
369
- );
370
- RUN_USER_SWITCHING_TEST();
371
- ensure_equals(userNameForUid(uid), testConfig["default_user"]);
372
- }
373
-
374
- TEST_METHOD(21) {
375
- // If 'group' is given, it changes group to the given group name.
376
- SETUP_USER_SWITCHING_TEST(
377
- options.user = "root";
378
- options.group = testConfig["normal_group_1"].asCString();
379
- );
380
- RUN_USER_SWITCHING_TEST();
381
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_1"].asString());
382
- }
383
-
384
- TEST_METHOD(22) {
385
- // If 'group' is set to the root group, it changes group to defaultGroup.
386
- string rootGroup = groupNameForGid(0);
387
- SETUP_USER_SWITCHING_TEST(
388
- options.user = "root";
389
- options.group = rootGroup.c_str();
390
- );
391
- RUN_USER_SWITCHING_TEST();
392
- ensure_equals(groupNameForGid(gid), testConfig["default_group"].asString());
393
- }
394
-
395
- // and 'group' is set to '!STARTUP_FILE!'"
396
- TEST_METHOD(23) {
397
- // It changes the group to the startup file's group.
398
- SETUP_USER_SWITCHING_TEST(
399
- options.user = "root";
400
- options.group = "!STARTUP_FILE!";
401
- );
402
- lchown("tmp.wsgi/passenger_wsgi.py",
403
- (uid_t) -1,
404
- gidFor(testConfig["normal_group_1"].asString()));
405
- RUN_USER_SWITCHING_TEST();
406
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_1"].asString());
407
- }
408
-
409
- TEST_METHOD(24) {
410
- // If the startup file is a symlink, then it uses the symlink's group, not the target's group
411
- SETUP_USER_SWITCHING_TEST(
412
- options.user = "root";
413
- options.group = "!STARTUP_FILE!";
414
- );
415
- lchown("tmp.wsgi/passenger_wsgi.py",
416
- (uid_t) -1,
417
- gidFor(testConfig["normal_group_2"].asString()));
418
- chown("tmp.wsgi/passenger_wsgi.py.real",
419
- (uid_t) -1,
420
- gidFor(testConfig["normal_group_1"].asString()));
421
- RUN_USER_SWITCHING_TEST();
422
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_2"].asString());
423
- }
424
-
425
- TEST_METHOD(25) {
426
- // If 'group' is not given, it changes the group to defaultUser's primary group.
427
- SETUP_USER_SWITCHING_TEST(
428
- options.user = "root";
429
- );
430
- RUN_USER_SWITCHING_TEST();
431
- ensure_equals(groupNameForGid(gid),
432
- primaryGroupFor(testConfig["default_user"].asString()));
433
- }
434
-
435
- // and 'user' is not 'root'
436
- TEST_METHOD(29) {
437
- // It changes the user to the given username.
438
- SETUP_USER_SWITCHING_TEST(
439
- options.user = testConfig["normal_user_1"].asCString();
440
- );
441
- RUN_USER_SWITCHING_TEST();
442
- ensure_equals(userNameForUid(uid), testConfig["normal_user_1"].asString());
443
- }
444
-
445
- TEST_METHOD(30) {
446
- // If 'group' is given, it changes group to the given group name.
447
- // It changes the user to the given username.
448
- SETUP_USER_SWITCHING_TEST(
449
- options.user = testConfig["normal_user_1"].asCString();
450
- options.group = testConfig["normal_group_1"].asCString();
451
- );
452
- RUN_USER_SWITCHING_TEST();
453
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_1"].asString());
454
- }
455
-
456
- TEST_METHOD(31) {
457
- // If 'group' is set to the root group, it changes group to defaultGroup.
458
- // It changes the user to the given username.
459
- string rootGroup = groupNameForGid(0);
460
- SETUP_USER_SWITCHING_TEST(
461
- options.user = testConfig["normal_user_1"].asCString();
462
- options.group = rootGroup.c_str();
463
- );
464
- RUN_USER_SWITCHING_TEST();
465
- ensure_equals(groupNameForGid(gid), testConfig["default_group"].asString());
466
- }
467
-
468
- // and 'group' is set to '!STARTUP_FILE!'
469
- TEST_METHOD(32) {
470
- // It changes the group to the startup file's group.
471
- SETUP_USER_SWITCHING_TEST(
472
- options.user = testConfig["normal_user_1"].asCString();
473
- options.group = "!STARTUP_FILE!";
474
- );
475
- lchown("tmp.wsgi/passenger_wsgi.py",
476
- (uid_t) -1,
477
- gidFor(testConfig["normal_group_1"].asString()));
478
- RUN_USER_SWITCHING_TEST();
479
- ensure_equals(groupNameForGid(gid),
480
- testConfig["normal_group_1"].asString());
481
- }
482
-
483
- TEST_METHOD(33) {
484
- // If the startup file is a symlink, then it uses the
485
- // symlink's group, not the target's group.
486
- SETUP_USER_SWITCHING_TEST(
487
- options.user = testConfig["normal_user_1"].asCString();
488
- options.group = "!STARTUP_FILE!";
489
- );
490
- lchown("tmp.wsgi/passenger_wsgi.py",
491
- (uid_t) -1,
492
- gidFor(testConfig["normal_group_2"].asString()));
493
- chown("tmp.wsgi/passenger_wsgi.py.real",
494
- (uid_t) -1,
495
- gidFor(testConfig["normal_group_1"].asString()));
496
- RUN_USER_SWITCHING_TEST();
497
- ensure_equals(groupNameForGid(gid),
498
- testConfig["normal_group_2"].asString());
499
- }
500
-
501
- TEST_METHOD(34) {
502
- // If 'group' is not given, it changes the group to the user's primary group.
503
- SETUP_USER_SWITCHING_TEST(
504
- options.user = testConfig["normal_user_1"].asCString();
505
- );
506
- RUN_USER_SWITCHING_TEST();
507
- ensure_equals(groupNameForGid(gid),
508
- primaryGroupFor(testConfig["normal_user_1"].asString()));
509
- }
510
-
511
- // and the given username does not exist
512
- TEST_METHOD(38) {
513
- // It changes the user to the value of defaultUser.
514
- SETUP_USER_SWITCHING_TEST(
515
- options.user = testConfig["nonexistant_user"].asCString();
516
- );
517
- RUN_USER_SWITCHING_TEST();
518
- ensure_equals(userNameForUid(uid), testConfig["default_user"].asString());
519
- }
520
-
521
- TEST_METHOD(39) {
522
- // If 'group' is given, it changes group to the given group name.
523
- SETUP_USER_SWITCHING_TEST(
524
- options.user = testConfig["nonexistant_user"].asCString();
525
- options.group = testConfig["normal_group_1"].asCString();
526
- );
527
- RUN_USER_SWITCHING_TEST();
528
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_1"].asString());
529
- }
530
-
531
- TEST_METHOD(40) {
532
- // If 'group' is set to the root group, it changes group to defaultGroup.
533
- string rootGroup = groupNameForGid(0);
534
- SETUP_USER_SWITCHING_TEST(
535
- options.user = testConfig["nonexistant_user"].asCString();
536
- options.group = rootGroup;
537
- );
538
- RUN_USER_SWITCHING_TEST();
539
- ensure_equals(groupNameForGid(gid), testConfig["default_group"].asString());
540
- }
541
-
542
- // and 'group' is set to '!STARTUP_FILE!'
543
- TEST_METHOD(41) {
544
- // It changes the group to the startup file's group.
545
- SETUP_USER_SWITCHING_TEST(
546
- options.user = testConfig["nonexistant_user"].asCString();
547
- options.group = "!STARTUP_FILE!";
548
- );
549
- lchown("tmp.wsgi/passenger_wsgi.py",
550
- (uid_t) -1,
551
- gidFor(testConfig["normal_group_1"].asString()));
552
- RUN_USER_SWITCHING_TEST();
553
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_1"].asString());
554
- }
555
-
556
- TEST_METHOD(42) {
557
- // If the startup file is a symlink, then it uses the
558
- // symlink's group, not the target's group.
559
- SETUP_USER_SWITCHING_TEST(
560
- options.user = testConfig["nonexistant_user"].asCString();
561
- options.group = "!STARTUP_FILE!";
562
- );
563
- lchown("tmp.wsgi/passenger_wsgi.py",
564
- (uid_t) -1,
565
- gidFor(testConfig["normal_group_2"].asString()));
566
- chown("tmp.wsgi/passenger_wsgi.py.real",
567
- (uid_t) -1,
568
- gidFor(testConfig["normal_group_1"].asString()));
569
- RUN_USER_SWITCHING_TEST();
570
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_2"].asString());
571
- }
572
-
573
- TEST_METHOD(43) {
574
- // If 'group' is not given, it changes the group to defaultUser's primary group.
575
- SETUP_USER_SWITCHING_TEST(
576
- options.user = testConfig["nonexistant_user"].asCString();
577
- );
578
- RUN_USER_SWITCHING_TEST();
579
- ensure_equals(groupNameForGid(gid),
580
- primaryGroupFor(testConfig["default_user"].asString()));
581
- }
582
-
583
- // If 'user' is not set
584
- // and the startup file's owner exists
585
- TEST_METHOD(47) {
586
- // It changes the user to the owner of the startup file.
587
- SETUP_USER_SWITCHING_TEST(
588
- (void) 0;
589
- );
590
- lchown("tmp.wsgi/passenger_wsgi.py",
591
- uidFor(testConfig["normal_user_1"].asString()),
592
- (gid_t) -1);
593
- RUN_USER_SWITCHING_TEST();
594
- ensure_equals(userNameForUid(uid), testConfig["normal_user_1"].asString());
595
- }
596
-
597
- TEST_METHOD(48) {
598
- // If the startup file is a symlink, then it uses the symlink's owner, not the target's owner.
599
- SETUP_USER_SWITCHING_TEST(
600
- (void) 0;
601
- );
602
- lchown("tmp.wsgi/passenger_wsgi.py",
603
- uidFor(testConfig["normal_user_2"].asString()),
604
- (gid_t) -1);
605
- chown("tmp.wsgi/passenger_wsgi.py.real",
606
- uidFor(testConfig["normal_user_1"].asString()),
607
- (gid_t) -1);
608
- RUN_USER_SWITCHING_TEST();
609
- ensure_equals(userNameForUid(uid), testConfig["normal_user_2"].asString());
610
- }
611
-
612
- TEST_METHOD(49) {
613
- // If 'group' is given, it changes group to the given group name.
614
- SETUP_USER_SWITCHING_TEST(
615
- options.group = testConfig["normal_group_1"].asCString();
616
- );
617
- lchown("tmp.wsgi/passenger_wsgi.py",
618
- uidFor(testConfig["normal_user_1"].asString()),
619
- (gid_t) -1);
620
- RUN_USER_SWITCHING_TEST();
621
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_1"].asString());
622
- }
623
-
624
- TEST_METHOD(50) {
625
- // If 'group' is set to the root group, it changes group to defaultGroup.
626
- string rootGroup = groupNameForGid(0);
627
- SETUP_USER_SWITCHING_TEST(
628
- options.group = rootGroup;
629
- );
630
- lchown("tmp.wsgi/passenger_wsgi.py",
631
- uidFor(testConfig["normal_user_1"].asString()),
632
- (gid_t) -1);
633
- RUN_USER_SWITCHING_TEST();
634
- ensure_equals(groupNameForGid(gid), testConfig["default_group"].asString());
635
- }
636
-
637
- // and 'group' is set to '!STARTUP_FILE!'
638
- TEST_METHOD(51) {
639
- // It changes the group to the startup file's group.
640
- SETUP_USER_SWITCHING_TEST(
641
- options.group = "!STARTUP_FILE!";
642
- );
643
- lchown("tmp.wsgi/passenger_wsgi.py",
644
- (uid_t) -1,
645
- gidFor(testConfig["normal_group_1"].asString()));
646
- RUN_USER_SWITCHING_TEST();
647
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_1"].asString());
648
- }
649
-
650
- TEST_METHOD(52) {
651
- // If the startup file is a symlink, then it uses the symlink's
652
- // group, not the target's group.
653
- SETUP_USER_SWITCHING_TEST(
654
- options.group = "!STARTUP_FILE!";
655
- );
656
- lchown("tmp.wsgi/passenger_wsgi.py",
657
- (uid_t) -1,
658
- gidFor(testConfig["normal_group_2"].asString()));
659
- chown("tmp.wsgi/passenger_wsgi.py.real",
660
- (uid_t) -1,
661
- gidFor(testConfig["normal_group_1"].asString()));
662
- RUN_USER_SWITCHING_TEST();
663
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_2"].asString());
664
- }
665
-
666
- TEST_METHOD(53) {
667
- // If 'group' is not given, it changes the group to the startup file's owner's primary group.
668
- SETUP_USER_SWITCHING_TEST(
669
- (void) 0;
670
- );
671
- lchown("tmp.wsgi/passenger_wsgi.py",
672
- uidFor(testConfig["normal_user_1"].asString()),
673
- (gid_t) -1);
674
- RUN_USER_SWITCHING_TEST();
675
- ensure_equals(groupNameForGid(gid),
676
- primaryGroupFor(testConfig["normal_user_1"].asString()));
677
- }
678
-
679
- // and the startup file's owner doesn't exist
680
- TEST_METHOD(57) {
681
- // It changes the user to the value of defaultUser.
682
- SETUP_USER_SWITCHING_TEST(
683
- (void) 0;
684
- );
685
- lchown("tmp.wsgi/passenger_wsgi.py",
686
- (uid_t) testConfig["nonexistant_uid"].asInt64(),
687
- (gid_t) -1);
688
- RUN_USER_SWITCHING_TEST();
689
- ensure_equals(userNameForUid(uid), testConfig["default_user"].asString());
690
- }
691
-
692
- TEST_METHOD(58) {
693
- // If 'group' is given, it changes group to the given group name.
694
- SETUP_USER_SWITCHING_TEST(
695
- options.group = testConfig["normal_group_1"].asCString();
696
- );
697
- lchown("tmp.wsgi/passenger_wsgi.py",
698
- (uid_t) testConfig["nonexistant_uid"].asInt64(),
699
- (gid_t) -1);
700
- RUN_USER_SWITCHING_TEST();
701
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_1"].asString());
702
- }
703
-
704
- TEST_METHOD(59) {
705
- // If 'group' is set to the root group, it changes group to defaultGroup.
706
- string rootGroup = groupNameForGid(0);
707
- SETUP_USER_SWITCHING_TEST(
708
- options.group = rootGroup;
709
- );
710
- lchown("tmp.wsgi/passenger_wsgi.py",
711
- (uid_t) testConfig["nonexistant_uid"].asInt64(),
712
- (gid_t) -1);
713
- RUN_USER_SWITCHING_TEST();
714
- ensure_equals(groupNameForGid(gid), testConfig["default_group"].asString());
715
- }
716
-
717
- // and 'group' is set to '!STARTUP_FILE!'
718
- // and the startup file's group doesn't exist
719
- TEST_METHOD(60) {
720
- // It changes the group to the value given by defaultGroup.
721
- SETUP_USER_SWITCHING_TEST(
722
- options.group = "!STARTUP_FILE!";
723
- );
724
- lchown("tmp.wsgi/passenger_wsgi.py",
725
- (uid_t) testConfig["nonexistant_uid"].asInt64(),
726
- (gid_t) testConfig["nonexistant_gid"].asInt64());
727
- RUN_USER_SWITCHING_TEST();
728
- ensure_equals(groupNameForGid(gid), testConfig["default_group"].asString());
729
- }
730
-
731
- // and the startup file's group exists
732
- TEST_METHOD(61) {
733
- // It changes the group to the startup file's group.
734
- SETUP_USER_SWITCHING_TEST(
735
- options.group = "!STARTUP_FILE!";
736
- );
737
- lchown("tmp.wsgi/passenger_wsgi.py",
738
- (uid_t) testConfig["nonexistant_uid"].asInt64(),
739
- gidFor(testConfig["normal_group_1"].asString()));
740
- RUN_USER_SWITCHING_TEST();
741
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_1"].asString());
742
- }
743
-
744
- TEST_METHOD(62) {
745
- // If the startup file is a symlink, then it uses the symlink's group, not the target's group.
746
- SETUP_USER_SWITCHING_TEST(
747
- options.group = "!STARTUP_FILE!";
748
- );
749
- lchown("tmp.wsgi/passenger_wsgi.py",
750
- (uid_t) testConfig["nonexistant_uid"].asInt64(),
751
- gidFor(testConfig["normal_group_2"].asString()));
752
- chown("tmp.wsgi/passenger_wsgi.py.real",
753
- (uid_t) -1,
754
- gidFor(testConfig["normal_group_1"].asString()));
755
- RUN_USER_SWITCHING_TEST();
756
- ensure_equals(groupNameForGid(gid), testConfig["normal_group_2"].asString());
757
- }
758
-
759
- TEST_METHOD(63) {
760
- // If 'group' is not given, it changes the group to defaultUser's primary group.
761
- SETUP_USER_SWITCHING_TEST(
762
- (void) 0;
763
- );
764
- lchown("tmp.wsgi/passenger_wsgi.py",
765
- (uid_t) testConfig["nonexistant_uid"].asInt64(),
766
- (gid_t) -1);
767
- RUN_USER_SWITCHING_TEST();
768
- ensure_equals(groupNameForGid(gid), primaryGroupFor(testConfig["default_user"].asString()));
769
- }
770
-
771
- TEST_METHOD(67) {
772
- // It raises an error if it tries to lower to 'defaultUser',
773
- // but that user doesn't exist.
774
- SETUP_USER_SWITCHING_TEST(
775
- options.user = "root";
776
- options.defaultUser = testConfig["nonexistant_user"].asCString();
777
- );
778
- try {
779
- RUN_USER_SWITCHING_TEST();
780
- fail();
781
- } catch (const RuntimeException &e) {
782
- ensure(containsSubstring(e.what(), "Cannot determine a user to lower privilege to"));
783
- }
784
- }
785
-
786
- TEST_METHOD(68) {
787
- // It raises an error if it tries to lower to 'default_group',
788
- // but that group doesn't exist.
789
- SETUP_USER_SWITCHING_TEST(
790
- options.user = testConfig["normal_user_1"].asCString();
791
- options.group = groupNameForGid(0);
792
- options.defaultGroup = testConfig["nonexistant_group"].asCString();
793
- );
794
- try {
795
- RUN_USER_SWITCHING_TEST();
796
- fail();
797
- } catch (const RuntimeException &e) {
798
- ensure(containsSubstring(e.what(), "Cannot determine a group to lower privilege to"));
799
- }
800
- }
801
-
802
- TEST_METHOD(69) {
803
- // Changes supplementary groups to the owner's default supplementary groups.
804
- SETUP_USER_SWITCHING_TEST(
805
- options.user = testConfig["normal_user_1"].asCString();
806
- );
807
- RUN_USER_SWITCHING_TEST();
808
- runShellCommand(("groups " + testConfig["normal_user_1"].asString() + " > /tmp/info2.txt").c_str());
809
- string defaultGroups = strip(readAll("/tmp/info2.txt"));
810
-
811
- // On Linux, the 'groups' output is prepended by the group name so
812
- // get rid of that.
813
- string::size_type pos = defaultGroups.find(':');
814
- if (pos != string::npos) {
815
- pos++;
816
- while (pos < defaultGroups.size() && defaultGroups[pos] == ' ') {
817
- pos++;
818
- }
819
- defaultGroups.erase(0, pos);
820
- }
821
-
822
- ensure_equals(groups, defaultGroups);
823
- }