passenger 5.2.1 → 5.2.2

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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +8 -0
  3. data/CODE_OF_CONDUCT.md +52 -0
  4. data/README.md +17 -9
  5. data/build/agent.rb +3 -1
  6. data/build/cxx_tests.rb +1 -0
  7. data/build/schema_printer.rb +1 -0
  8. data/build/support/cxx_dependency_map.rb +338 -31
  9. data/dev/configkit-schemas/index.json +64 -15
  10. data/dev/copy_boost_headers +1 -0
  11. data/images/justin.png +0 -0
  12. data/images/passenger_logo.svg +45 -0
  13. data/images/spark.png +0 -0
  14. data/resources/templates/standalone/http.erb +4 -0
  15. data/src/agent/AgentMain.cpp +4 -0
  16. data/src/agent/Core/AdminPanelConnector.h +133 -5
  17. data/src/agent/Core/ApplicationPool/Implementation.cpp +1 -0
  18. data/src/agent/Core/ApplicationPool/Options.h +7 -1
  19. data/src/agent/Core/ApplicationPool/Pool.h +1 -0
  20. data/src/agent/Core/ApplicationPool/Pool/GroupUtils.cpp +11 -0
  21. data/src/agent/Core/ApplicationPool/Process.cpp +52 -0
  22. data/src/agent/Core/ApplicationPool/Process.h +4 -8
  23. data/src/agent/Core/Config.h +6 -2
  24. data/src/agent/Core/ConfigChange.cpp +12 -1
  25. data/src/agent/Core/ConfigChange.h +3 -0
  26. data/src/agent/Core/Controller/Config.h +1 -1
  27. data/src/agent/Core/Controller/InitRequest.cpp +1 -1
  28. data/src/agent/Core/Controller/InternalUtils.cpp +2 -2
  29. data/src/agent/Core/CoreMain.cpp +18 -5
  30. data/src/agent/Core/SpawningKit/BackgroundIOCapturer.h +8 -4
  31. data/src/agent/Core/SpawningKit/DirectSpawner.h +3 -1
  32. data/src/agent/Core/SpawningKit/PipeWatcher.h +9 -4
  33. data/src/agent/Core/SpawningKit/SmartSpawner.h +5 -3
  34. data/src/agent/Core/SpawningKit/Spawner.h +1 -1
  35. data/src/agent/ExecHelper/ExecHelperMain.cpp +295 -0
  36. data/src/agent/Shared/Fundamentals/Initialization.cpp +11 -8
  37. data/src/agent/Shared/Fundamentals/Initialization.h +2 -2
  38. data/src/agent/Watchdog/Config.h +5 -2
  39. data/src/apache2_module/Config.cpp +13 -0
  40. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +30 -0
  41. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +90 -0
  42. data/src/apache2_module/ConfigGeneral/ManifestGeneration.h +18 -2
  43. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +5 -0
  44. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +12 -0
  45. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +7 -0
  46. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +13 -0
  47. data/src/apache2_module/Hooks.cpp +4 -0
  48. data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp +55 -0
  49. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +65 -0
  50. data/src/cxx_supportlib/BackgroundEventLoop.cpp +3 -3
  51. data/src/cxx_supportlib/ConfigKit/Schema.h +53 -31
  52. data/src/cxx_supportlib/ConfigKit/Store.h +12 -8
  53. data/src/cxx_supportlib/Constants.h +2 -1
  54. data/src/cxx_supportlib/DataStructures/StringKeyTable.h +4 -0
  55. data/src/cxx_supportlib/FileTools/PathManipCBindings.cpp +22 -1
  56. data/src/cxx_supportlib/FileTools/PathManipCBindings.h +3 -1
  57. data/src/cxx_supportlib/LoggingKit/Config.h +2 -0
  58. data/src/cxx_supportlib/LoggingKit/Context.h +28 -0
  59. data/src/cxx_supportlib/LoggingKit/Forward.h +0 -1
  60. data/src/cxx_supportlib/LoggingKit/Implementation.cpp +112 -9
  61. data/src/cxx_supportlib/LoggingKit/Logging.h +4 -2
  62. data/src/cxx_supportlib/WebSocketCommandReverseServer.h +34 -43
  63. data/src/cxx_supportlib/vendor-modified/boost/call_traits.hpp +20 -0
  64. data/src/cxx_supportlib/vendor-modified/boost/circular_buffer.hpp +62 -0
  65. data/src/cxx_supportlib/vendor-modified/boost/circular_buffer/base.hpp +3123 -0
  66. data/src/cxx_supportlib/vendor-modified/boost/circular_buffer/debug.hpp +248 -0
  67. data/src/cxx_supportlib/vendor-modified/boost/circular_buffer/details.hpp +498 -0
  68. data/src/cxx_supportlib/vendor-modified/boost/circular_buffer/space_optimized.hpp +1719 -0
  69. data/src/cxx_supportlib/vendor-modified/boost/circular_buffer_fwd.hpp +43 -0
  70. data/src/cxx_supportlib/vendor-modified/boost/detail/call_traits.hpp +172 -0
  71. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +48 -0
  72. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +72 -0
  73. data/src/nginx_module/ConfigGeneral/ManifestGeneration.c +32 -0
  74. data/src/nginx_module/ConfigGeneral/ManifestGeneration.h +3 -0
  75. data/src/nginx_module/Configuration.c +25 -0
  76. data/src/nginx_module/ContentHandler.c +42 -4
  77. data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +5 -0
  78. data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +13 -0
  79. data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +5 -0
  80. data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +4 -0
  81. data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c +30 -0
  82. data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c +60 -0
  83. data/src/nginx_module/MainConfig/AutoGeneratedStruct.h +20 -0
  84. data/src/nginx_module/ngx_http_passenger_module.c +4 -0
  85. data/src/ruby_supportlib/phusion_passenger.rb +1 -1
  86. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +37 -1
  87. data/src/ruby_supportlib/phusion_passenger/constants.rb +1 -0
  88. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +42 -1
  89. data/src/ruby_supportlib/phusion_passenger/packaging.rb +2 -0
  90. data/src/ruby_supportlib/phusion_passenger/platform_info/crypto.rb +13 -3
  91. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +20 -0
  92. metadata +16 -2
