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
@@ -45,6 +45,7 @@
45
45
  #include <Utils/JsonUtils.h>
46
46
  #include <Core/ApplicationPool/Pool.h>
47
47
  #include <Core/ApplicationPool/Group.h>
48
+ #include <Core/ApplicationPool/Process.cpp>
48
49
  #include <Core/ApplicationPool/ErrorRenderer.h>
49
50
  #include <Core/ApplicationPool/Pool/InitializationAndShutdown.cpp>
50
51
  #include <Core/ApplicationPool/Pool/AnalyticsCollection.cpp>
@@ -85,6 +85,7 @@ private:
85
85
 
86
86
  result.push_back(&options.appRoot);
87
87
  result.push_back(&options.appGroupName);
88
+ result.push_back(&options.appLogFile);
88
89
  result.push_back(&options.appType);
89
90
  result.push_back(&options.startCommand);
90
91
  result.push_back(&options.startupFile);
@@ -177,6 +178,11 @@ public:
177
178
  */
178
179
  HashedStaticString appGroupName;
179
180
 
181
+ /** The application's log file, where Passenger sends the logs from
182
+ * the application.
183
+ */
184
+ StaticString appLogFile;
185
+
180
186
  /** The application's type, used for determining the command to invoke to
181
187
  * spawn an application process as well as determining the startup file's
182
188
  * filename. It can be one of the app type names in AppType.cpp, or the
@@ -598,6 +604,7 @@ public:
598
604
  appendKeyValue (vec, "app_root", appRoot);
599
605
  appendKeyValue (vec, "app_group_name", getAppGroupName());
600
606
  appendKeyValue (vec, "app_type", appType);
607
+ appendKeyValue (vec, "app_log_file", appLogFile);
601
608
  appendKeyValue (vec, "start_command", getStartCommand(resourceLocator));
602
609
  appendKeyValue (vec, "startup_file", absolutizePath(getStartupFile(), absolutizePath(appRoot)));
603
610
  appendKeyValue (vec, "process_title", getProcessTitle());
@@ -716,4 +723,3 @@ public:
716
723
  } // namespace Passenger
717
724
 
718
725
  #endif /* _PASSENGER_APPLICATION_POOL2_OPTIONS_H_ */
719
-
@@ -392,6 +392,7 @@ public:
392
392
  };
393
393
 
394
394
  const GroupPtr getGroup(const char *name);
395
+ const pair<uid_t, gid_t> getGroupRunUidAndGids(const StaticString &appGroupName);
395
396
  Group *findMatchingGroup(const Options &options);
396
397
  GroupPtr createGroup(const Options &options);
