passenger 3.0.0.pre2 → 3.0.0.pre3

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 (182) hide show
  1. data/bin/passenger-status +1 -1
  2. data/build/packaging.rb +4 -7
  3. data/build/ruby_extension.rb +5 -5
  4. data/ext/common/Constants.h +1 -1
  5. data/ext/common/LoggingAgent/RemoteSender.h +3 -1
  6. data/ext/nginx/ngx_http_passenger_module.c +1 -1
  7. data/ext/{phusion_passenger → ruby}/extconf.rb +1 -1
  8. data/ext/{phusion_passenger/native_support.c → ruby/passenger_native_support.c} +1 -1
  9. data/lib/phusion_passenger.rb +5 -6
  10. data/lib/phusion_passenger/dependencies.rb +23 -0
  11. data/lib/phusion_passenger/native_support.rb +123 -65
  12. data/lib/phusion_passenger/packaging.rb +1 -1
  13. data/lib/phusion_passenger/platform_info/apache.rb +1 -1
  14. data/lib/phusion_passenger/platform_info/compiler.rb +25 -1
  15. data/lib/phusion_passenger/platform_info/ruby.rb +36 -5
  16. data/lib/phusion_passenger/standalone/runtime_installer.rb +5 -4
  17. data/lib/phusion_passenger/utils.rb +62 -1
  18. data/test/ruby/utils_spec.rb +62 -0
  19. data/test/support/test_helper.rb +2 -0
  20. metadata +6 -168
  21. data/doc/rdoc/classes/ConditionVariable.html +0 -215
  22. data/doc/rdoc/classes/Exception.html +0 -120
  23. data/doc/rdoc/classes/GC.html +0 -113
  24. data/doc/rdoc/classes/IO.html +0 -221
  25. data/doc/rdoc/classes/PhusionPassenger.html +0 -368
  26. data/doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html +0 -180
  27. data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +0 -647
  28. data/doc/rdoc/classes/PhusionPassenger/AbstractServer.html +0 -654
  29. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/InvalidPassword.html +0 -92
  30. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerAlreadyStarted.html +0 -97
  31. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerError.html +0 -96
  32. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerNotStarted.html +0 -97
  33. data/doc/rdoc/classes/PhusionPassenger/AbstractServer/UnknownMessage.html +0 -96
  34. data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +0 -619
  35. data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +0 -142
  36. data/doc/rdoc/classes/PhusionPassenger/AdminTools/MemoryStats.html +0 -368
  37. data/doc/rdoc/classes/PhusionPassenger/AdminTools/MemoryStats/Process.html +0 -231
  38. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance.html +0 -588
  39. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/CorruptedDirectoryError.html +0 -92
  40. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/GenerationsAbsentError.html +0 -92
  41. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/Group.html +0 -147
  42. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/Process.html +0 -279
  43. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/RoleDeniedError.html +0 -92
  44. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/StaleDirectoryError.html +0 -92
  45. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/Stats.html +0 -123
  46. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/UnsupportedGenerationStructureVersionError.html +0 -92
  47. data/doc/rdoc/classes/PhusionPassenger/AnalyticsLogger.html +0 -341
  48. data/doc/rdoc/classes/PhusionPassenger/AnalyticsLogger/Log.html +0 -294
  49. data/doc/rdoc/classes/PhusionPassenger/AnalyticsLogger/SharedData.html +0 -199
  50. data/doc/rdoc/classes/PhusionPassenger/AppInitError.html +0 -155
  51. data/doc/rdoc/classes/PhusionPassenger/AppProcess.html +0 -367
  52. data/doc/rdoc/classes/PhusionPassenger/ClassicRails.html +0 -95
  53. data/doc/rdoc/classes/PhusionPassenger/ClassicRails/ApplicationSpawner.html +0 -351
  54. data/doc/rdoc/classes/PhusionPassenger/ClassicRails/ApplicationSpawner/Error.html +0 -98
  55. data/doc/rdoc/classes/PhusionPassenger/ClassicRails/CGIFixed.html +0 -200
  56. data/doc/rdoc/classes/PhusionPassenger/ClassicRails/FrameworkSpawner.html +0 -410
  57. data/doc/rdoc/classes/PhusionPassenger/ClassicRails/FrameworkSpawner/Error.html +0 -98
  58. data/doc/rdoc/classes/PhusionPassenger/ClassicRails/RequestHandler.html +0 -156
  59. data/doc/rdoc/classes/PhusionPassenger/ClassicRailsExtensions.html +0 -115
  60. data/doc/rdoc/classes/PhusionPassenger/ClassicRailsExtensions/AnalyticsLogging.html +0 -202
  61. data/doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html +0 -172
  62. data/doc/rdoc/classes/PhusionPassenger/DebugLogging.html +0 -273
  63. data/doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html +0 -145
  64. data/doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html +0 -162
  65. data/doc/rdoc/classes/PhusionPassenger/InitializationError.html +0 -141
  66. data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +0 -92
  67. data/doc/rdoc/classes/PhusionPassenger/MessageChannel.html +0 -673
  68. data/doc/rdoc/classes/PhusionPassenger/MessageChannel/InvalidHashError.html +0 -92
  69. data/doc/rdoc/classes/PhusionPassenger/MessageClient.html +0 -415
  70. data/doc/rdoc/classes/PhusionPassenger/NativeSupport.html +0 -494
  71. data/doc/rdoc/classes/PhusionPassenger/NativeSupport/FileSystemWatcher.html +0 -96
  72. data/doc/rdoc/classes/PhusionPassenger/Packaging.html +0 -129
  73. data/doc/rdoc/classes/PhusionPassenger/PlatformInfo.html +0 -1758
  74. data/doc/rdoc/classes/PhusionPassenger/Plugin.html +0 -237
  75. data/doc/rdoc/classes/PhusionPassenger/Rack.html +0 -91
  76. data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +0 -312
  77. data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner/Error.html +0 -98
  78. data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +0 -218
  79. data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions.html +0 -114
  80. data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging.html +0 -256
  81. data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging/ACExtension.html +0 -139
  82. data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging/ASBenchmarkableExtension.html +0 -118
  83. data/doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging/ExceptionLogger.html +0 -135
  84. data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +0 -378
  85. data/doc/rdoc/classes/PhusionPassenger/Standalone.html +0 -111
  86. data/doc/rdoc/classes/PhusionPassenger/Standalone/AppFinder.html +0 -252
  87. data/doc/rdoc/classes/PhusionPassenger/Standalone/Command.html +0 -161
  88. data/doc/rdoc/classes/PhusionPassenger/Standalone/ConfigFile.html +0 -368
  89. data/doc/rdoc/classes/PhusionPassenger/Standalone/ConfigFile/DisallowedContextError.html +0 -132
  90. data/doc/rdoc/classes/PhusionPassenger/Standalone/HelpCommand.html +0 -151
  91. data/doc/rdoc/classes/PhusionPassenger/Standalone/Main.html +0 -189
  92. data/doc/rdoc/classes/PhusionPassenger/Standalone/PackageRuntimeCommand.html +0 -177
  93. data/doc/rdoc/classes/PhusionPassenger/Standalone/RuntimeInstaller.html +0 -341
  94. data/doc/rdoc/classes/PhusionPassenger/Standalone/StartCommand.html +0 -203
  95. data/doc/rdoc/classes/PhusionPassenger/Standalone/StatusCommand.html +0 -156
  96. data/doc/rdoc/classes/PhusionPassenger/Standalone/StopCommand.html +0 -168
  97. data/doc/rdoc/classes/PhusionPassenger/Standalone/Utils.html +0 -86
  98. data/doc/rdoc/classes/PhusionPassenger/Standalone/VersionCommand.html +0 -135
  99. data/doc/rdoc/classes/PhusionPassenger/UnknownError.html +0 -125
  100. data/doc/rdoc/classes/PhusionPassenger/Utils.html +0 -1468
  101. data/doc/rdoc/classes/PhusionPassenger/Utils/FileSystemWatcher.html +0 -204
  102. data/doc/rdoc/classes/PhusionPassenger/Utils/FileSystemWatcher/DirInfo.html +0 -171
  103. data/doc/rdoc/classes/PhusionPassenger/Utils/FileSystemWatcher/FileInfo.html +0 -140
  104. data/doc/rdoc/classes/PhusionPassenger/Utils/HostsFileParser.html +0 -260
  105. data/doc/rdoc/classes/PhusionPassenger/Utils/PseudoIO.html +0 -169
  106. data/doc/rdoc/classes/PhusionPassenger/Utils/RewindableInput.html +0 -265
  107. data/doc/rdoc/classes/PhusionPassenger/Utils/RewindableInput/Tempfile.html +0 -120
  108. data/doc/rdoc/classes/PhusionPassenger/Utils/UnseekableSocket.html +0 -561
  109. data/doc/rdoc/classes/PhusionPassenger/VersionNotFound.html +0 -140
  110. data/doc/rdoc/classes/PhusionPassenger/WSGI.html +0 -89
  111. data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +0 -182
  112. data/doc/rdoc/classes/Process.html +0 -115
  113. data/doc/rdoc/classes/Signal.html +0 -139
  114. data/doc/rdoc/created.rid +0 -1
  115. data/doc/rdoc/files/DEVELOPERS_TXT.html +0 -276
  116. data/doc/rdoc/files/README.html +0 -157
  117. data/doc/rdoc/files/ext/phusion_passenger/native_support_c.html +0 -92
  118. data/doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html +0 -130
  119. data/doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html +0 -135
  120. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +0 -126
  121. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html +0 -128
  122. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/memory_stats_rb.html +0 -126
  123. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/server_instance_rb.html +0 -132
  124. data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +0 -122
  125. data/doc/rdoc/files/lib/phusion_passenger/analytics_logger_rb.html +0 -129
  126. data/doc/rdoc/files/lib/phusion_passenger/app_process_rb.html +0 -127
  127. data/doc/rdoc/files/lib/phusion_passenger/classic_rails/application_spawner_rb.html +0 -141
  128. data/doc/rdoc/files/lib/phusion_passenger/classic_rails/cgi_fixed_rb.html +0 -126
  129. data/doc/rdoc/files/lib/phusion_passenger/classic_rails/framework_spawner_rb.html +0 -146
  130. data/doc/rdoc/files/lib/phusion_passenger/classic_rails/request_handler_rb.html +0 -125
  131. data/doc/rdoc/files/lib/phusion_passenger/classic_rails_extensions/init_rb.html +0 -132
  132. data/doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html +0 -126
  133. data/doc/rdoc/files/lib/phusion_passenger/constants_rb.html +0 -122
  134. data/doc/rdoc/files/lib/phusion_passenger/debug_logging_rb.html +0 -122
  135. data/doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html +0 -147
  136. data/doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html +0 -122
  137. data/doc/rdoc/files/lib/phusion_passenger/html_template_rb.html +0 -127
  138. data/doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html +0 -120
  139. data/doc/rdoc/files/lib/phusion_passenger/message_client_rb.html +0 -127
  140. data/doc/rdoc/files/lib/phusion_passenger/native_support_rb.html +0 -131
  141. data/doc/rdoc/files/lib/phusion_passenger/packaging_rb.html +0 -122
  142. data/doc/rdoc/files/lib/phusion_passenger/platform_info/apache_rb.html +0 -127
  143. data/doc/rdoc/files/lib/phusion_passenger/platform_info/binary_compatibility_rb.html +0 -129
  144. data/doc/rdoc/files/lib/phusion_passenger/platform_info/compiler_rb.html +0 -126
  145. data/doc/rdoc/files/lib/phusion_passenger/platform_info/curl_rb.html +0 -126
  146. data/doc/rdoc/files/lib/phusion_passenger/platform_info/documentation_tools_rb.html +0 -126
  147. data/doc/rdoc/files/lib/phusion_passenger/platform_info/linux_rb.html +0 -126
  148. data/doc/rdoc/files/lib/phusion_passenger/platform_info/operating_system_rb.html +0 -127
  149. data/doc/rdoc/files/lib/phusion_passenger/platform_info/ruby_rb.html +0 -128
  150. data/doc/rdoc/files/lib/phusion_passenger/platform_info/zlib_rb.html +0 -126
  151. data/doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html +0 -122
  152. data/doc/rdoc/files/lib/phusion_passenger/plugin_rb.html +0 -127
  153. data/doc/rdoc/files/lib/phusion_passenger/public_api_rb.html +0 -127
  154. data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +0 -137
  155. data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +0 -125
  156. data/doc/rdoc/files/lib/phusion_passenger/rails3_extensions/init_rb.html +0 -127
  157. data/doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html +0 -122
  158. data/doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html +0 -160
  159. data/doc/rdoc/files/lib/phusion_passenger/standalone/app_finder_rb.html +0 -127
  160. data/doc/rdoc/files/lib/phusion_passenger/standalone/command_rb.html +0 -135
  161. data/doc/rdoc/files/lib/phusion_passenger/standalone/config_file_rb.html +0 -126
  162. data/doc/rdoc/files/lib/phusion_passenger/standalone/help_command_rb.html +0 -126
  163. data/doc/rdoc/files/lib/phusion_passenger/standalone/main_rb.html +0 -126
  164. data/doc/rdoc/files/lib/phusion_passenger/standalone/package_runtime_command_rb.html +0 -127
  165. data/doc/rdoc/files/lib/phusion_passenger/standalone/runtime_installer_rb.html +0 -132
  166. data/doc/rdoc/files/lib/phusion_passenger/standalone/start_command_rb.html +0 -136
  167. data/doc/rdoc/files/lib/phusion_passenger/standalone/status_command_rb.html +0 -126
  168. data/doc/rdoc/files/lib/phusion_passenger/standalone/stop_command_rb.html +0 -126
  169. data/doc/rdoc/files/lib/phusion_passenger/standalone/utils_rb.html +0 -126
  170. data/doc/rdoc/files/lib/phusion_passenger/standalone/version_command_rb.html +0 -127
  171. data/doc/rdoc/files/lib/phusion_passenger/utils/file_system_watcher_rb.html +0 -126
  172. data/doc/rdoc/files/lib/phusion_passenger/utils/hosts_file_parser_rb.html +0 -120
  173. data/doc/rdoc/files/lib/phusion_passenger/utils/rewindable_input_rb.html +0 -100
  174. data/doc/rdoc/files/lib/phusion_passenger/utils/tmpdir_rb.html +0 -122
  175. data/doc/rdoc/files/lib/phusion_passenger/utils/unseekable_socket_rb.html +0 -126
  176. data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +0 -179
  177. data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +0 -132
  178. data/doc/rdoc/fr_class_index.html +0 -139
  179. data/doc/rdoc/fr_file_index.html +0 -109
  180. data/doc/rdoc/fr_method_index.html +0 -435
  181. data/doc/rdoc/index.html +0 -26
  182. data/doc/rdoc/rdoc-style.css +0 -187
