passenger 5.3.4 → 5.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -0
  3. data/CODE_OF_CONDUCT.md +1 -1
  4. data/build/cxx_tests.rb +12 -1
  5. data/build/misc.rb +2 -1
  6. data/build/packaging.rb +2 -0
  7. data/build/support/cplusplus.rb +2 -2
  8. data/build/support/cxx_dependency_map.rb +653 -383
  9. data/dev/configkit-schemas/index.json +105 -3
  10. data/dev/show-latest-crashlog-dir +27 -0
  11. data/resources/templates/standalone/http.erb +2 -0
  12. data/src/agent/Core/AdminPanelConnector.h +2 -2
  13. data/src/agent/Core/ApplicationPool/Context.h +5 -1
  14. data/src/agent/Core/ApplicationPool/Group.h +2 -0
  15. data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +5 -0
  16. data/src/agent/Core/ApplicationPool/Group/Miscellaneous.cpp +2 -1
  17. data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +1 -1
  18. data/src/agent/Core/ApplicationPool/Group/StateInspection.cpp +12 -19
  19. data/src/agent/Core/ApplicationPool/Options.h +35 -31
  20. data/src/agent/Core/ApplicationPool/Pool/GroupUtils.cpp +2 -1
  21. data/src/agent/Core/ApplicationPool/Socket.h +1 -1
  22. data/src/agent/Core/Config.h +38 -7
  23. data/src/agent/Core/ConfigChange.cpp +13 -1
  24. data/src/agent/Core/Controller.h +3 -1
  25. data/src/agent/Core/Controller/Config.h +14 -11
  26. data/src/agent/Core/Controller/InitRequest.cpp +6 -5
  27. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +3 -0
  28. data/src/agent/Core/CoreMain.cpp +149 -34
  29. data/src/agent/Core/OptionParser.h +12 -1
  30. data/src/agent/Core/SpawningKit/Config.h +1 -1
  31. data/src/agent/Core/SpawningKit/Context.h +7 -1
  32. data/src/agent/Core/SpawningKit/Exceptions.h +15 -12
  33. data/src/agent/Core/SpawningKit/README.md +34 -17
  34. data/src/agent/Core/SpawningKit/Spawner.h +5 -3
  35. data/src/agent/Core/SpawningKit/UserSwitchingRules.h +5 -2
  36. data/src/agent/Core/TelemetryCollector.h +674 -0
  37. data/src/agent/Shared/Fundamentals/AbortHandler.cpp +309 -83
  38. data/src/agent/Shared/Fundamentals/AbortHandler.h +18 -3
  39. data/src/agent/Watchdog/Config.h +21 -4
  40. data/src/agent/Watchdog/WatchdogMain.cpp +4 -1
  41. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +10 -0
  42. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
  43. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +30 -0
  44. data/src/apache2_module/DirectoryMapper.h +24 -36
  45. data/src/apache2_module/Hooks.cpp +13 -5
  46. data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp +20 -0
  47. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +24 -0
  48. data/src/cxx_supportlib/AppTypeDetector/CBindings.cpp +136 -0
  49. data/src/cxx_supportlib/AppTypeDetector/CBindings.h +73 -0
  50. data/src/cxx_supportlib/{AppTypes.h → AppTypeDetector/Detector.h} +59 -132
  51. data/src/cxx_supportlib/ConfigKit/README.md +90 -2
  52. data/src/cxx_supportlib/ConfigKit/Schema.h +58 -13
  53. data/src/cxx_supportlib/ConfigKit/Store.h +128 -4
  54. data/src/cxx_supportlib/Constants.h +1 -1
  55. data/src/cxx_supportlib/ProcessManagement/Ruby.cpp +3 -3
  56. data/src/cxx_supportlib/ProcessManagement/Ruby.h +7 -2
  57. data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +14 -7
  58. data/src/cxx_supportlib/ProcessManagement/Spawn.h +21 -2
  59. data/src/cxx_supportlib/ResourceLocator.h +1 -1
  60. data/src/cxx_supportlib/ServerKit/ClientRef.h +17 -7
  61. data/src/cxx_supportlib/ServerKit/HttpRequestRef.h +17 -7
  62. data/src/cxx_supportlib/Utils/IOUtils.cpp +2 -1
  63. data/src/cxx_supportlib/Utils/ProcessMetricsCollector.h +9 -6
  64. data/src/cxx_supportlib/WrapperRegistry/CBindings.cpp +85 -0
  65. data/src/cxx_supportlib/WrapperRegistry/CBindings.h +56 -0
  66. data/src/cxx_supportlib/WrapperRegistry/Entry.h +112 -0
  67. data/src/cxx_supportlib/WrapperRegistry/README.md +37 -0
  68. data/src/cxx_supportlib/WrapperRegistry/Registry.h +309 -0
  69. data/src/helper-scripts/download_binaries/extconf.rb +6 -2
  70. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +16 -0
  71. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +6 -0
  72. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +24 -0
  73. data/src/nginx_module/ContentHandler.c +34 -13
  74. data/src/nginx_module/ContentHandler.h +3 -3
  75. data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c +11 -0
  76. data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c +23 -0
  77. data/src/nginx_module/MainConfig/AutoGeneratedStruct.h +8 -0
  78. data/src/nginx_module/config +2 -1
  79. data/src/nginx_module/ngx_http_passenger_module.c +9 -3
  80. data/src/nginx_module/ngx_http_passenger_module.h +4 -2
  81. data/src/ruby_supportlib/phusion_passenger.rb +2 -1
  82. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +13 -0
  83. data/src/ruby_supportlib/phusion_passenger/common_library.rb +8 -5
  84. data/src/ruby_supportlib/phusion_passenger/config/download_agent_command.rb +6 -2
  85. data/src/ruby_supportlib/phusion_passenger/config/download_nginx_engine_command.rb +6 -2
  86. data/src/ruby_supportlib/phusion_passenger/native_support.rb +7 -3
  87. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +15 -0
  88. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +11 -1
  89. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +3 -1
  90. metadata +12 -4
  91. data/src/cxx_supportlib/AppTypes.cpp +0 -109