397
398
  GroupPtr createGroupAndAsyncGetFromIt(const Options &options,
@@ -45,6 +45,17 @@ using namespace boost;
45
45
  *
46
46
  ****************************/
47
47
 
48
+ const pair<uid_t, gid_t>
49
+ Pool::getGroupRunUidAndGids(const StaticString &appGroupName) {
50
+ LockGuard l(syncher);
51
+ GroupPtr *group;
52
+ if (!groups.lookup(appGroupName.c_str(), &group)) {
53
+ throw RuntimeException("Could not find group: " + appGroupName);
54
+ } else {
55
+ SpawningKit::UserSwitchingInfo info = SpawningKit::prepareUserSwitching((*group)->options);
56
+ return pair<uid_t, gid_t>(info.uid,info.gid);
57
+ }
58
+ }
48
59
 
49
60
  const GroupPtr
50
61
  Pool::getGroup(const char *name) {
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2011-2017 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
+
27
+ #include <Core/ApplicationPool/Process.h>
28
+ #include <Core/ApplicationPool/Group.h>
29
+
30
+ namespace Passenger {
31
+ namespace ApplicationPool2 {
32
+
33
+ using namespace std;
34
+ using namespace boost;
35
+
36
+ SpawningKit::PipeWatcherPtr Process::makePipeWatcher(const SpawningKit::ConfigPtr &config, FileDescriptor socket, const char *channel, pid_t pid, const BasicGroupInfo *groupInfo) {
37
+ StaticString appLogFile;
38
+ HashedStaticString appGroupName;
39
+ if (groupInfo->group != NULL) {
40
+ appLogFile = groupInfo->group->options.appLogFile;
41
+ appGroupName = groupInfo->group->options.getAppGroupName();
42
+ }
43
+ SpawningKit::PipeWatcherPtr watcher = boost::make_shared<SpawningKit::PipeWatcher>(
44
+ config, socket, channel, pid, appGroupName, appLogFile
45
+ );
46
+ watcher->initialize();
47
+ watcher->start();
48
+ return watcher;
49
+ }
50
+
51
+ } // namespace ApplicationPool2
52
+ } // namespace Passenger
@@ -353,6 +353,8 @@ private:
353
353
  return result;
354
354
  }
355
355
 
356
+ SpawningKit::PipeWatcherPtr makePipeWatcher(const SpawningKit::ConfigPtr &config, FileDescriptor socket, const char *channel, pid_t pid, const BasicGroupInfo *groupInfo);
357
+
356
358
  public:
357
359
  /*************************************************************
358
360
  * Information used by Pool. Do not write to these from
@@ -454,17 +456,11 @@ public:
454
456
  errorPipe = skResult->errorPipe;
455
457
 
456
458
  if (adminSocket != -1) {
457
- SpawningKit::PipeWatcherPtr watcher = boost::make_shared<SpawningKit::PipeWatcher>(
458
- getContext()->getSpawningKitConfig(), adminSocket, "stdout", info.pid);
459
- watcher->initialize();
460
- watcher->start();
459
+ SpawningKit::PipeWatcherPtr watcher = makePipeWatcher(getContext()->getSpawningKitConfig(), adminSocket, "stdout", info.pid, groupInfo);
461
460
  }
462
461
 
463
462
  if (errorPipe != -1) {
464
- SpawningKit::PipeWatcherPtr watcher = boost::make_shared<SpawningKit::PipeWatcher>(
465
- getContext()->getSpawningKitConfig(), errorPipe, "stderr", info.pid);
466
- watcher->initialize();
467
- watcher->start();
463
+ SpawningKit::PipeWatcherPtr watcher = makePipeWatcher(getContext()->getSpawningKitConfig(), errorPipe, "stderr", info.pid, groupInfo);
468
464
  }
469
465
  }
470
466
  }
@@ -61,10 +61,12 @@ using namespace std;
61
61
  * (do not edit: following text is automatically generated
62
62
  * by 'rake configkit_schemas_inline_comments')
63
63
  *
64
- * admin_panel_authentication object - secret
64
+ * admin_panel_auth_type string - default("basic")
65
65
  * admin_panel_close_timeout float - default(10.0)
66
66
  * admin_panel_connect_timeout float - default(30.0)
67
67
  * admin_panel_data_debug boolean - default(false)
68
+ * admin_panel_password string - secret
69
+ * admin_panel_password_file string - -
68
70
  * admin_panel_ping_interval float - default(30.0)
69
71
  * admin_panel_ping_timeout float - default(30.0)
70
72
  * admin_panel_proxy_password string - secret
@@ -73,6 +75,7 @@ using namespace std;
73
75
  * admin_panel_proxy_username string - -
74
76
  * admin_panel_reconnect_timeout float - default(5.0)
75
77
  * admin_panel_url string - read_only
78
+ * admin_panel_username string - -
76
79
  * admin_panel_websocketpp_debug_access boolean - default(false)
77
80
  * admin_panel_websocketpp_debug_error boolean - default(false)
78
81
  * api_server_accept_burst_count unsigned integer - default(32)
@@ -150,7 +153,7 @@ using namespace std;
150
153
  * security_update_checker_interval unsigned integer - default(86400)
151
154
  * security_update_checker_proxy_url string - -
152
155
  * security_update_checker_url string - default("https://securitycheck.phusionpassenger.com/v1/check.json")
153
- * server_software string - default("Phusion_Passenger/5.2.1")
156
+ * server_software string - default("Phusion_Passenger/5.2.2")
154
157
  * show_version_in_header boolean - default(true)
155
158
  * single_app_mode_app_root string - default,read_only
156
159
  * single_app_mode_app_type string - read_only
@@ -380,6 +383,7 @@ public:
380
383
  loggingKit.translator.finalize();
381
384
  addSubSchema(loggingKit.schema, loggingKit.translator);
382
385
  erase("redirect_stderr");
386
+ erase("buffer_logs");
383
387
 
384
388
  // Add subschema: controller
385
389
  addSubSchemaPrefixTranslations<ServerKit::HttpServerSchema>(
@@ -180,7 +180,8 @@ asyncPrepareConfigChange(const Json::Value &updates, ConfigChangeRequest *req,
180
180
 
181
181
  ConfigKit::prepareConfigChangeForSubComponent(
182
182
  *LoggingKit::context, coreSchema->loggingKit.translator,
183
- req->config->inspectEffectiveValues(),
183
+ manipulateLoggingKitConfig(*req->config,
184
+ req->config->inspectEffectiveValues()),
184
185
  req->errors, req->forLoggingKit);
185
186
  ConfigKit::prepareConfigChangeForSubComponent(
186
187
  *workingObjects->securityUpdateChecker,
@@ -345,5 +346,15 @@ inspectConfig() {
345
346
  }
346
347
 
347
348
 
349
+ Json::Value
350
+ manipulateLoggingKitConfig(const ConfigKit::Store &coreConfig,
351
+ const Json::Value &loggingKitConfig)
352
+ {
353
+ Json::Value result = loggingKitConfig;
354
+ result["buffer_logs"] = !coreConfig["admin_panel_url"].isNull();
355
+ return result;
356
+ }
357
+
358
+
348
359
  } // namespace Core
349
360
  } // namespace Passenger
@@ -47,6 +47,9 @@ void asyncPrepareConfigChange(const Json::Value &updates, ConfigChangeRequest *r
47
47
  void asyncCommitConfigChange(ConfigChangeRequest *req, const CommitConfigChangeCallback &callback) BOOST_NOEXCEPT_OR_NOTHROW;
48
48
  Json::Value inspectConfig();
49
49
 
50
+ Json::Value manipulateLoggingKitConfig(const ConfigKit::Store &coreConfig,
51
+ const Json::Value &loggingKitConfig);
52
+
50
53
 
51
54
  } // namespace Core
52
55
  } // namespace Passenger
@@ -111,7 +111,7 @@ parseControllerBenchmarkMode(const StaticString &mode) {
111
111
  * multi_app boolean - default(true),read_only
112
112
  * request_freelist_limit unsigned integer - default(1024)
113
113
  * response_buffer_high_watermark unsigned integer - default(134217728)
114
- * server_software string - default("Phusion_Passenger/5.2.1")
114
+ * server_software string - default("Phusion_Passenger/5.2.2")
115
115
  * show_version_in_header boolean - default(true)
116
116
  * start_reading_after_accept boolean - default(true)
117
117
  * stat_throttle_rate unsigned integer - default(10)
@@ -353,7 +353,7 @@ Controller::createNewPoolOptions(Client *client, Request *req,
353
353
 
354
354
  options.appGroupName = appGroupName;
355
355
 
356
- fillPoolOption(req, options.appType, "!~PASSENGER_APP_TYPE");
356
+ fillPoolOption(req, options.appLogFile, "!~PASSENGER_APP_LOG_FILE");
357
357
  fillPoolOption(req, options.environment, "!~PASSENGER_APP_ENV");
358
358
  fillPoolOption(req, options.ruby, "!~PASSENGER_RUBY");
359
359
  fillPoolOption(req, options.python, "!~PASSENGER_PYTHON");
@@ -244,10 +244,10 @@ Controller::resolveSymlink(const StaticString &path, psg_pool_t *pool) {
244
244
  char *pos = data;
245
245
  char *end = data + resultlen;
246
246
 
247
- pos = appendData(pos, end, linkbuf, linkbuflen);
247
+ pos = appendData(pos, end, workingDir);
248
248
  *pos = '/';
249
249
  pos++;
250
- pos = appendData(pos, end, workingDir);
250
+ pos = appendData(pos, end, linkbuf, linkbuflen);
251
251
 
252
252
  return psg_lstr_create(pool, data, resultlen);
253
253
  }
@@ -863,6 +863,10 @@ initializeAdminPanelConnector() {
863
863
  connector->resourceLocator = &wo.resourceLocator;
864
864
  connector->appPool = wo.appPool;
865
865
  connector->configGetter = inspectConfig;
866
+ for (unsigned int i = 0; i < wo.threadWorkingObjects.size(); i++) {
867
+ ThreadWorkingObjects *two = &wo.threadWorkingObjects[i];
868
+ connector->controllers.push_back(two->controller);
869
+ }
866
870
  connector->initialize();
867
871
  wo.shutdownCounter.fetch_add(1, boost::memory_order_relaxed);
868
872
  wo.adminPanelConnector = connector;
@@ -925,14 +929,16 @@ warnIfPathVulnerable(const char *path, string &warnings) {
925
929
  warnings.append(path);
926
930
  warnings.append("\" can be modified by user \"");
927
931
  warnings.append(pathOwner.pw_name);
928
- warnings.append("\" (or applications running as that user). Change the owner of the path to root, or avoid running Passenger as root.");
932
+ warnings.append("\" (or applications running as that user)."
933
+ " Change the owner of the path to root, or avoid running " SHORT_PROGRAM_NAME " as root.");
929
934
  }
930
935
 
931
936
  // World writeable access rights
932
937
  if ((pathStat.st_mode & S_IWOTH) != 0) {
933
938
  warnings.append("\nThe path \"");
934
939
  warnings.append(path);
935
- warnings.append("\" is writeable by any user (or application). Limit write access on the path to only the root user/group.");
940
+ warnings.append("\" is writeable by any user (or application)."
941
+ " Limit write access on the path to only the root user/group.");
936
942
  }
937
943
  }
938
944
 
@@ -965,8 +971,9 @@ warnIfPassengerRootVulnerable() {
965
971
  }
966
972
  if (!warnings.empty()) {
967
973
  P_WARN("WARNING: potential privilege escalation vulnerability. "
968
- PROGRAM_NAME " is running as root, and part(s) of the passenger root path ("
969
- << root << ") can be changed by non-root user(s):" << warnings);
974
+ PROGRAM_NAME " is running as root, and part(s) of the "
975
+ SHORT_PROGRAM_NAME " root path (" << root
976
+ << ") can be changed by non-root user(s):" << warnings);
970
977
  }
971
978
  }
972
979
 
@@ -1309,6 +1316,12 @@ parseOptions(int argc, const char *argv[], ConfigKit::Store &config) {
1309
1316
  }
1310
1317
  }
1311
1318
 
1319
+ static void
1320
+ loggingKitPreInitFunc(Json::Value &loggingKitInitialConfig) {
1321
+ loggingKitInitialConfig = manipulateLoggingKitConfig(*coreConfig,
1322
+ loggingKitInitialConfig);
1323
+ }
1324
+
1312
1325
  int
1313
1326
  coreMain(int argc, char *argv[]) {
1314
1327
  int ret;
@@ -1317,7 +1330,7 @@ coreMain(int argc, char *argv[]) {
1317
1330
  coreConfig = new ConfigKit::Store(*coreSchema);
1318
1331
  initializeAgent(argc, &argv, SHORT_PROGRAM_NAME " core",
1319
1332
  *coreConfig, coreSchema->loggingKit.translator,
1320
- parseOptions, NULL, 2);
1333
+ parseOptions, loggingKitPreInitFunc, 2);
1321
1334
 
1322
1335
  #if !BOOST_OS_MACOS
1323
1336
  restoreOomScore(coreConfig->get("oom_score").asString());
@@ -63,6 +63,8 @@ private:
63
63
  boost::mutex dataSyncher;
64
64
  string data;
65
65
  oxt::thread *thr;
66
+ const HashedStaticString &appGroupName;
67
+ const StaticString &appLogFile;
66
68
 
67
69
  void capture() {
68
70
  TRACE_POINT();
@@ -89,7 +91,7 @@ private:
89
91
  }
90
92
  UPDATE_TRACE_POINT();
91
93
  if (ret == 1 && buf[0] == '\n') {
92
- LoggingKit::logAppOutput(pid, channelName, "", 0);
94
+ LoggingKit::logAppOutput(appGroupName, pid, channelName, "", 0, appLogFile);
93
95
  } else {
94
96
  vector<StaticString> lines;
95
97
  if (ret > 0 && buf[ret - 1] == '\n') {
@@ -97,7 +99,7 @@ private:
97
99
  }
98
100
  split(StaticString(buf, ret), '\n', lines);
99
101
  foreach (const StaticString line, lines) {
100
- LoggingKit::logAppOutput(pid, channelName, line.data(), line.size());
102
+ LoggingKit::logAppOutput(appGroupName, pid, channelName, line.data(), line.size(), appLogFile);
101
103
  }
102
104
  }
103
105
  }
@@ -105,11 +107,13 @@ private:
105
107
  }
106
108
 
107
109
  public:
108
- BackgroundIOCapturer(const FileDescriptor &_fd, pid_t _pid, const char *_channelName)
110
+ BackgroundIOCapturer(const FileDescriptor &_fd, pid_t _pid, const char *_channelName, const HashedStaticString &_appGroupName, const StaticString &_appLogFile)
109
111
  : fd(_fd),
110
112
  pid(_pid),
111
113
  channelName(_channelName),
112
- thr(NULL)
114
+ thr(NULL),
115
+ appGroupName(_appGroupName),
116
+ appLogFile(_appLogFile)
113
117
  { }
114
118
 
115
119
  ~BackgroundIOCapturer() {
@@ -242,7 +242,9 @@ public:
242
242
  errorPipe.first,
243
243
  pid,
244
244
  // The cast works around a compilation problem in Clang.
245
- (const char *) "stderr");
245
+ (const char *) "stderr",
246
+ options.getAppGroupName(),
247
+ options.appLogFile);
246
248
  details.stderrCapturer->start();
247
249
  details.pid = pid;
248
250
  details.adminSocket = adminSocket.second;
@@ -61,6 +61,8 @@ private:
61
61
  bool started;
62
62
  boost::mutex startSyncher;
63
63
  boost::condition_variable startCond;
64
+ const HashedStaticString appGroupName;
65
+ const StaticString appLogFile;
64
66
 
65
67
  static void threadMain(boost::shared_ptr<PipeWatcher> self) {
66
68
  TRACE_POINT();
@@ -97,7 +99,7 @@ private:
97
99
  }
98
100
  } else if (ret == 1 && buf[0] == '\n') {
99
101
  UPDATE_TRACE_POINT();
100
- LoggingKit::logAppOutput(pid, name, "", 0);
102
+ LoggingKit::logAppOutput(appGroupName, pid, name, "", 0, appLogFile);
101
103
  } else {
102
104
  UPDATE_TRACE_POINT();
103
105
  vector<StaticString> lines;
@@ -107,7 +109,7 @@ private:
107
109
  }
108
110
  split(StaticString(buf, ret2), '\n', lines);
109
111
  foreach (const StaticString line, lines) {
110
- LoggingKit::logAppOutput(pid, name, line.data(), line.size());
112
+ LoggingKit::logAppOutput(appGroupName, pid, name, line.data(), line.size(), appLogFile);
111
113
  }
112
114
  }
113
115
 
@@ -119,12 +121,15 @@ private:
119
121
 
120
122
  public:
121
123
  PipeWatcher(const ConfigPtr &_config, const FileDescriptor &_fd,
122
- const char *_name, pid_t _pid)
124
+ const char *_name, pid_t _pid,
125
+ const HashedStaticString &_appGroupName, const StaticString &_appLogFile)
123
126
  : config(_config),
124
127
  fd(_fd),
125
128
  name(_name),
126
129
  pid(_pid),
127
- started(false)
130
+ started(false),
131
+ appGroupName(_appGroupName),
132
+ appLogFile(_appLogFile)
128
133
  { }
129
134
 
130
135
  void initialize() {
@@ -290,7 +290,9 @@ private:
290
290
  errorPipe.first,
291
291
  pid,
292
292
  // The cast works around a compilation problem in Clang.
293
- (const char *) "stderr");
293
+ (const char *) "stderr",
294
+ options.getAppGroupName(),
295
+ options.appLogFile);
294
296
  details.stderrCapturer->start();
295
297
  details.debugDir = debugDir;
296
298
  details.options = &options;
@@ -310,12 +312,12 @@ private:
310
312
  PipeWatcherPtr watcher;
311
313
 
312
314
  watcher = boost::make_shared<PipeWatcher>(config,
313
- adminSocket.second, "stdout", pid);
315
+ adminSocket.second, "stdout", pid, options.getAppGroupName(), options.appLogFile);
314
316
  watcher->initialize();
315
317
  watcher->start();
316
318
 
317
319
  watcher = boost::make_shared<PipeWatcher>(config,
318
- errorPipe.first, "stderr", pid);
320
+ errorPipe.first, "stderr", pid, options.getAppGroupName(), options.appLogFile);
319
321
  watcher->initialize();
320
322
  watcher->start();
321
323
 
@@ -710,7 +710,7 @@ protected:
710
710
  if (details.stderrCapturer != NULL) {
711
711
  details.stderrCapturer->appendToBuffer(result);
712
712
  }
713
- LoggingKit::logAppOutput(details.pid, "stdout", line.data(), line.size());
713
+ LoggingKit::logAppOutput(details.options->getAppGroupName(), details.pid, "stdout", line.data(), line.size(), details.options->appLogFile);
714
714
  }
715
715
  }
716
716
  }