@@ -0,0 +1,43 @@
1
+ // Forward declaration of the circular buffer and its adaptor.
2
+
3
+ // Copyright (c) 2003-2008 Jan Gaspar
4
+
5
+ // Use, modification, and distribution is subject to the Boost Software
6
+ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7
+ // http://www.boost.org/LICENSE_1_0.txt)
8
+
9
+ // See www.boost.org/libs/circular_buffer for documentation.
10
+
11
+ #if !defined(BOOST_CIRCULAR_BUFFER_FWD_HPP)
12
+ #define BOOST_CIRCULAR_BUFFER_FWD_HPP
13
+
14
+ #if defined(_MSC_VER)
15
+ #pragma once
16
+ #endif
17
+
18
+ #include <boost/config.hpp>
19
+ #if !defined(BOOST_NO_STD_ALLOCATOR)
20
+ #include <memory>
21
+ #else
22
+ #include <vector>
23
+ #endif
24
+
25
+ namespace boost {
26
+
27
+ #if !defined(BOOST_NO_STD_ALLOCATOR)
28
+ #define BOOST_CB_DEFAULT_ALLOCATOR(T) std::allocator<T>
29
+ #else
30
+ #define BOOST_CB_DEFAULT_ALLOCATOR(T) BOOST_DEDUCED_TYPENAME std::vector<T>::allocator_type
31
+ #endif
32
+
33
+ template <class T, class Alloc = BOOST_CB_DEFAULT_ALLOCATOR(T)>
34
+ class circular_buffer;
35
+
36
+ template <class T, class Alloc = BOOST_CB_DEFAULT_ALLOCATOR(T)>
37
+ class circular_buffer_space_optimized;
38
+
39
+ #undef BOOST_CB_DEFAULT_ALLOCATOR
40
+
41
+ } // namespace boost
42
+
43
+ #endif // #if !defined(BOOST_CIRCULAR_BUFFER_FWD_HPP)
@@ -0,0 +1,172 @@
1
+ // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
2
+ // Use, modification and distribution are subject to the Boost Software License,
3
+ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4
+ // http://www.boost.org/LICENSE_1_0.txt).
5
+ //
6
+ // See http://www.boost.org/libs/utility for most recent version including documentation.
7
+
8
+ // call_traits: defines typedefs for function usage
9
+ // (see libs/utility/call_traits.htm)
10
+
11
+ /* Release notes:
12
+ 23rd July 2000:
13
+ Fixed array specialization. (JM)
14
+ Added Borland specific fixes for reference types
15
+ (issue raised by Steve Cleary).
16
+ */
17
+
18
+ #ifndef BOOST_DETAIL_CALL_TRAITS_HPP
19
+ #define BOOST_DETAIL_CALL_TRAITS_HPP
20
+
21
+ #ifndef BOOST_CONFIG_HPP
22
+ #include <boost/config.hpp>
23
+ #endif
24
+ #include <cstddef>
25
+
26
+ #include <boost/type_traits/is_arithmetic.hpp>
27
+ #include <boost/type_traits/is_enum.hpp>
28
+ #include <boost/type_traits/is_pointer.hpp>
29
+ #include <boost/detail/workaround.hpp>
30
+
31
+ namespace boost{
32
+
33
+ namespace detail{
34
+
35
+ template <typename T, bool small_>
36
+ struct ct_imp2
37
+ {
38
+ typedef const T& param_type;
39
+ };
40
+
41
+ template <typename T>
42
+ struct ct_imp2<T, true>
43
+ {
44
+ typedef const T param_type;
45
+ };
46
+
47
+ template <typename T, bool isp, bool b1, bool b2>
48
+ struct ct_imp
49
+ {
50
+ typedef const T& param_type;
51
+ };
52
+
53
+ template <typename T, bool isp, bool b2>
54
+ struct ct_imp<T, isp, true, b2>
55
+ {
56
+ typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
57
+ };
58
+
59
+ template <typename T, bool isp, bool b1>
60
+ struct ct_imp<T, isp, b1, true>
61
+ {
62
+ typedef typename ct_imp2<T, sizeof(T) <= sizeof(void*)>::param_type param_type;
63
+ };
64
+
65
+ template <typename T, bool b1, bool b2>
66
+ struct ct_imp<T, true, b1, b2>
67
+ {
68
+ typedef const T param_type;
69
+ };
70
+
71
+ }
72
+
73
+ template <typename T>
74
+ struct call_traits
75
+ {
76
+ public:
77
+ typedef T value_type;
78
+ typedef T& reference;
79
+ typedef const T& const_reference;
80
+ //
81
+ // C++ Builder workaround: we should be able to define a compile time
82
+ // constant and pass that as a single template parameter to ct_imp<T,bool>,
83
+ // however compiler bugs prevent this - instead pass three bool's to
84
+ // ct_imp<T,bool,bool,bool> and add an extra partial specialisation
85
+ // of ct_imp to handle the logic. (JM)
86
+ typedef typename boost::detail::ct_imp<
87
+ T,
88
+ ::boost::is_pointer<T>::value,
89
+ ::boost::is_arithmetic<T>::value,
90
+ ::boost::is_enum<T>::value
91
+ >::param_type param_type;
92
+ };
93
+
94
+ template <typename T>
95
+ struct call_traits<T&>
96
+ {
97
+ typedef T& value_type;
98
+ typedef T& reference;
99
+ typedef const T& const_reference;
100
+ typedef T& param_type; // hh removed const
101
+ };
102
+
103
+ #if BOOST_WORKAROUND( __BORLANDC__, < 0x5A0 )
104
+ // these are illegal specialisations; cv-qualifies applied to
105
+ // references have no effect according to [8.3.2p1],
106
+ // C++ Builder requires them though as it treats cv-qualified
107
+ // references as distinct types...
108
+ template <typename T>
109
+ struct call_traits<T&const>
110
+ {
111
+ typedef T& value_type;
112
+ typedef T& reference;
113
+ typedef const T& const_reference;
114
+ typedef T& param_type; // hh removed const
115
+ };
116
+ template <typename T>
117
+ struct call_traits<T&volatile>
118
+ {
119
+ typedef T& value_type;
120
+ typedef T& reference;
121
+ typedef const T& const_reference;
122
+ typedef T& param_type; // hh removed const
123
+ };
124
+ template <typename T>
125
+ struct call_traits<T&const volatile>
126
+ {
127
+ typedef T& value_type;
128
+ typedef T& reference;
129
+ typedef const T& const_reference;
130
+ typedef T& param_type; // hh removed const
131
+ };
132
+
133
+ template <typename T>
134
+ struct call_traits< T * >
135
+ {
136
+ typedef T * value_type;
137
+ typedef T * & reference;
138
+ typedef T * const & const_reference;
139
+ typedef T * const param_type; // hh removed const
140
+ };
141
+ #endif
142
+ #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
143
+ template <typename T, std::size_t N>
144
+ struct call_traits<T [N]>
145
+ {
146
+ private:
147
+ typedef T array_type[N];
148
+ public:
149
+ // degrades array to pointer:
150
+ typedef const T* value_type;
151
+ typedef array_type& reference;
152
+ typedef const array_type& const_reference;
153
+ typedef const T* const param_type;
154
+ };
155
+
156
+ template <typename T, std::size_t N>
157
+ struct call_traits<const T [N]>
158
+ {
159
+ private:
160
+ typedef const T array_type[N];
161
+ public:
162
+ // degrades array to pointer:
163
+ typedef const T* value_type;
164
+ typedef array_type& reference;
165
+ typedef const array_type& const_reference;
166
+ typedef const T* const param_type;
167
+ };
168
+ #endif
169
+
170
+ }
171
+
172
+ #endif // BOOST_DETAIL_CALL_TRAITS_HPP
@@ -62,6 +62,14 @@
62
62
  offsetof(passenger_main_conf_t, autogenerated.abort_on_startup_error),