@@ -0,0 +1,37 @@
1
+ # The wrapper registry
2
+
3
+ The wrapper registry (the Registry class) describes for which languages Passenger has wrappers available. Each entry (the Entry class) describes:
4
+
5
+ * An identifier for this language (ex: `rack`). Related to `passenger_app_type`.
6
+ * The path to the wrapper (ex. `rack-loader.rb`).
7
+ * The title that the spawned process should assume (ex: `Passenger RubyApp`).
8
+ * The default interpreter command for this language (ex: `ruby`). Related to `passenger_ruby`, among others.
9
+ * Zero or more names for the default startup file (ex: `config.ru`, `app.js`, `index.js`). Related to `passenger_startup_file`.
10
+
11
+ ## Synopsis
12
+
13
+ After construction, one can add entries to the registry. When done, one must call `finalize()` after which no more mutations are allowed. The Registry will contain some built-in, hardcoded entries after construction.
14
+
15
+ Given a language identifier, the Registry can lookup the corresponding Entry.
16
+
17
+ ~~~c++
18
+ Registry reg;
19
+ reg.finalize();
20
+
21
+ const Entry &ruby = reg.lookup("ruby");
22
+ cout << ruby.language << endl; // => ruby
23
+ cout << ruby.path << endl; // => rack-loader.rb
24
+ // etc
25
+ ~~~
26
+
27
+ ## Properties
28
+
29
+ The Registry, after finalization, is a static, immutable, in-memory database. Default, built-in, hardcoded entries are inserted during object creation. Registry allows adding additional entries after creation, but this functionality is not actually used and is reserved for the future. So at present, the Registry will only contain a small number of known entries.
30
+
31
+ After finalization, Registry is thread-safe because of its immutability.
32
+
33
+ Entries' lifetimes are the same as that of the Registry itself.
34
+
35
+ ## Relationships
36
+
37
+ The wrapper registry's main use is to be used by the AppTypeDetector, to detect what kind of application lives in a certain directory, and (if applicable) which wrapper should be used.
@@ -0,0 +1,309 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2018 Phusion Holding B.V.
4
+ *
5
+ * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
+ * trademarks of Phusion Holding B.V.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ * THE SOFTWARE.
25
+ */
26
+ #ifndef _PASSENGER_WRAPPER_REGISTRY_REGISTRY_H_
27
+ #define _PASSENGER_WRAPPER_REGISTRY_REGISTRY_H_
28
+
29
+ #include <cassert>
30
+ #include <cstddef>
31
+
32
+ #include <boost/foreach.hpp>
33
+ #include <boost/shared_array.hpp>
34
+ #include <oxt/macros.hpp>
35
+
36
+ #include <WrapperRegistry/Entry.h>
37
+ #include <DataStructures/StringKeyTable.h>
38
+ #include <Constants.h>
39
+ #include <Utils.h>
40
+ #include <Utils/StrIntUtils.h>
41
+
42
+ namespace Passenger {
43
+ namespace WrapperRegistry {
44
+
45
+ using namespace std;
46
+
47
+
48
+ class Registry {
49
+ public:
50
+ typedef StringKeyTable<Entry>::ConstIterator ConstIterator;
51
+
52
+ private:
53
+ StringKeyTable<Entry> entries;
54
+ StringKeyTable<HashedStaticString> aliases;
55
+ boost::shared_array<char> storage;
56
+ const Entry nullEntry;
57
+ bool finalized;
58
+
59
+ void internStrings() {
60
+ size_t totalSize = 0;
61
+ size_t tmpSize;
62
+ char *newStorage, *pos, *end;
63
+
64
+ // Calculate required storage size
65
+ {
66
+ StringKeyTable<Entry>::ConstIterator it(entries);
67
+ while (*it != NULL) {
68
+ const Entry &entry = it.getValue();
69
+
70
+ totalSize += entry.language.size() + 1;
71
+ totalSize += entry.languageDisplayName.size() + 1;
72
+ totalSize += entry.path.size() + 1;
73
+ totalSize += entry.processTitle.size() + 1;
74
+ totalSize += entry.defaultInterpreter.size() + 1;
75
+ foreach (const StaticString &defaultStartupFile,
76
+ entry.defaultStartupFiles)
77
+ {
78
+ totalSize += defaultStartupFile.size() + 1;
79
+ }
80
+
81
+ it.next();
82
+ }
83
+ }
84
+ {
85
+ StringKeyTable<HashedStaticString>::ConstIterator it(aliases);
86
+ while (*it != NULL) {
87
+ const HashedStaticString &name = it.getValue();
88
+ totalSize += name.size() + 1;
89
+ it.next();
90
+ }
91
+ }
92
+
93
+ // Allocate new storage
94
+ newStorage = pos = new char[totalSize];
95
+ end = newStorage + totalSize;
96
+
97
+ // Fill new storage
98
+ {
99
+ StringKeyTable<Entry>::ConstIterator it(entries);
100
+ while (*it != NULL) {
101
+ const Entry &entry = it.getValue();
102
+
103
+ pos = appendData(pos, end, entry.language);
104
+ pos = appendData(pos, end, "\0", 1);
105
+
106
+ pos = appendData(pos, end, entry.languageDisplayName);
107
+ pos = appendData(pos, end, "\0", 1);
108
+
109
+ pos = appendData(pos, end, entry.path);
110
+ pos = appendData(pos, end, "\0", 1);
111
+
112
+ pos = appendData(pos, end, entry.processTitle);
113
+ pos = appendData(pos, end, "\0", 1);
114
+
115
+ pos = appendData(pos, end, entry.defaultInterpreter);
116
+ pos = appendData(pos, end, "\0", 1);
117
+
118
+ foreach (const StaticString &defaultStartupFile,
119
+ entry.defaultStartupFiles)
120
+ {
121
+ pos = appendData(pos, end, defaultStartupFile);
122
+ pos = appendData(pos, end, "\0", 1);
123
+ }
124
+
125
+ it.next();
126
+ }
127
+ }
128
+ {
129
+ StringKeyTable<HashedStaticString>::ConstIterator it(aliases);
130
+ while (*it != NULL) {
131
+ const HashedStaticString &name = it.getValue();
132
+ pos = appendData(pos, end, name);
133
+ pos = appendData(pos, end, "\0", 1);
134
+ it.next();
135
+ }
136
+ }
137
+
138
+ // Move over pointers to new storage
139
+ {
140
+ StringKeyTable<Entry>::Iterator it(entries);
141
+ pos = newStorage;
142
+ while (*it != NULL) {
143
+ Entry &entry = it.getValue();
144
+
145
+ tmpSize = entry.language.size();
146
+ entry.language = StaticString(pos, tmpSize);
147
+ pos += tmpSize + 1;
148
+
149
+ tmpSize = entry.languageDisplayName.size();
150
+ entry.languageDisplayName = StaticString(pos, tmpSize);
151
+ pos += tmpSize + 1;
152
+
153
+ tmpSize = entry.path.size();
154
+ entry.path = StaticString(pos, tmpSize);
155
+ pos += tmpSize + 1;
156
+
157
+ tmpSize = entry.processTitle.size();
158
+ entry.processTitle = StaticString(pos, tmpSize);
159
+ pos += tmpSize + 1;
160
+
161
+ tmpSize = entry.defaultInterpreter.size();
162
+ entry.defaultInterpreter = StaticString(pos, tmpSize);
163
+ pos += tmpSize + 1;
164
+
165
+ foreach (StaticString &defaultStartupFile,
166
+ entry.defaultStartupFiles)
167
+ {
168
+ tmpSize = defaultStartupFile.size();
169
+ defaultStartupFile = StaticString(pos, tmpSize);
170
+ pos += tmpSize + 1;
171
+ }
172
+
173
+ it.next();
174
+ }
175
+ }
176
+ {
177
+ StringKeyTable<HashedStaticString>::Iterator it(aliases);
178
+ while (*it != NULL) {
179
+ HashedStaticString &name = it.getValue();
180
+ tmpSize = name.size();
181
+ name = StaticString(pos, tmpSize);
182
+ pos += tmpSize + 1;
183
+ it.next();
184
+ }
185
+ }
186
+
187
+ // Commit current storage
188
+ storage.reset(newStorage);
189
+ }
190
+
191
+ void
192
+ addBuiltinEntries() {
193
+ {
194
+ Entry entry;
195
+ entry.language = "ruby";
196
+ entry.languageDisplayName = "Ruby";
197
+ entry.path = "rack-loader.rb";
198
+ entry.processTitle = SHORT_PROGRAM_NAME " RubyApp";
199
+ entry.defaultInterpreter = "ruby";
200
+ entry.defaultStartupFiles.push_back("config.ru");
201
+ entries.insert(entry.language, entry);
202
+ aliases.insert("rack", "ruby");
203
+ }
204
+
205
+ {
206
+ Entry entry;
207
+ entry.language = "nodejs";
208
+ entry.languageDisplayName = "Node.js";
209
+ entry.path = "node-loader.js";
210
+ entry.processTitle = SHORT_PROGRAM_NAME " NodejsApp";
211
+ entry.defaultInterpreter = "node";
212
+ // Other code in Passenger does not yet support the notion
213
+ // of multiple defaultStartupFiles.
214
+ //entry.defaultStartupFiles.push_back("index.js");
215
+ entry.defaultStartupFiles.push_back("app.js");
216
+ entries.insert(entry.language, entry);
217
+ aliases.insert("node", "nodejs");
218
+ }
219
+
220
+ {
221
+ Entry entry;
222
+ entry.language = "python";
223
+ entry.languageDisplayName = "Python";
224
+ entry.path = "wsgi-loader.py";
225
+ entry.processTitle = SHORT_PROGRAM_NAME " PythonApp";
226
+ entry.defaultInterpreter = "python";
227
+ entry.defaultStartupFiles.push_back("passenger_wsgi.py");
228
+ entries.insert(entry.language, entry);
229
+ aliases.insert("wsgi", "python");
230
+ }
231
+
232
+ {
233
+ Entry entry;
234
+ entry.language = "meteor";
235
+ entry.languageDisplayName = "Meteor";
236
+ entry.path = "meteor-loader.rb";
237
+ entry.processTitle = SHORT_PROGRAM_NAME " MeteorApp";
238
+ entry.defaultInterpreter = "ruby"; // because meteor-loader.rb is in Ruby
239
+ entry.defaultStartupFiles.push_back(".meteor");
240
+ entries.insert(entry.language, entry);
241
+ }
242
+
243
+ internStrings();
244
+ }
245
+
246
+ public:
247
+ Registry()
248
+ : finalized(false)
249
+ {
250
+ addBuiltinEntries();
251
+ }
252
+
253
+ bool add(const Entry &entry) {
254
+ assert(!isFinalized());
255
+ // Disallow overwriting builtin entries for security reasons.
256
+ // Not sure whether overwriting builtin entries can be harmful
257
+ // but let's err on the safe side.
258
+ bool result = entries.insert(entry.language, entry, false);
259
+ internStrings();
260
+ return result;
261
+ }
262
+
263
+ bool isFinalized() const {
264
+ return finalized;
265
+ }
266
+
267
+ void finalize() {
268
+ assert(!isFinalized());
269
+ entries.compact();
270
+ aliases.compact();
271
+ finalized = true;
272
+ }
273
+
274
+ const Entry &lookup(const HashedStaticString &name) const {
275
+ assert(isFinalized());
276
+
277
+ if (OXT_UNLIKELY(name.empty())) {
278
+ return nullEntry;
279
+ }
280
+
281
+ const Entry *result;
282
+ HashedStaticString aliasTarget = aliases.lookupCopy(name);
283
+ if (aliasTarget.empty()) {
284
+ entries.lookup(name, &result);
285
+ } else {
286
+ entries.lookup(aliasTarget, &result);
287
+ }
288
+ if (result != NULL) {
289
+ return *result;
290
+ } else {
291
+ return nullEntry;
292
+ }
293
+ }
294
+
295
+ const Entry &getNullEntry() const {
296
+ return nullEntry;
297
+ }
298
+
299
+ ConstIterator getIterator() const {
300
+ assert(isFinalized());
301
+ return ConstIterator(entries);
302
+ }
303
+ };
304
+
305
+
306
+ } // namespace WrapperRegistry
307
+ } // namespace Passenger
308
+
309
+ #endif /* _PASSENGER_WRAPPER_REGISTRY_REGISTRY_H_ */
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Phusion Passenger - https://www.phusionpassenger.com/
3
- # Copyright (c) 2010-2017 Phusion Holding B.V.
3
+ # Copyright (c) 2010-2018 Phusion Holding B.V.
4
4
  #