@@ -50,16 +50,37 @@ module PlatformInfo
50
50
  name = rvm_ruby_string
51
51
  dir = rvm_path
52
52
  if name && dir
53
- return "#{dir}/wrappers/#{name}/ruby"
53
+ filename = "#{dir}/wrappers/#{name}/ruby"
54
+ if File.exist?(filename)
55
+ contents = File.open(filename, 'rb') do |f|
56
+ f.read
57
+ end
58
+ # Old wrapper scripts reference $HOME which causes
59
+ # things to blow up when run by a different user.
60
+ if contents.include?("$HOME")
61
+ filename = nil
62
+ end
63
+ else
64
+ filename = nil
65
+ end
66
+ if filename
67
+ return filename
68
+ else
69
+ STDERR.puts "Your RVM wrapper scripts are too old. Please " +
70
+ "update them first by running 'rvm update --head && " +
71
+ "rvm reload && rvm repair all'."
72
+ exit 1
73
+ end
54
74
  else
55
75
  # Something's wrong with the user's RVM installation.
56
76
  # Raise an error so that the user knows this instead of
57
77
  # having things fail randomly later on.
58
78
  # 'name' is guaranteed to be non-nil because rvm_ruby_string
59
79
  # already raises an exception on error.
60
- raise "Your RVM installation appears to be broken: the RVM " +
80
+ STDERR.puts "Your RVM installation appears to be broken: the RVM " +
61
81
  "path cannot be found. Please fix your RVM installation " +