63
63
  NULL
64
64
  },
65
+ {
66
+ ngx_string("passenger_dump_config_manifest"),
67
+ NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE1,
68
+ passenger_conf_set_dump_config_manifest,
69
+ NGX_HTTP_MAIN_CONF_OFFSET,
70
+ offsetof(passenger_main_conf_t, autogenerated.dump_config_manifest),
71
+ NULL
72
+ },
65
73
  {
66
74
  ngx_string("passenger_log_level"),
67
75
  NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE1,
@@ -222,6 +230,38 @@
222
230
  offsetof(passenger_loc_conf_t, autogenerated.app_file_descriptor_ulimit),
223
231
  NULL
224
232
  },
233
+ {
234
+ ngx_string("passenger_admin_panel_url"),
235
+ NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE1,
236
+ passenger_conf_set_admin_panel_url,
237
+ NGX_HTTP_MAIN_CONF_OFFSET,
238
+ offsetof(passenger_main_conf_t, autogenerated.admin_panel_url),
239
+ NULL
240
+ },
241
+ {
242
+ ngx_string("passenger_admin_panel_auth_type"),
243
+ NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE1,
244
+ passenger_conf_set_admin_panel_auth_type,
245
+ NGX_HTTP_MAIN_CONF_OFFSET,
246
+ offsetof(passenger_main_conf_t, autogenerated.admin_panel_auth_type),
247
+ NULL
248
+ },
249
+ {
250
+ ngx_string("passenger_admin_panel_username"),
251
+ NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE1,
252
+ passenger_conf_set_admin_panel_username,
253
+ NGX_HTTP_MAIN_CONF_OFFSET,
254
+ offsetof(passenger_main_conf_t, autogenerated.admin_panel_username),
255
+ NULL
256
+ },
257
+ {
258
+ ngx_string("passenger_admin_panel_password"),
259
+ NGX_HTTP_MAIN_CONF | NGX_CONF_TAKE1,
260
+ passenger_conf_set_admin_panel_password,
261
+ NGX_HTTP_MAIN_CONF_OFFSET,
262
+ offsetof(passenger_main_conf_t, autogenerated.admin_panel_password),
263
+ NULL
264
+ },
225
265
  {
226
266
  ngx_string("passenger_enabled"),
227
267
  NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_HTTP_LIF_CONF | NGX_CONF_FLAG,
@@ -350,6 +390,14 @@
350
390
  offsetof(passenger_loc_conf_t, autogenerated.app_group_name),
351
391
  NULL
352
392
  },