5
5
  # "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  # trademarks of Phusion Holding B.V.
@@ -95,7 +95,11 @@ def download(name, options = {})
95
95
  end
96
96
 
97
97
  def really_download(site, name, logger, options)
98
- url = "#{site[:url]}/#{PhusionPassenger::VERSION_STRING}/#{name}"
98
+ if site[:url].include?('{{VERSION}}')
99
+ url = site[:url].gsub('{{VERSION}}', PhusionPassenger::VERSION_STRING) + "/#{name}"
100
+ else
101
+ url = "#{site[:url]}/#{PhusionPassenger::VERSION_STRING}/#{name}"
102
+ end
99
103
  puts "Attempting to download #{url} into #{Dir.pwd}"
100
104
  File.unlink("#{name}.tmp") rescue nil
101
105
 
@@ -134,6 +134,22 @@
134
134
  offsetof(passenger_main_conf_t, autogenerated.security_update_check_proxy),
135
135
  NULL
136
136
  },
137
+ {
138
+ ngx_string("passenger_disable_anonymous_telemetry"),
139
+ NGX_HTTP_MAIN_CONF | NGX_CONF_FLAG,
140
+ passenger_conf_set_disable_anonymous_telemetry,
141
+ NGX_HTTP_MAIN_CONF_OFFSET,
142
+ offsetof(passenger_main_conf_t, autogenerated.disable_anonymous_telemetry),
143
+ NULL
144
+ },
145
+ {
146
+ ngx_string("passenger_anonymous_telemetry_proxy"),
147
+ NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE1,
148
+ passenger_conf_set_anonymous_telemetry_proxy,
149
+ NGX_HTTP_MAIN_CONF_OFFSET,
150
+ offsetof(passenger_main_conf_t, autogenerated.anonymous_telemetry_proxy),
151
+ NULL
152
+ },
137
153
  {
138
154
  ngx_string("passenger_pre_start"),
139
155
  NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE1,
@@ -87,6 +87,12 @@ set_manifest_autogenerated_global_conf_defaults(manifest_gen_ctx_t *ctx) {
87
87
  sizeof("passenger_disable_security_update_check") - 1,
88
88
  0);
89
89
 
90
+ add_manifest_options_container_static_default_bool(ctx,
91
+ ctx->global_config_container,
92
+ "passenger_disable_anonymous_telemetry",
93
+ sizeof("passenger_disable_anonymous_telemetry") - 1,
94
+ 0);
95
+
90
96
  add_manifest_options_container_dynamic_default(ctx,
91
97
  ctx->global_config_container,
92
98
  "passenger_instance_registry_dir",
@@ -217,6 +217,30 @@ passenger_conf_set_security_update_check_proxy(ngx_conf_t *cf, ngx_command_t *cm
217
217
  return ngx_conf_set_str_slot(cf, cmd, conf);
218
218
  }
219
219
 
220
+ static char *
221
+ passenger_conf_set_disable_anonymous_telemetry(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
222
+ passenger_main_conf_t *passenger_conf = conf;
223
+
224
+ passenger_conf->autogenerated.disable_anonymous_telemetry_explicitly_set = 1;
225
+ record_main_conf_source_location(cf,
226
+ &passenger_conf->autogenerated.disable_anonymous_telemetry_source_file,
227
+ &passenger_conf->autogenerated.disable_anonymous_telemetry_source_line);
228
+
229
+ return ngx_conf_set_flag_slot(cf, cmd, conf);
230
+ }
231
+
232
+ static char *
233
+ passenger_conf_set_anonymous_telemetry_proxy(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
234
+ passenger_main_conf_t *passenger_conf = conf;
235
+
236
+ passenger_conf->autogenerated.anonymous_telemetry_proxy_explicitly_set = 1;
237
+ record_main_conf_source_location(cf,
238
+ &passenger_conf->autogenerated.anonymous_telemetry_proxy_source_file,
239
+ &passenger_conf->autogenerated.anonymous_telemetry_proxy_source_line);
240
+
241
+ return ngx_conf_set_str_slot(cf, cmd, conf);
242
+ }
243
+
220
244
  static char *
221
245
  passenger_conf_set_pre_start(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
222
246
  passenger_main_conf_t *passenger_conf = conf;
@@ -169,6 +169,11 @@ map_uri_to_page_cache_file(ngx_http_request_t *r, ngx_str_t *public_dir,
169
169
  }
170
170
  }
171
171
 
172
+ static void
173
+ cleanup_detector_result(void *data) {
174
+ psg_app_type_detector_result_deinit((PsgAppTypeDetectorResult *) data);
175
+ }
176
+
172
177
  static int
173
178
  find_base_uri(ngx_http_request_t *r, const passenger_loc_conf_t *loc,
174
179
  ngx_str_t *found_base_uri)
@@ -357,6 +362,7 @@ prepare_request_buffer_construction(ngx_http_request_t *r, passenger_context_t *
357
362
  #if (NGX_HAVE_INET6)
358
363
  struct sockaddr_in6 *sin6;
359
364
  #endif
365
+ const PsgWrapperRegistryEntry *wrapper_registry_entry;
360
366
 
361
367
  switch (r->method) {
362
368
  case NGX_HTTP_GET:
@@ -409,9 +415,10 @@ prepare_request_buffer_construction(ngx_http_request_t *r, passenger_context_t *
409
415
  break;
410
416
  }
411
417
 
412
- state->app_type.data = (u_char *) pp_get_app_type_name(context->app_type);
413
- /* Include null terminator */
414
- state->app_type.len = strlen((const char *) state->app_type.data);
418
+ wrapper_registry_entry = psg_app_type_detector_result_get_wrapper_registry_entry(
419
+ context->detector_result);
420
+ state->app_type.data = (u_char *) psg_wrapper_registry_entry_get_language(wrapper_registry_entry,
421
+ &state->app_type.len);
415
422
 
416
423
  /*
417
424
  * Nginx unescapes URI's before passing them to Phusion Passenger,
@@ -1362,7 +1369,10 @@ passenger_content_handler(ngx_http_request_t *r)
1362
1369
  u_char page_cache_file_str[NGX_MAX_PATH + 1];
1363
1370
  ngx_str_t page_cache_file;
1364
1371
  passenger_context_t *context;
1372
+ void *detector_result_mem;
1373
+ ngx_pool_cleanup_t *detector_result_cleanup;
1365
1374
  PP_Error error;
1375
+ const PsgWrapperRegistryEntry *wrapper_registry_entry;
1366
1376
 
1367
1377
  if (passenger_main_conf.autogenerated.root_dir.len == 0) {
1368
1378
  return NGX_DECLINED;
@@ -1450,24 +1460,31 @@ passenger_content_handler(ngx_http_request_t *r)
1450
1460
  return passenger_static_content_handler(r, &page_cache_file);
1451
1461
  }
1452
1462
 
1463
+ detector_result_mem = ngx_palloc(r->pool,
1464
+ psg_app_type_detector_result_get_object_size());
1465
+ context->detector_result = psg_app_type_detector_result_init(detector_result_mem);
1466
+ detector_result_cleanup = ngx_pool_cleanup_add(r->pool, 0);
1467
+ detector_result_cleanup->handler = cleanup_detector_result;
1468
+ detector_result_cleanup->data = context->detector_result;
1469
+
1453
1470
  if (slcf->autogenerated.app_type.data == NULL) {
1454
1471
  pp_error_init(&error);
1455
1472
  if (slcf->autogenerated.app_root.data == NULL) {
1456
- context->app_type = pp_app_type_detector_check_document_root(
1457
- pp_app_type_detector,
1473
+ psg_app_type_detector_check_document_root(
1474
+ psg_app_type_detector, context->detector_result,
1458
1475
  (const char *) context->public_dir.data, context->public_dir.len,
1459
1476
  context->base_uri.len != 0,
1460
1477
  &error);
1461
1478
  } else {
1462
- context->app_type = pp_app_type_detector_check_app_root(
1463
- pp_app_type_detector,
1479
+ psg_app_type_detector_check_app_root(
1480
+ psg_app_type_detector, context->detector_result,
1464
1481
  (const char *) slcf->autogenerated.app_root.data, slcf->autogenerated.app_root.len,
1465
1482
  &error);
1466
1483
  }
1467
- if (context->app_type == PAT_NONE) {
1468
- return NGX_DECLINED;
1469
- } else if (context->app_type == PAT_ERROR) {
1470
- if (error.errnoCode == EACCES) {
1484
+ if (psg_app_type_detector_result_is_null(context->detector_result)) {
1485
+ if (error.message == NULL) {
1486
+ return NGX_DECLINED;
1487
+ } else if (error.errnoCode == EACCES) {
1471
1488
  ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
1472
1489
  "%s; This error means that the Nginx worker process (PID %d, "
1473
1490
  "running as UID %d) does not have permission to access this file. "
@@ -1486,10 +1503,14 @@ passenger_content_handler(ngx_http_request_t *r)
1486
1503
  return NGX_HTTP_INTERNAL_SERVER_ERROR;
1487
1504
  }
1488
1505
  } else {
1489
- context->app_type = pp_get_app_type2((const char *) slcf->autogenerated.app_type.data,
1506
+ wrapper_registry_entry = psg_wrapper_registry_lookup(psg_wrapper_registry,
1507
+ (const char *) slcf->autogenerated.app_type.data,
1490
1508
  slcf->autogenerated.app_type.len);
1491
- if (context->app_type == PAT_NONE) {
1509
+ if (psg_wrapper_registry_entry_is_null(wrapper_registry_entry)) {
1492
1510
  return NGX_DECLINED;
1511
+ } else {
1512
+ psg_app_type_detector_result_set_wrapper_registry_entry(
1513
+ context->detector_result, wrapper_registry_entry);
1493
1514
  }
1494
1515
  }
1495
1516