62
82
  "or contact the RVM developers for support."
83
+ exit 1
63
84
  end
64
85
  else
65
86
  return ruby_executable
@@ -131,7 +152,8 @@ module PlatformInfo
131
152
 
132
153
  # Returns whether the current Ruby interpreter is managed by RVM.
133
154
  def self.in_rvm?
134
- return Config::CONFIG['bindir'].include?('/.rvm/')
155
+ bindir = Config::CONFIG['bindir']
156
+ return bindir.include?('/.rvm/') || bindir.include?('/rvm/')
135
157
  end
136
158
 
137
159
  # If the current Ruby interpreter is managed by RVM, returns the
@@ -144,8 +166,16 @@ module PlatformInfo
144
166
  path = File.expand_path(path)
145
167
  return path if File.directory?(path)
146
168
  end
169
+ # Failure to locate the RVM path is probably caused by the
170
+ # user customizing $rvm_path. Older RVM versions don't
171
+ # export $rvm_path, making us unable to detect its value.
172
+ STDERR.puts "Unable to locate the RVM path. Your RVM installation " +
173
+ "is probably too old. Please update it with " +
174
+ "'rvm update --head && rvm reload && rvm repair all'."
175
+ exit 1
176
+ else
177
+ return nil
147
178
  end
148
- return nil
149
179
  end