393
+ {
394
+ ngx_string("passenger_monitor_log_file"),
395
+ NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_HTTP_LIF_CONF | NGX_CONF_TAKE1,
396
+ passenger_conf_set_monitor_log_file,
397
+ NGX_HTTP_LOC_CONF_OFFSET,
398
+ offsetof(passenger_loc_conf_t, autogenerated.monitor_log_file),
399
+ NULL
400
+ },
353
401
  {
354
402
  ngx_string("passenger_app_root"),
355
403
  NGX_HTTP_MAIN_CONF | NGX_HTTP_SRV_CONF | NGX_HTTP_LOC_CONF | NGX_HTTP_LIF_CONF | NGX_CONF_TAKE1,
@@ -109,6 +109,18 @@ passenger_conf_set_abort_on_startup_error(ngx_conf_t *cf, ngx_command_t *cmd, vo
109
109
  return ngx_conf_set_flag_slot(cf, cmd, conf);
110
110
  }
111
111
 
112
+ static char *
113
+ passenger_conf_set_dump_config_manifest(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
114
+ passenger_main_conf_t *passenger_conf = conf;
115
+
116
+ passenger_conf->autogenerated.dump_config_manifest_explicitly_set = 1;
117
+ record_main_conf_source_location(cf,
118
+ &passenger_conf->autogenerated.dump_config_manifest_source_file,
119
+ &passenger_conf->autogenerated.dump_config_manifest_source_line);
120
+
121
+ return ngx_conf_set_str_slot(cf, cmd, conf);
122
+ }
123
+
112
124
  static char *
113
125
  passenger_conf_set_log_level(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
114
126
  passenger_main_conf_t *passenger_conf = conf;
@@ -349,6 +361,54 @@ passenger_conf_set_app_file_descriptor_ulimit(ngx_conf_t *cf, ngx_command_t *cmd
349
361
  return ngx_conf_set_num_slot(cf, cmd, conf);
350
362
  }
351
363
 
364
+ static char *
365
+ passenger_conf_set_admin_panel_url(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
366
+ passenger_main_conf_t *passenger_conf = conf;
367
+
368
+ passenger_conf->autogenerated.admin_panel_url_explicitly_set = 1;
369
+ record_main_conf_source_location(cf,
370
+ &passenger_conf->autogenerated.admin_panel_url_source_file,
371
+ &passenger_conf->autogenerated.admin_panel_url_source_line);
372
+
373
+ return ngx_conf_set_str_slot(cf, cmd, conf);
374
+ }
375
+
376
+ static char *
377
+ passenger_conf_set_admin_panel_auth_type(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
378
+ passenger_main_conf_t *passenger_conf = conf;
379
+
380
+ passenger_conf->autogenerated.admin_panel_auth_type_explicitly_set = 1;
381
+ record_main_conf_source_location(cf,
382
+ &passenger_conf->autogenerated.admin_panel_auth_type_source_file,
383
+ &passenger_conf->autogenerated.admin_panel_auth_type_source_line);
384
+
385
+ return ngx_conf_set_str_slot(cf, cmd, conf);
386
+ }
387
+
388
+ static char *
389
+ passenger_conf_set_admin_panel_username(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
390
+ passenger_main_conf_t *passenger_conf = conf;
391
+
392
+ passenger_conf->autogenerated.admin_panel_username_explicitly_set = 1;
393
+ record_main_conf_source_location(cf,
394
+ &passenger_conf->autogenerated.admin_panel_username_source_file,
395
+ &passenger_conf->autogenerated.admin_panel_username_source_line);
396
+
397
+ return ngx_conf_set_str_slot(cf, cmd, conf);
398
+ }
399
+
400
+ static char *
401
+ passenger_conf_set_admin_panel_password(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
402
+ passenger_main_conf_t *passenger_conf = conf;
403
+
404
+ passenger_conf->autogenerated.admin_panel_password_explicitly_set = 1;
405
+ record_main_conf_source_location(cf,
406
+ &passenger_conf->autogenerated.admin_panel_password_source_file,
407
+ &passenger_conf->autogenerated.admin_panel_password_source_line);
408
+
409
+ return ngx_conf_set_str_slot(cf, cmd, conf);
410
+ }
411
+
352
412
  static char *
353
413
  passenger_conf_set_ruby(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
354
414
  passenger_loc_conf_t *passenger_conf = conf;
@@ -529,6 +589,18 @@ passenger_conf_set_app_group_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf
529
589
  return ngx_conf_set_str_slot(cf, cmd, conf);
530
590
  }
531
591
 
592
+ static char *
593
+ passenger_conf_set_monitor_log_file(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
594
+ passenger_loc_conf_t *passenger_conf = conf;
595
+
596
+ passenger_conf->autogenerated.monitor_log_file_explicitly_set = 1;
597
+ record_loc_conf_source_location(cf, passenger_conf,
598
+ &passenger_conf->autogenerated.monitor_log_file_source_file,
599
+ &passenger_conf->autogenerated.monitor_log_file_source_line);
600
+
601
+ return ngx_conf_set_str_array_slot(cf, cmd, conf);
602
+ }
603
+
532
604
  static char *
533
605
  passenger_conf_set_app_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
534
606
  passenger_loc_conf_t *passenger_conf = conf;
@@ -146,6 +146,19 @@ infer_loc_conf_app_group_name(manifest_gen_ctx_t *ctx, passenger_loc_conf_t *plc
146
146
  return 1;
147
147
  }
148
148
 
149
+ static u_char *
150
+ infer_default_app_root(manifest_gen_ctx_t *ctx, ngx_http_core_loc_conf_t *clcf,
151
+ size_t *len)
152
+ {
153
+ u_char *path, *end;
154
+
155
+ path = ngx_pnalloc(ctx->cf->temp_pool, clcf->root.len + 3);
156
+ end = ngx_snprintf(path, clcf->root.len + 3,
157
+ "%V/..", &clcf->root);
158
+ return (u_char *) psg_absolutize_path((const char *) path,
159
+ end - path, NULL, 0, len);
160
+ }
161
+
149
162
  static PsgJsonValue *
150
163
  find_or_create_manifest_app_config_container(manifest_gen_ctx_t *ctx,
151
164
  ngx_str_t *app_group_name)
@@ -390,6 +403,7 @@ find_or_create_manifest_app_and_loc_options_containers(manifest_gen_ctx_t *ctx,
390
403
  {
391
404
  ngx_str_t app_group_name;
392
405
  PsgJsonValue *app_config_container, *loc_config_container;
406
+ ngx_str_t default_app_root;
393
407
 
394
408
  if (*app_options_container != NULL && *loc_options_container != NULL) {
395
409
  return;
@@ -405,6 +419,24 @@ find_or_create_manifest_app_and_loc_options_containers(manifest_gen_ctx_t *ctx,
405
419
  app_config_container = find_or_create_manifest_app_config_container(ctx, &app_group_name);
406
420
  *app_options_container = psg_json_value_get(app_config_container, "options", -1);
407
421
  *loc_options_container = psg_json_value_get(app_config_container, "default_location_configuration", -1);
422
+
423
+ /* Create a default value for passenger_app_root
424
+ * if we just created this config container
425
+ */
426
+ if (psg_json_value_size(*app_options_container) == 0) {
427
+ add_manifest_options_container_static_default_str(ctx,
428
+ *app_options_container,
429
+ "passenger_app_group_name", -1,
430
+ (const char *) app_group_name.data, app_group_name.len);
431
+
432
+ default_app_root.data = infer_default_app_root(
433
+ ctx, clcf, &default_app_root.len);
434
+ add_manifest_options_container_static_default_str(ctx,
435
+ *app_options_container,
436
+ "passenger_app_root", -1,
437
+ (const char *) default_app_root.data, default_app_root.len);
438
+ free(default_app_root.data);
439
+ }
408
440
  } else {
409
441
  /* We are in a location/if block */
410
442
  infer_loc_conf_app_group_name(ctx, plcf, clcf, &app_group_name);
@@ -4,6 +4,7 @@
4
4
  #include <ngx_config.h>
5
5
  #include <ngx_core.h>
6
6
  #include <ngx_http.h>
7
+ #include "cxx_supportlib/FileTools/PathManipCBindings.h"
7
8
  #include "cxx_supportlib/JsonTools/CBindings.h"
8
9
 
9
10
  #ifndef _PASSENGER_NGINX_MODULE_CONF_STRUCT_TYPEDEFS_H_
@@ -40,6 +41,8 @@ static void recursively_generate_config_manifest_for_loc_conf(manifest_gen_ctx_t
40
41
  passenger_loc_conf_t *plcf);
41
42
  static int infer_loc_conf_app_group_name(manifest_gen_ctx_t *ctx,
42
43
  passenger_loc_conf_t *plcf, ngx_http_core_loc_conf_t *clcf, ngx_str_t *result);
44
+ static u_char *infer_default_app_root(manifest_gen_ctx_t *ctx,
45
+ ngx_http_core_loc_conf_t *clcf, size_t *len);
43
46
  static void generate_config_manifest_for_loc_conf(manifest_gen_ctx_t *ctx,
44
47
  passenger_loc_conf_t *plcf, ngx_http_core_srv_conf_t *cscf,
45
48
  ngx_http_core_loc_conf_t *clcf);
@@ -991,6 +991,9 @@ passenger_postprocess_config(ngx_conf_t *cf)
991
991
  ngx_http_conf_ctx_t *http_ctx;
992
992
  passenger_loc_conf_t *toplevel_plcf;
993
993
  ngx_pool_cleanup_t *manifest_cleanup;
994
+ char *dump_path, *dump_content;
995
+ FILE *dump_file;
996
+ u_char *end;
994
997
 
995
998
  http_ctx = cf->ctx;
996
999
  toplevel_plcf = http_ctx->loc_conf[ngx_http_passenger_module.ctx_index];
@@ -1006,6 +1009,28 @@ passenger_postprocess_config(ngx_conf_t *cf)
1006
1009
  manifest_cleanup->handler = (ngx_pool_cleanup_pt) psg_json_value_free;
1007
1010
  manifest_cleanup->data = passenger_main_conf.manifest;
1008
1011
 
1012
+ if (passenger_main_conf.autogenerated.dump_config_manifest.len != 0) {
1013
+ dump_path = (char *) ngx_pnalloc(cf->temp_pool,
1014
+ passenger_main_conf.autogenerated.dump_config_manifest.len + 1);
1015
+ end = ngx_copy(dump_path,
1016
+ passenger_main_conf.autogenerated.dump_config_manifest.data,
1017
+ passenger_main_conf.autogenerated.dump_config_manifest.len);
1018
+ *end = '\0';
1019
+
1020
+ dump_file = fopen(dump_path, "w");
1021
+ if (dump_file != NULL) {
1022
+ dump_content = psg_json_value_to_styled_string(
1023
+ passenger_main_conf.manifest);
1024
+ fwrite(dump_content, 1, strlen(dump_content), dump_file);
1025
+ fclose(dump_file);
1026
+ free(dump_content);
1027
+ } else {
1028
+ ngx_conf_log_error(NGX_LOG_ALERT, cf, 0,
1029
+ "Error dumping " PROGRAM_NAME " configuration manifest to %V",
1030
+ &passenger_main_conf.autogenerated.dump_config_manifest);
1031
+ }
1032
+ }
1033
+
1009
1034
  return NGX_OK;
1010
1035
  }
1011
1036