150
180
  memoize :rvm_path
151
181
 
@@ -189,8 +219,9 @@ module PlatformInfo
189
219
  # We're out of options now, we can't detect the gem set.
190
220
  # Raise an exception so that the user knows what's going on
191
221
  # instead of having things fail in obscure ways later.
192
- raise "Unable to autodetect the currently active RVM gem " +
222
+ STDERR.puts "Unable to autodetect the currently active RVM gem " +
193
223
  "set name. Please contact this program's author for support."
224
+ exit 1
194
225
  end
195
226
  return nil
196
227
  end
@@ -76,7 +76,7 @@ protected
76
76
  def dependencies
77
77
  result = [
78
78
  Dependencies::GCC,
79
- Dependencies::Make,
79
+ Dependencies::GnuMake,
80
80
  Dependencies::DownloadTool,
81
81
  Dependencies::Ruby_DevHeaders,
82
82
  Dependencies::Ruby_OpenSSL,
@@ -427,6 +427,7 @@ private
427
427
  end
428
428
 
429
429
  def install_nginx_from_source(source_dir)
430
+ require 'phusion_passenger/platform_info/compiler'
430
431
  Dir.chdir(source_dir) do
431
432
  command = "sh ./configure '--prefix=#{@nginx_dir}' --without-pcre " <<
432
433
  "--without-http_rewrite_module " <<
@@ -437,8 +438,8 @@ private
437
438
  end
438
439
 
439
440
  backlog = ""
440
- total_lines = `make --dry-run`.split("\n").size
441
- IO.popen("make 2>&1", "r") do |io|
441
+ total_lines = `#{PlatformInfo.gnu_make} --dry-run`.split("\n").size
442
+ IO.popen("#{PlatformInfo.gnu_make} 2>&1", "r") do |io|
442
443
  progress = 1
443
444
  while !io.eof?
444
445
  line = io.readline
@@ -454,7 +455,7 @@ private
454
455
  exit 1
455
456
  end
456
457
 
457
- command = "make install"
458
+ command = "#{PlatformInfo.gnu_make} install"
458
459
  run_command_with_throbber(command, "Copying files...") do |status_text|
459
460
  yield(1, 1, status_text)
460
461
  end
@@ -192,9 +192,31 @@ protected
192
192
  # This function may modify +options+. The modified options are to be
193
193
  # passed to the request handler.
194
194
  def prepare_app_process(startup_file, options)
195
+ options["app_root"] = canonicalize_path(options["app_root"])
195
196
  Dir.chdir(options["app_root"])
196
197
 
197
198
  lower_privilege(startup_file, options)
199
+ path, is_parent = check_directory_tree_permissions(options["app_root"])
200
+ if path
201
+ username = Etc.getpwuid(Process.euid).name
202
+ groupname = Etc.getgrgid(Process.egid).name
203
+ message = "This application process is currently running as " +
204
+ "user '#{username}' and group '#{groupname}' and must be " +
205
+ "able to access its application root directory " +
206
+ "'#{options["app_root"]}'. "
207
+ if is_parent
208
+ message << "However the parent directory '#{path}' " +
209
+ "has wrong permissions, thereby preventing " +
210
+ "this process from accessing its application " +
211
+ "root directory. Please fix the permissions " +
212
+ "of the directory '#{path}' first."
213
+ else
214
+ message << "However this directory is not accessible " +
215
+ "because it has wrong permissions. Please fix " +
216
+ "these permissions first."
217
+ end
218
+ raise(message)
219
+ end
198
220
 
199
221
  ENV["RAILS_ENV"] = ENV["RACK_ENV"] = options["environment"]
200
222
 
@@ -316,7 +338,7 @@ protected
316
338
 
317
339
  # !!! NOTE !!!
318
340
  # If the app is using Bundler then any dependencies required past this
319
- # point must be specified in the Gemfile. Like ruby-debug in debugging is on...
341
+ # point must be specified in the Gemfile. Like ruby-debug if debugging is on...
320
342
 
321
343
  if options["debugger"]
322
344
  require 'ruby-debug'
@@ -710,6 +732,45 @@ protected
710
732
  ENV['HOME'] = user_info.dir
711
733
  end
712
734
 
735
+ # Checks the permissions of all parent directories of +dir+ as
736
+ # well as +dir+ itself.
737
+ #
738
+ # +dir+ must be a canonical path.
739
+ #
740
+ # If one of the parent directories has wrong permissions, causing
741
+ # +dir+ to be inaccessible by the current process, then this function
742
+ # returns [path, true] where +path+ is the path of the top-most
743
+ # directory with wrong permissions.
744
+ #
745
+ # If +dir+ itself is not executable by the current process then
746
+ # this function returns [dir, false].
747
+ #
748
+ # Otherwise, nil is returned.
749
+ def check_directory_tree_permissions(dir)
750
+ components = dir.split("/")
751
+ components.shift
752
+ i = 0
753
+ # We can't use File.readable() and friends here because they
754
+ # don't always work right with ACLs. Instead of we use 'real'
755
+ # checks.
756
+ while i < components.size
757
+ path = "/" + components[0..i].join("/")
758
+ begin
759
+ File.stat(path)
760
+ rescue Errno::EACCES
761
+ return [File.dirname(path), true]
762
+ end
763
+ i += 1
764
+ end
765
+ begin
766
+ Dir.chdir(dir) do
767
+ return nil
768
+ end
769
+ rescue Errno::EACCES
770
+ return [dir, false]
771
+ end
772
+ end
773
+
713
774
  # Returns a string which reports the backtraces for all threads,
714
775
  # or if that's not supported the backtrace for the current thread.
715
776
  def global_backtrace_report
@@ -680,6 +680,68 @@ describe Utils do
680
680
  end
681
681
  end
682
682
 
683
+ describe "#check_directory_tree_permissions" do
684
+ before :each do
685
+ @root = PhusionPassenger::Utils.passenger_tmpdir
686
+ end
687
+
688
+ def primary_group_for(username)
689
+ gid = Etc.getpwnam(username).gid
690
+ return Etc.getgrgid(gid).name
691
+ end
692
+
693
+ it "raises an error for the top-most parent directory that has wrong permissions" do
694
+ FileUtils.mkdir_p("#{@root}/a/b/c/d")
695
+
696
+ when_running_as_root do
697
+ user = CONFIG['normal_user_1']
698
+ group = primary_group_for(user)
699
+ system("chown -R #{user} #{@root}/a")
700
+ system("chgrp -R #{group} #{@root}/a")
701
+
702
+ output = run_script(%q{
703
+ require 'phusion_passenger/utils'
704
+ include PhusionPassenger::Utils
705
+ @root = ARGV[0]
706
+ lower_privilege(nil,
707
+ "user" => ARGV[1],
708
+ "group" => ARGV[2])
709
+
710
+ File.chmod(0600, "#{@root}/a/b/c/d")
711
+ File.chmod(0600, "#{@root}/a/b/c")
712
+ File.chmod(0600, "#{@root}/a")
713
+ p check_directory_tree_permissions("#{@root}/a/b/c/d")
714
+ File.chmod(0700, "#{@root}/a")
715
+ p check_directory_tree_permissions("#{@root}/a/b/c/d")
716
+ File.chmod(0700, "#{@root}/a/b/c")
717
+ p check_directory_tree_permissions("#{@root}/a/b/c/d")
718
+ File.chmod(0700, "#{@root}/a/b/c/d")
719
+ p check_directory_tree_permissions("#{@root}/a/b/c/d")
720
+ }, @root, user, group)
721
+ lines = output.split("\n")
722
+ lines[0].should == ["#{@root}/a", true].inspect
723
+ lines[1].should == ["#{@root}/a/b/c", true].inspect
724
+ lines[2].should == ["#{@root}/a/b/c/d", false].inspect
725
+ lines[3].should == "nil"
726
+ end
727
+ when_not_running_as_root do
728
+ File.chmod(0000, "#{@root}/a/b/c/d")
729
+ File.chmod(0600, "#{@root}/a/b/c")
730
+ File.chmod(0600, "#{@root}/a")
731
+ check_directory_tree_permissions("#{@root}/a/b/c/d").should ==
732
+ ["#{@root}/a", true]
733
+ File.chmod(0700, "#{@root}/a")
734
+ check_directory_tree_permissions("#{@root}/a/b/c/d").should ==
735
+ ["#{@root}/a/b/c", true]
736
+ File.chmod(0700, "#{@root}/a/b/c")
737
+ check_directory_tree_permissions("#{@root}/a/b/c/d").should ==
738
+ ["#{@root}/a/b/c/d", false]
739
+ File.chmod(0700, "#{@root}/a/b/c/d")
740
+ check_directory_tree_permissions("#{@root}/a/b/c/d").should be_nil
741
+ end
742
+ end
743
+ end
744
+
683
745
  ######################
684
746
  end
685
747
 
@@ -255,6 +255,8 @@ module TestHelper
255
255
  end
256
256
  end
257
257
 
258
+ alias when_running_as_root when_user_switching_possible
259
+
258
260
  def when_not_running_as_root
259
261
  if Process.euid != 0
260
262
  yield
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passenger
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1876988207
4
+ hash: -1876988210
5
5
  prerelease: true
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
9
  - 0
10
- - pre2
11
- version: 3.0.0.pre2
10
+ - pre3
11
+ version: 3.0.0.pre3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Phusion - http://www.phusion.nl/
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-17 00:00:00 +02:00
19
+ date: 2010-09-20 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -735,168 +735,6 @@ files:
735
735
  - doc/images/spawn_server_architecture.svg
736
736
  - doc/images/typical_isolated_web_application.png
737
737
  - doc/images/typical_isolated_web_application.svg
738
- - doc/rdoc/classes/ConditionVariable.html
739
- - doc/rdoc/classes/Exception.html
740
- - doc/rdoc/classes/GC.html
741
- - doc/rdoc/classes/IO.html
742
- - doc/rdoc/classes/PhusionPassenger/AbstractInstaller.html
743
- - doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html
744
- - doc/rdoc/classes/PhusionPassenger/AbstractServer/InvalidPassword.html
745
- - doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerAlreadyStarted.html
746
- - doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerError.html
747
- - doc/rdoc/classes/PhusionPassenger/AbstractServer/ServerNotStarted.html
748
- - doc/rdoc/classes/PhusionPassenger/AbstractServer/UnknownMessage.html
749
- - doc/rdoc/classes/PhusionPassenger/AbstractServer.html
750
- - doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html
751
- - doc/rdoc/classes/PhusionPassenger/AdminTools/MemoryStats/Process.html
752
- - doc/rdoc/classes/PhusionPassenger/AdminTools/MemoryStats.html
753
- - doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/CorruptedDirectoryError.html
754
- - doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/GenerationsAbsentError.html
755
- - doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/Group.html
756
- - doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/Process.html
757
- - doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/RoleDeniedError.html
758
- - doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/StaleDirectoryError.html
759
- - doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/Stats.html
760
- - doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance/UnsupportedGenerationStructureVersionError.html
761
- - doc/rdoc/classes/PhusionPassenger/AdminTools/ServerInstance.html
762
- - doc/rdoc/classes/PhusionPassenger/AdminTools.html
763
- - doc/rdoc/classes/PhusionPassenger/AnalyticsLogger/Log.html
764
- - doc/rdoc/classes/PhusionPassenger/AnalyticsLogger/SharedData.html
765
- - doc/rdoc/classes/PhusionPassenger/AnalyticsLogger.html
766
- - doc/rdoc/classes/PhusionPassenger/AppInitError.html
767
- - doc/rdoc/classes/PhusionPassenger/AppProcess.html
768
- - doc/rdoc/classes/PhusionPassenger/ClassicRails/ApplicationSpawner/Error.html
769
- - doc/rdoc/classes/PhusionPassenger/ClassicRails/ApplicationSpawner.html
770
- - doc/rdoc/classes/PhusionPassenger/ClassicRails/CGIFixed.html
771
- - doc/rdoc/classes/PhusionPassenger/ClassicRails/FrameworkSpawner/Error.html
772
- - doc/rdoc/classes/PhusionPassenger/ClassicRails/FrameworkSpawner.html
773
- - doc/rdoc/classes/PhusionPassenger/ClassicRails/RequestHandler.html
774
- - doc/rdoc/classes/PhusionPassenger/ClassicRails.html
775
- - doc/rdoc/classes/PhusionPassenger/ClassicRailsExtensions/AnalyticsLogging.html
776
- - doc/rdoc/classes/PhusionPassenger/ClassicRailsExtensions.html
777
- - doc/rdoc/classes/PhusionPassenger/ConsoleTextTemplate.html
778
- - doc/rdoc/classes/PhusionPassenger/DebugLogging.html
779
- - doc/rdoc/classes/PhusionPassenger/FrameworkInitError.html
780
- - doc/rdoc/classes/PhusionPassenger/HTMLTemplate.html
781
- - doc/rdoc/classes/PhusionPassenger/InitializationError.html
782
- - doc/rdoc/classes/PhusionPassenger/InvalidPath.html
783
- - doc/rdoc/classes/PhusionPassenger/MessageChannel/InvalidHashError.html
784
- - doc/rdoc/classes/PhusionPassenger/MessageChannel.html
785
- - doc/rdoc/classes/PhusionPassenger/MessageClient.html
786
- - doc/rdoc/classes/PhusionPassenger/NativeSupport/FileSystemWatcher.html
787
- - doc/rdoc/classes/PhusionPassenger/NativeSupport.html
788
- - doc/rdoc/classes/PhusionPassenger/Packaging.html
789
- - doc/rdoc/classes/PhusionPassenger/PlatformInfo.html
790
- - doc/rdoc/classes/PhusionPassenger/Plugin.html
791
- - doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner/Error.html
792
- - doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html
793
- - doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html
794
- - doc/rdoc/classes/PhusionPassenger/Rack.html
795
- - doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging/ACExtension.html
796
- - doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging/ASBenchmarkableExtension.html
797
- - doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging/ExceptionLogger.html
798
- - doc/rdoc/classes/PhusionPassenger/Rails3Extensions/AnalyticsLogging.html
799
- - doc/rdoc/classes/PhusionPassenger/Rails3Extensions.html
800
- - doc/rdoc/classes/PhusionPassenger/SpawnManager.html
801
- - doc/rdoc/classes/PhusionPassenger/Standalone/AppFinder.html
802
- - doc/rdoc/classes/PhusionPassenger/Standalone/Command.html
803
- - doc/rdoc/classes/PhusionPassenger/Standalone/ConfigFile/DisallowedContextError.html
804
- - doc/rdoc/classes/PhusionPassenger/Standalone/ConfigFile.html
805
- - doc/rdoc/classes/PhusionPassenger/Standalone/HelpCommand.html
806
- - doc/rdoc/classes/PhusionPassenger/Standalone/Main.html
807
- - doc/rdoc/classes/PhusionPassenger/Standalone/PackageRuntimeCommand.html
808
- - doc/rdoc/classes/PhusionPassenger/Standalone/RuntimeInstaller.html
809
- - doc/rdoc/classes/PhusionPassenger/Standalone/StartCommand.html
810
- - doc/rdoc/classes/PhusionPassenger/Standalone/StatusCommand.html
811
- - doc/rdoc/classes/PhusionPassenger/Standalone/StopCommand.html
812
- - doc/rdoc/classes/PhusionPassenger/Standalone/Utils.html
813
- - doc/rdoc/classes/PhusionPassenger/Standalone/VersionCommand.html
814
- - doc/rdoc/classes/PhusionPassenger/Standalone.html
815
- - doc/rdoc/classes/PhusionPassenger/UnknownError.html
816
- - doc/rdoc/classes/PhusionPassenger/Utils/FileSystemWatcher/DirInfo.html
817
- - doc/rdoc/classes/PhusionPassenger/Utils/FileSystemWatcher/FileInfo.html
818
- - doc/rdoc/classes/PhusionPassenger/Utils/FileSystemWatcher.html
819
- - doc/rdoc/classes/PhusionPassenger/Utils/HostsFileParser.html
820
- - doc/rdoc/classes/PhusionPassenger/Utils/PseudoIO.html
821
- - doc/rdoc/classes/PhusionPassenger/Utils/RewindableInput/Tempfile.html
822
- - doc/rdoc/classes/PhusionPassenger/Utils/RewindableInput.html
823
- - doc/rdoc/classes/PhusionPassenger/Utils/UnseekableSocket.html
824
- - doc/rdoc/classes/PhusionPassenger/Utils.html
825
- - doc/rdoc/classes/PhusionPassenger/VersionNotFound.html
826
- - doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html
827
- - doc/rdoc/classes/PhusionPassenger/WSGI.html
828
- - doc/rdoc/classes/PhusionPassenger.html
829
- - doc/rdoc/classes/Process.html
830
- - doc/rdoc/classes/Signal.html
831
- - doc/rdoc/created.rid
832
- - doc/rdoc/files/DEVELOPERS_TXT.html
833
- - doc/rdoc/files/ext/phusion_passenger/native_support_c.html
834
- - doc/rdoc/files/lib/phusion_passenger/abstract_installer_rb.html
835
- - doc/rdoc/files/lib/phusion_passenger/abstract_request_handler_rb.html
836
- - doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html
837
- - doc/rdoc/files/lib/phusion_passenger/abstract_server_rb.html
838
- - doc/rdoc/files/lib/phusion_passenger/admin_tools/memory_stats_rb.html
839
- - doc/rdoc/files/lib/phusion_passenger/admin_tools/server_instance_rb.html
840
- - doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html
841
- - doc/rdoc/files/lib/phusion_passenger/analytics_logger_rb.html
842
- - doc/rdoc/files/lib/phusion_passenger/app_process_rb.html
843
- - doc/rdoc/files/lib/phusion_passenger/classic_rails/application_spawner_rb.html
844
- - doc/rdoc/files/lib/phusion_passenger/classic_rails/cgi_fixed_rb.html
845
- - doc/rdoc/files/lib/phusion_passenger/classic_rails/framework_spawner_rb.html
846
- - doc/rdoc/files/lib/phusion_passenger/classic_rails/request_handler_rb.html
847
- - doc/rdoc/files/lib/phusion_passenger/classic_rails_extensions/init_rb.html
848
- - doc/rdoc/files/lib/phusion_passenger/console_text_template_rb.html
849
- - doc/rdoc/files/lib/phusion_passenger/constants_rb.html
850
- - doc/rdoc/files/lib/phusion_passenger/debug_logging_rb.html
851
- - doc/rdoc/files/lib/phusion_passenger/dependencies_rb.html
852
- - doc/rdoc/files/lib/phusion_passenger/exceptions_rb.html
853
- - doc/rdoc/files/lib/phusion_passenger/html_template_rb.html
854
- - doc/rdoc/files/lib/phusion_passenger/message_channel_rb.html
855
- - doc/rdoc/files/lib/phusion_passenger/message_client_rb.html
856
- - doc/rdoc/files/lib/phusion_passenger/native_support_rb.html
857
- - doc/rdoc/files/lib/phusion_passenger/packaging_rb.html
858
- - doc/rdoc/files/lib/phusion_passenger/platform_info/apache_rb.html
859
- - doc/rdoc/files/lib/phusion_passenger/platform_info/binary_compatibility_rb.html
860
- - doc/rdoc/files/lib/phusion_passenger/platform_info/compiler_rb.html
861
- - doc/rdoc/files/lib/phusion_passenger/platform_info/curl_rb.html
862
- - doc/rdoc/files/lib/phusion_passenger/platform_info/documentation_tools_rb.html
863
- - doc/rdoc/files/lib/phusion_passenger/platform_info/linux_rb.html
864
- - doc/rdoc/files/lib/phusion_passenger/platform_info/operating_system_rb.html
865
- - doc/rdoc/files/lib/phusion_passenger/platform_info/ruby_rb.html
866
- - doc/rdoc/files/lib/phusion_passenger/platform_info/zlib_rb.html
867
- - doc/rdoc/files/lib/phusion_passenger/platform_info_rb.html
868
- - doc/rdoc/files/lib/phusion_passenger/plugin_rb.html
869
- - doc/rdoc/files/lib/phusion_passenger/public_api_rb.html
870
- - doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html
871
- - doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html
872
- - doc/rdoc/files/lib/phusion_passenger/rails3_extensions/init_rb.html
873
- - doc/rdoc/files/lib/phusion_passenger/simple_benchmarking_rb.html
874
- - doc/rdoc/files/lib/phusion_passenger/spawn_manager_rb.html
875
- - doc/rdoc/files/lib/phusion_passenger/standalone/app_finder_rb.html
876
- - doc/rdoc/files/lib/phusion_passenger/standalone/command_rb.html
877
- - doc/rdoc/files/lib/phusion_passenger/standalone/config_file_rb.html
878
- - doc/rdoc/files/lib/phusion_passenger/standalone/help_command_rb.html
879
- - doc/rdoc/files/lib/phusion_passenger/standalone/main_rb.html
880
- - doc/rdoc/files/lib/phusion_passenger/standalone/package_runtime_command_rb.html
881
- - doc/rdoc/files/lib/phusion_passenger/standalone/runtime_installer_rb.html
882
- - doc/rdoc/files/lib/phusion_passenger/standalone/start_command_rb.html
883
- - doc/rdoc/files/lib/phusion_passenger/standalone/status_command_rb.html
884
- - doc/rdoc/files/lib/phusion_passenger/standalone/stop_command_rb.html
885
- - doc/rdoc/files/lib/phusion_passenger/standalone/utils_rb.html
886
- - doc/rdoc/files/lib/phusion_passenger/standalone/version_command_rb.html
887
- - doc/rdoc/files/lib/phusion_passenger/utils/file_system_watcher_rb.html
888
- - doc/rdoc/files/lib/phusion_passenger/utils/hosts_file_parser_rb.html
889
- - doc/rdoc/files/lib/phusion_passenger/utils/rewindable_input_rb.html
890
- - doc/rdoc/files/lib/phusion_passenger/utils/tmpdir_rb.html
891
- - doc/rdoc/files/lib/phusion_passenger/utils/unseekable_socket_rb.html
892
- - doc/rdoc/files/lib/phusion_passenger/utils_rb.html
893
- - doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html
894
- - doc/rdoc/files/README.html
895
- - doc/rdoc/fr_class_index.html
896
- - doc/rdoc/fr_file_index.html
897
- - doc/rdoc/fr_method_index.html
898
- - doc/rdoc/index.html
899
- - doc/rdoc/rdoc-style.css
900
738
  - doc/Security of user switching support.html
901
739
  - doc/Security of user switching support.txt
902
740
  - doc/template/horo.rb
@@ -1693,8 +1531,8 @@ files:
1693
1531
  - ext/oxt/detail/spin_lock_pthreads.hpp
1694
1532
  - ext/oxt/detail/tracable_exception_disabled.hpp
1695
1533
  - ext/oxt/detail/tracable_exception_enabled.hpp
1696
- - ext/phusion_passenger/native_support.c
1697
- - ext/phusion_passenger/extconf.rb
1534
+ - ext/ruby/passenger_native_support.c
1535
+ - ext/ruby/extconf.rb
1698
1536
  - misc/copy_boost_headers.rb
1699
1537
  - misc/find_owner_pipe_leaks.rb
1700
1538
  - misc/render_error_pages.rb