passenger 4.0.48 → 4.0.49
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.
- checksums.yaml +8 -8
- checksums.yaml.gz.asc +7 -7
- data.tar.gz.asc +7 -7
- data/.editorconfig +36 -2
- data/.travis.yml +1 -1
- data/CHANGELOG +16 -0
- data/Rakefile +0 -1
- data/build/apache2.rb +4 -4
- data/build/common_library.rb +18 -18
- data/build/cplusplus_support.rb +2 -2
- data/build/documentation.rb +1 -1
- data/build/integration_tests.rb +12 -4
- data/build/misc.rb +12 -7
- data/build/packaging.rb +14 -14
- data/build/preprocessor.rb +10 -10
- data/build/rake_extensions.rb +11 -11
- data/build/ruby_extension.rb +2 -2
- data/dev/ci/inituidgid +24 -0
- data/dev/ci/run_jenkins.sh +57 -0
- data/dev/ci/run_rpm_tests.sh +77 -0
- data/dev/{run_travis.sh → ci/run_travis.sh} +60 -4
- data/doc/Users guide Nginx.txt +2 -2
- data/doc/users_guide_snippets/environment_variables.txt +0 -2
- data/doc/users_guide_snippets/tips.txt +20 -1
- data/ext/apache2/Bucket.cpp +18 -18
- data/ext/apache2/Bucket.h +4 -4
- data/ext/apache2/Configuration.cpp +7 -7
- data/ext/apache2/Configuration.hpp +43 -43
- data/ext/apache2/DirectoryMapper.h +5 -5
- data/ext/apache2/Hooks.cpp +142 -142
- data/ext/apache2/MergeDirConfig.cpp +40 -40
- data/ext/common/Account.h +17 -17
- data/ext/common/AccountsDatabase.h +9 -9
- data/ext/common/AgentsStarter.cpp +2 -2
- data/ext/common/AgentsStarter.h +40 -40
- data/ext/common/ApplicationPool2/Common.h +10 -6
- data/ext/common/ApplicationPool2/ComponentInfo.h +2 -2
- data/ext/common/ApplicationPool2/DirectSpawner.h +17 -17
- data/ext/common/ApplicationPool2/DummySpawner.h +5 -5
- data/ext/common/ApplicationPool2/Group.h +54 -38
- data/ext/common/ApplicationPool2/Implementation.cpp +76 -49
- data/ext/common/ApplicationPool2/Options.h +98 -91
- data/ext/common/ApplicationPool2/Pool.h +70 -69
- data/ext/common/ApplicationPool2/Process.h +21 -21
- data/ext/common/ApplicationPool2/Session.h +11 -11
- data/ext/common/ApplicationPool2/SmartSpawner.h +60 -60
- data/ext/common/ApplicationPool2/Socket.h +19 -19
- data/ext/common/ApplicationPool2/Spawner.h +64 -72
- data/ext/common/ApplicationPool2/SpawnerFactory.h +4 -4
- data/ext/common/ApplicationPool2/SuperGroup.h +41 -41
- data/ext/common/BackgroundEventLoop.cpp +1 -1
- data/ext/common/BackgroundEventLoop.h +2 -2
- data/ext/common/Constants.h +1 -1
- data/ext/common/EventedBufferedInput.h +5 -5
- data/ext/common/EventedClient.h +51 -51
- data/ext/common/EventedMessageServer.h +39 -39
- data/ext/common/EventedServer.h +32 -32
- data/ext/common/Exceptions.h +23 -23
- data/ext/common/FileDescriptor.h +18 -18
- data/ext/common/Logging.cpp +1 -1
- data/ext/common/MessageClient.h +27 -27
- data/ext/common/MessageReadersWriters.h +79 -79
- data/ext/common/MessageServer.h +59 -59
- data/ext/common/RandomGenerator.h +12 -12
- data/ext/common/ResourceLocator.h +8 -8
- data/ext/common/SafeLibev.h +54 -25
- data/ext/common/ServerInstanceDir.h +31 -31
- data/ext/common/StaticString.h +50 -48
- data/ext/common/Utils.cpp +73 -78
- data/ext/common/Utils.h +6 -6
- data/ext/common/Utils/Base64.cpp +3 -3
- data/ext/common/Utils/Base64.h +7 -7
- data/ext/common/Utils/BlockingQueue.h +9 -9
- data/ext/common/Utils/BufferedIO.h +17 -17
- data/ext/common/Utils/CachedFileStat.hpp +16 -16
- data/ext/common/Utils/Dechunker.h +25 -25
- data/ext/common/Utils/FileChangeChecker.h +10 -10
- data/ext/common/Utils/MemZeroGuard.h +5 -5
- data/ext/common/Utils/MemoryBarrier.h +1 -1
- data/ext/common/Utils/MessageIO.h +61 -61
- data/ext/common/Utils/ProcessMetricsCollector.h +40 -40
- data/ext/common/Utils/ScopeGuard.h +7 -7
- data/ext/common/Utils/SpeedMeter.h +1 -1
- data/ext/common/Utils/StrIntUtils.cpp +13 -13
- data/ext/common/Utils/StrIntUtils.h +3 -3
- data/ext/common/Utils/StringScanning.h +5 -5
- data/ext/common/Utils/SystemMetricsCollector.h +2 -2
- data/ext/common/Utils/SystemTime.h +10 -10
- data/ext/common/Utils/Template.h +2 -2
- data/ext/common/Utils/Timer.h +6 -6
- data/ext/common/Utils/VariantMap.h +29 -29
- data/ext/common/agents/Base.cpp +19 -19
- data/ext/common/agents/HelperAgent/AgentOptions.h +1 -1
- data/ext/common/agents/HelperAgent/FileBackedPipe.h +6 -6
- data/ext/common/agents/HelperAgent/Main.cpp +44 -43
- data/ext/common/agents/HelperAgent/RequestHandler.cpp +4 -4
- data/ext/common/agents/HelperAgent/RequestHandler.h +29 -28
- data/ext/common/agents/HelperAgent/ScgiRequestParser.h +56 -50
- data/ext/common/agents/LoggingAgent/AdminController.h +8 -8
- data/ext/common/agents/LoggingAgent/DataStoreId.h +17 -17
- data/ext/common/agents/LoggingAgent/FilterSupport.h +167 -167
- data/ext/common/agents/LoggingAgent/LoggingServer.h +122 -122
- data/ext/common/agents/LoggingAgent/Main.cpp +7 -7
- data/ext/common/agents/LoggingAgent/RemoteSender.h +54 -54
- data/ext/common/agents/SpawnPreparer.cpp +4 -4
- data/ext/common/agents/TempDirToucher.c +2 -2
- data/ext/common/agents/Watchdog/AgentWatcher.cpp +47 -47
- data/ext/common/agents/Watchdog/HelperAgentWatcher.cpp +7 -7
- data/ext/common/agents/Watchdog/LoggingAgentWatcher.cpp +7 -7
- data/ext/common/agents/Watchdog/Main.cpp +22 -22
- data/ext/common/agents/Watchdog/ServerInstanceDirToucher.cpp +9 -9
- data/ext/libeio/eio.c +1 -1
- data/ext/nginx/Configuration.c +30 -30
- data/ext/nginx/Configuration.h +1 -1
- data/ext/nginx/ContentHandler.c +54 -54
- data/ext/nginx/ContentHandler.h +3 -3
- data/ext/nginx/StaticContentHandler.c +2 -2
- data/ext/nginx/ngx_http_passenger_module.c +21 -21
- data/ext/oxt/detail/backtrace_enabled.hpp +1 -1
- data/ext/oxt/detail/context.hpp +1 -1
- data/ext/oxt/detail/spin_lock_darwin.hpp +4 -4
- data/ext/oxt/detail/spin_lock_gcc_x86.hpp +3 -3
- data/ext/oxt/detail/spin_lock_pthreads.hpp +4 -4
- data/ext/oxt/detail/tracable_exception_disabled.hpp +1 -1
- data/ext/oxt/dynamic_thread_group.hpp +18 -18
- data/ext/oxt/implementation.cpp +9 -8
- data/ext/oxt/macros.hpp +2 -2
- data/ext/oxt/system_calls.cpp +11 -11
- data/ext/oxt/system_calls.hpp +13 -13
- data/ext/oxt/thread.hpp +22 -14
- data/ext/ruby/passenger_native_support.c +55 -55
- data/lib/phusion_passenger.rb +24 -24
- data/lib/phusion_passenger/common_library.rb +2 -0
- data/lib/phusion_passenger/loader_shared_helpers.rb +18 -18
- data/lib/phusion_passenger/packaging.rb +9 -4
- data/lib/phusion_passenger/platform_info/apache.rb +45 -31
- data/lib/phusion_passenger/platform_info/compiler.rb +11 -11
- data/lib/phusion_passenger/rack/thread_handler_extension.rb +1 -1
- data/lib/phusion_passenger/request_handler/thread_handler.rb +8 -8
- data/lib/phusion_passenger/standalone/app_finder.rb +16 -16
- data/lib/phusion_passenger/standalone/command.rb +22 -22
- data/packaging/rpm/LICENSE.txt +19 -0
- data/packaging/rpm/Makefile +13 -0
- data/packaging/rpm/README.md +41 -0
- data/packaging/rpm/Vagrantfile +38 -0
- data/{rpm/Vagrantfile → packaging/rpm/Vagrantfile.centos} +0 -0
- data/packaging/rpm/build +170 -0
- data/packaging/rpm/create_project +41 -0
- data/packaging/rpm/git_update +88 -0
- data/packaging/rpm/image/Dockerfile +37 -0
- data/packaging/rpm/image/Gemfile +3 -0
- data/packaging/rpm/image/Gemfile.lock +12 -0
- data/packaging/rpm/image/RPM-GPG-KEY-amazon-ga +19 -0
- data/packaging/rpm/image/amazon2014-i386.cfg +96 -0
- data/packaging/rpm/image/amazon2014-x86_64.cfg +96 -0
- data/packaging/rpm/image/site-defaults.cfg +168 -0
- data/packaging/rpm/internal/build_tasks.rb +238 -0
- data/packaging/rpm/internal/dummygpg +11 -0
- data/packaging/rpm/internal/exec_build +42 -0
- data/packaging/rpm/internal/get_distro_arch +14 -0
- data/packaging/rpm/internal/get_distro_id +10 -0
- data/packaging/rpm/internal/git_update +27 -0
- data/packaging/rpm/internal/inituidgid +17 -0
- data/packaging/rpm/internal/my_init +344 -0
- data/packaging/rpm/internal/python27 +3 -0
- data/packaging/rpm/internal/repo_update +46 -0
- data/packaging/rpm/internal/setuser +26 -0
- data/packaging/rpm/internal/tracking_helper +40 -0
- data/packaging/rpm/jenkins_release +99 -0
- data/packaging/rpm/lib/build_tasks_support.rb +402 -0
- data/packaging/rpm/lib/preprocessor.rb +341 -0
- data/packaging/rpm/nginx_spec/404.html +119 -0
- data/packaging/rpm/nginx_spec/50x.html +119 -0
- data/packaging/rpm/nginx_spec/index.html +116 -0
- data/packaging/rpm/nginx_spec/nginx-auto-cc-gcc.patch +13 -0
- data/packaging/rpm/nginx_spec/nginx-logo.png +0 -0
- data/packaging/rpm/nginx_spec/nginx-upgrade +13 -0
- data/packaging/rpm/nginx_spec/nginx-upgrade.8 +151 -0
- data/packaging/rpm/nginx_spec/nginx.conf +131 -0
- data/packaging/rpm/nginx_spec/nginx.init +144 -0
- data/packaging/rpm/nginx_spec/nginx.logrotate +13 -0
- data/packaging/rpm/nginx_spec/nginx.service +15 -0
- data/packaging/rpm/nginx_spec/nginx.spec.template +559 -0
- data/packaging/rpm/nginx_spec/nginx.sysconfig +4 -0
- data/packaging/rpm/nginx_spec/passenger.conf +9 -0
- data/packaging/rpm/nginx_spec/poweredby.png +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/apache-passenger.conf.in +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/config.json +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger.logrotate +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger.spec.template +58 -31
- data/{rpm → packaging/rpm/passenger_spec}/passenger_dynamic_thread_group.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/passenger_tests_default_config_example.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-GLIBC_HAVE_LONG_LONG.patch +0 -0
- data/{rpm → packaging/rpm/passenger_spec}/rubygem-passenger-4.0.18-gcc47-include-sys_types.patch +0 -0
- data/packaging/rpm/repo_update +114 -0
- data/packaging/rpm/setup-system +60 -0
- data/packaging/rpm/shell +10 -0
- data/resources/templates/standalone/config.erb +3 -1
- data/test/config.json.rpm-automation +1 -1
- data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +11 -11
- data/test/cxx/ApplicationPool2/OptionsTest.cpp +5 -5
- data/test/cxx/ApplicationPool2/PoolTest.cpp +129 -89
- data/test/cxx/ApplicationPool2/ProcessTest.cpp +15 -15
- data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +22 -22
- data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +11 -11
- data/test/cxx/ScgiRequestParserTest.cpp +75 -61
- data/test/cxx/UtilsTest.cpp +86 -85
- data/test/gdbinit.example +3 -0
- data/test/integration_tests/nginx_tests.rb +3 -3
- data/test/integration_tests/source_packaging_test.rb +3 -1
- data/test/stub/nginx/nginx.conf.erb +8 -1
- data/test/support/nginx_controller.rb +7 -7
- metadata +62 -17
- metadata.gz.asc +7 -7
- data/build/rpm.rb +0 -128
- data/dev/rpmtool +0 -21
- data/dev/test_rpm_packaging.sh +0 -28
- data/rpm/get_distro_id.py +0 -4
@@ -39,143 +39,143 @@
|
|
39
39
|
|
40
40
|
|
41
41
|
|
42
|
-
|
42
|
+
|
43
43
|
config->ruby =
|
44
44
|
(add->ruby == NULL) ?
|
45
45
|
base->ruby :
|
46
46
|
add->ruby;
|
47
|
-
|
48
47
|
|
49
|
-
|
48
|
+
|
49
|
+
|
50
50
|
config->python =
|
51
51
|
(add->python == NULL) ?
|
52
52
|
base->python :
|
53
53
|
add->python;
|
54
|
-
|
55
54
|
|
56
|
-
|
55
|
+
|
56
|
+
|
57
57
|
config->nodejs =
|
58
58
|
(add->nodejs == NULL) ?
|
59
59
|
base->nodejs :
|
60
60
|
add->nodejs;
|
61
|
-
|
62
61
|
|
63
|
-
|
62
|
+
|
63
|
+
|
64
64
|
config->appEnv =
|
65
65
|
(add->appEnv == NULL) ?
|
66
66
|
base->appEnv :
|
67
67
|
add->appEnv;
|
68
|
-
|
69
68
|
|
70
|
-
|
69
|
+
|
70
|
+
|
71
71
|
config->minInstances =
|
72
72
|
(add->minInstances == UNSET_INT_VALUE) ?
|
73
73
|
base->minInstances :
|
74
74
|
add->minInstances;
|
75
|
-
|
76
75
|
|
77
|
-
|
76
|
+
|
77
|
+
|
78
78
|
config->maxInstancesPerApp =
|
79
79
|
(add->maxInstancesPerApp == UNSET_INT_VALUE) ?
|
80
80
|
base->maxInstancesPerApp :
|
81
81
|
add->maxInstancesPerApp;
|
82
|
-
|
83
82
|
|
84
|
-
|
83
|
+
|
84
|
+
|
85
85
|
config->user =
|
86
86
|
(add->user == NULL) ?
|
87
87
|
base->user :
|
88
88
|
add->user;
|
89
|
-
|
90
89
|
|
91
|
-
|
90
|
+
|
91
|
+
|
92
92
|
config->group =
|
93
93
|
(add->group == NULL) ?
|
94
94
|
base->group :
|
95
95
|
add->group;
|
96
|
-
|
97
96
|
|
98
|
-
|
97
|
+
|
98
|
+
|
99
99
|
config->errorOverride =
|
100
100
|
(add->errorOverride == DirConfig::UNSET) ?
|
101
101
|
base->errorOverride :
|
102
102
|
add->errorOverride;
|
103
|
-
|
104
103
|
|
105
|
-
|
104
|
+
|
105
|
+
|
106
106
|
config->maxRequests =
|
107
107
|
(add->maxRequests == UNSET_INT_VALUE) ?
|
108
108
|
base->maxRequests :
|
109
109
|
add->maxRequests;
|
110
|
-
|
111
110
|
|
112
|
-
|
111
|
+
|
112
|
+
|
113
113
|
config->startTimeout =
|
114
114
|
(add->startTimeout == UNSET_INT_VALUE) ?
|
115
115
|
base->startTimeout :
|
116
116
|
add->startTimeout;
|
117
|
-
|
118
117
|
|
119
|
-
|
118
|
+
|
119
|
+
|
120
120
|
config->highPerformance =
|
121
121
|
(add->highPerformance == DirConfig::UNSET) ?
|
122
122
|
base->highPerformance :
|
123
123
|
add->highPerformance;
|
124
|
-
|
125
124
|
|
126
|
-
|
125
|
+
|
126
|
+
|
127
127
|
config->enabled =
|
128
128
|
(add->enabled == DirConfig::UNSET) ?
|
129
129
|
base->enabled :
|
130
130
|
add->enabled;
|
131
|
-
|
132
131
|
|
133
|
-
|
132
|
+
|
133
|
+
|
134
134
|
config->maxRequestQueueSize =
|
135
135
|
(add->maxRequestQueueSize == UNSET_INT_VALUE) ?
|
136
136
|
base->maxRequestQueueSize :
|
137
137
|
add->maxRequestQueueSize;
|
138
|
-
|
139
138
|
|
140
|
-
|
139
|
+
|
140
|
+
|
141
141
|
config->loadShellEnvvars =
|
142
142
|
(add->loadShellEnvvars == DirConfig::UNSET) ?
|
143
143
|
base->loadShellEnvvars :
|
144
144
|
add->loadShellEnvvars;
|
145
|
-
|
146
145
|
|
147
|
-
|
146
|
+
|
147
|
+
|
148
148
|
config->bufferUpload =
|
149
149
|
(add->bufferUpload == DirConfig::UNSET) ?
|
150
150
|
base->bufferUpload :
|
151
151
|
add->bufferUpload;
|
152
|
-
|
153
152
|
|
154
|
-
|
153
|
+
|
154
|
+
|
155
155
|
config->appType =
|
156
156
|
(add->appType == NULL) ?
|
157
157
|
base->appType :
|
158
158
|
add->appType;
|
159
|
-
|
160
159
|
|
161
|
-
|
160
|
+
|
161
|
+
|
162
162
|
config->startupFile =
|
163
163
|
(add->startupFile == NULL) ?
|
164
164
|
base->startupFile :
|
165
165
|
add->startupFile;
|
166
|
-
|
167
166
|
|
168
|
-
|
167
|
+
|
168
|
+
|
169
169
|
config->stickySessions =
|
170
170
|
(add->stickySessions == DirConfig::UNSET) ?
|
171
171
|
base->stickySessions :
|
172
172
|
add->stickySessions;
|
173
|
-
|
174
173
|
|
175
|
-
|
174
|
+
|
175
|
+
|
176
176
|
config->stickySessionsCookieName =
|
177
177
|
(add->stickySessionsCookieName == DirConfig::UNSET) ?
|
178
178
|
base->stickySessionsCookieName :
|
179
179
|
add->stickySessionsCookieName;
|
180
|
-
|
180
|
+
|
181
181
|
|
data/ext/common/Account.h
CHANGED
@@ -61,7 +61,7 @@ public:
|
|
61
61
|
enum Rights {
|
62
62
|
ALL = ~0,
|
63
63
|
NONE = 0,
|
64
|
-
|
64
|
+
|
65
65
|
// HelperAgent ApplicationPool rights.
|
66
66
|
CLEAR = 1 << 0,
|
67
67
|
DETACH = 1 << 1,
|
@@ -69,11 +69,11 @@ public:
|
|
69
69
|
RESTART = 1 << 3,
|
70
70
|
INSPECT_BASIC_INFO = 1 << 4,
|
71
71
|
INSPECT_SENSITIVE_INFO = 1 << 5,
|
72
|
-
|
72
|
+
|
73
73
|
// HelperAgent admin rights.
|
74
74
|
INSPECT_REQUESTS = 1 << 8,
|
75
75
|
INSPECT_BACKTRACES = 1 << 9,
|
76
|
-
|
76
|
+
|
77
77
|
// Other rights.
|
78
78
|
EXIT = 1 << 31
|
79
79
|
};
|
@@ -87,19 +87,19 @@ private:
|
|
87
87
|
public:
|
88
88
|
// Urgh, I can't use 'Rights' here as type because apparently bitwise
|
89
89
|
// ORing two enums results in an int type.
|
90
|
-
|
90
|
+
|
91
91
|
static Rights parseRightsString(const string &str, int defaultValue = NONE) {
|
92
92
|
vector<string> rights_vec;
|
93
93
|
vector<string>::const_iterator it;
|
94
94
|
int result = defaultValue;
|
95
|
-
|
95
|
+
|
96
96
|
split(str, ',', rights_vec);
|
97
97
|
for (it = rights_vec.begin(); it != rights_vec.end(); it++) {
|
98
98
|
if (*it == "all") {
|
99
99
|
result = ALL;
|
100
100
|
} else if (*it == "none") {
|
101
101
|
result = NONE;
|
102
|
-
|
102
|
+
|
103
103
|
} else if (*it == "clear") {
|
104
104
|
result |= CLEAR;
|
105
105
|
} else if (*it == "detach") {
|
@@ -110,30 +110,30 @@ public:
|
|
110
110
|
result |= INSPECT_BASIC_INFO;
|
111
111
|
} else if (*it == "inspect_sensitive_info") {
|
112
112
|
result |= INSPECT_SENSITIVE_INFO;
|
113
|
-
|
113
|
+
|
114
114
|
} else if (*it == "inspect_requests") {
|
115
115
|
result |= INSPECT_REQUESTS;
|
116
116
|
} else if (*it == "inspect_backtraces") {
|
117
117
|
result |= INSPECT_BACKTRACES;
|
118
|
-
|
118
|
+
|
119
119
|
} else if (*it == "exit") {
|
120
120
|
result |= EXIT;
|
121
|
-
|
121
|
+
|
122
122
|
} else if (*it != "") {
|
123
123
|
throw ArgumentException("Unknown right '" + *it + "'.");
|
124
124
|
}
|
125
125
|
}
|
126
|
-
|
126
|
+
|
127
127
|
return (Rights) result;
|
128
128
|
}
|
129
|
-
|
129
|
+
|
130
130
|
Account(const string &username, const string &passwordOrHash, bool hashGiven, int rights = ALL) {
|
131
131
|
this->username = username;
|
132
132
|
this->passwordOrHash = passwordOrHash;
|
133
133
|
this->hashGiven = hashGiven;
|
134
134
|
this->rights = (Rights) rights;
|
135
135
|
}
|
136
|
-
|
136
|
+
|
137
137
|
bool checkPasswordOrHash(const StaticString &userSuppliedPassword) const {
|
138
138
|
if (hashGiven) {
|
139
139
|
return passwordOrHash == createHash(userSuppliedPassword);
|
@@ -141,23 +141,23 @@ public:
|
|
141
141
|
return userSuppliedPassword == passwordOrHash;
|
142
142
|
}
|
143
143
|
}
|
144
|
-
|
144
|
+
|
145
145
|
bool hasRights(int rights) const {
|
146
146
|
return this->rights & rights;
|
147
147
|
}
|
148
|
-
|
148
|
+
|
149
149
|
void setRights(int rights) {
|
150
150
|
this->rights = (Rights) rights;
|
151
151
|
}
|
152
|
-
|
152
|
+
|
153
153
|
string getUsername() const {
|
154
154
|
return username;
|
155
155
|
}
|
156
|
-
|
156
|
+
|
157
157
|
string getRawPassword() const {
|
158
158
|
return passwordOrHash;
|
159
159
|
}
|
160
|
-
|
160
|
+
|
161
161
|
static string createHash(const StaticString &userSuppliedPassword) {
|
162
162
|
// TODO: use bcrypt or something
|
163
163
|
return userSuppliedPassword;
|
@@ -49,34 +49,34 @@ private:
|
|
49
49
|
mutable boost::mutex lock;
|
50
50
|
map<string, AccountPtr> accounts;
|
51
51
|
unsigned int uniqueNumber;
|
52
|
-
|
52
|
+
|
53
53
|
public:
|
54
54
|
AccountsDatabase() {
|
55
55
|
uniqueNumber = 0;
|
56
56
|
}
|
57
|
-
|
57
|
+
|
58
58
|
unsigned int size() const {
|
59
59
|
boost::lock_guard<boost::mutex> l(lock);
|
60
60
|
return (unsigned int) accounts.size();
|
61
61
|
}
|
62
|
-
|
62
|
+
|
63
63
|
vector<string> listUsernames() const {
|
64
64
|
map<string, AccountPtr>::const_iterator it;
|
65
65
|
vector<string> result;
|
66
|
-
|
66
|
+
|
67
67
|
for (it = accounts.begin(); it != accounts.end(); it++) {
|
68
68
|
result.push_back(it->second->getUsername());
|
69
69
|
}
|
70
70
|
return result;
|
71
71
|
}
|
72
|
-
|
72
|
+
|
73
73
|
AccountPtr add(const string &username, const string &passwordOrHash, bool hashGiven, int rights = Account::ALL) {
|
74
74
|
AccountPtr account(new Account(username, passwordOrHash, hashGiven, rights));
|
75
75
|
boost::lock_guard<boost::mutex> l(lock);
|
76
76
|
accounts[username] = account;
|
77
77
|
return account;
|
78
78
|
}
|
79
|
-
|
79
|
+
|
80
80
|
const AccountPtr get(const string &username) const {
|
81
81
|
boost::lock_guard<boost::mutex> l(lock);
|
82
82
|
map<string, AccountPtr>::const_iterator it = accounts.find(username);
|
@@ -86,7 +86,7 @@ public:
|
|
86
86
|
return it->second;
|
87
87
|
}
|
88
88
|
}
|
89
|
-
|
89
|
+
|
90
90
|
AccountPtr authenticate(const string &username, const StaticString &userSuppliedPassword) const {
|
91
91
|
boost::lock_guard<boost::mutex> l(lock);
|
92
92
|
map<string, AccountPtr>::const_iterator it = accounts.find(username);
|
@@ -101,7 +101,7 @@ public:
|
|
101
101
|
}
|
102
102
|
}
|
103
103
|
}
|
104
|
-
|
104
|
+
|
105
105
|
bool remove(const string &username) {
|
106
106
|
boost::lock_guard<boost::mutex> l(lock);
|
107
107
|
map<string, AccountPtr>::iterator it = accounts.find(username);
|
@@ -112,7 +112,7 @@ public:
|
|
112
112
|
return true;
|
113
113
|
}
|
114
114
|
}
|
115
|
-
|
115
|
+
|
116
116
|
unsigned int getUniqueNumber() {
|
117
117
|
boost::lock_guard<boost::mutex> l(lock);
|
118
118
|
unsigned int result = uniqueNumber;
|
@@ -87,7 +87,7 @@ pp_variant_map_set_strset(PP_VariantMap *m,
|
|
87
87
|
{
|
88
88
|
Passenger::VariantMap *vm = (Passenger::VariantMap *) m;
|
89
89
|
std::set<string> the_set;
|
90
|
-
|
90
|
+
|
91
91
|
for (unsigned int i = 0; i < count; i++) {
|
92
92
|
the_set.insert(strs[i]);
|
93
93
|
}
|
@@ -117,7 +117,7 @@ pp_agents_starter_start(PP_AgentsStarter *as,
|
|
117
117
|
this_thread::disable_syscall_interruption dsi;
|
118
118
|
try {
|
119
119
|
boost::function<void ()> afterForkFunctionObject;
|
120
|
-
|
120
|
+
|
121
121
|
if (afterFork != NULL) {
|
122
122
|
afterForkFunctionObject = boost::bind(afterFork, callbackArgument);
|
123
123
|
}
|
data/ext/common/AgentsStarter.h
CHANGED
@@ -128,15 +128,15 @@ private:
|
|
128
128
|
pid_t pid;
|
129
129
|
|
130
130
|
/******* Information about the started services. Only valid when pid != 0. *******/
|
131
|
-
|
131
|
+
|
132
132
|
/** The watchdog's feedback file descriptor. */
|
133
133
|
FileDescriptor feedbackFd;
|
134
|
-
|
134
|
+
|
135
135
|
/** The helper agent's request socket filename and its password. This socket
|
136
136
|
* is for serving SCGI requests. */
|
137
137
|
string requestSocketFilename;
|
138
138
|
string requestSocketPassword;
|
139
|
-
|
139
|
+
|
140
140
|
/** The socket on which the helper agent listens for administration commands,
|
141
141
|
* and the corresponding password for the "web_server" account, which has the
|
142
142
|
* authorization to shutdown the helper agent.
|
@@ -147,12 +147,12 @@ private:
|
|
147
147
|
/** The logging agent's socket address and its password. */
|
148
148
|
string loggingSocketAddress;
|
149
149
|
string loggingSocketPassword;
|
150
|
-
|
150
|
+
|
151
151
|
/** The server instance dir and generation dir of the agents. */
|
152
152
|
ServerInstanceDirPtr serverInstanceDir;
|
153
153
|
/** The generation dir of the agents. */
|
154
154
|
ServerInstanceDir::GenerationPtr generation;
|
155
|
-
|
155
|
+
|
156
156
|
/**
|
157
157
|
* Safely dup2() the given file descriptor to 3 (FEEDBACK_FD).
|
158
158
|
*/
|
@@ -174,7 +174,7 @@ private:
|
|
174
174
|
}
|
175
175
|
}
|
176
176
|
}
|
177
|
-
|
177
|
+
|
178
178
|
/**
|
179
179
|
* Call this if the watchdog seems to have crashed. This function will try
|
180
180
|
* to determine whether the watchdog is still running, whether it crashed
|
@@ -185,7 +185,7 @@ private:
|
|
185
185
|
this_thread::disable_interruption di;
|
186
186
|
this_thread::disable_syscall_interruption dsi;
|
187
187
|
int ret, status;
|
188
|
-
|
188
|
+
|
189
189
|
/* Upon noticing that something went wrong, the watchdog
|
190
190
|
* or its subprocesses might still be writing out an error
|
191
191
|
* report, so we wait a while before killing the watchdog.
|
@@ -218,7 +218,7 @@ private:
|
|
218
218
|
"with exit code " + toString(WEXITSTATUS(status)));
|
219
219
|
}
|
220
220
|
}
|
221
|
-
|
221
|
+
|
222
222
|
static void killProcessGroupAndWait(pid_t *pid, unsigned long long timeout = 0) {
|
223
223
|
if (*pid != -1 && (timeout == 0 || timedWaitPid(*pid, NULL, timeout) <= 0)) {
|
224
224
|
this_thread::disable_syscall_interruption dsi;
|
@@ -227,7 +227,7 @@ private:
|
|
227
227
|
*pid = -1;
|
228
228
|
}
|
229
229
|
}
|
230
|
-
|
230
|
+
|
231
231
|
/**
|
232
232
|
* Behaves like `waitpid(pid, status, WNOHANG)`, but waits at most
|
233
233
|
* `timeout` miliseconds for the process to exit.
|
@@ -235,7 +235,7 @@ private:
|
|
235
235
|
static int timedWaitPid(pid_t pid, int *status, unsigned long long timeout) {
|
236
236
|
Timer timer;
|
237
237
|
int ret;
|
238
|
-
|
238
|
+
|
239
239
|
do {
|
240
240
|
ret = syscalls::waitpid(pid, status, WNOHANG);
|
241
241
|
if (ret > 0 || ret == -1) {
|
@@ -246,7 +246,7 @@ private:
|
|
246
246
|
} while (timer.elapsed() < timeout);
|
247
247
|
return 0; // timed out
|
248
248
|
}
|
249
|
-
|
249
|
+
|
250
250
|
/**
|
251
251
|
* Gracefully shutdown an agent process by sending an exit command to its socket.
|
252
252
|
* Returns whether the agent has successfully processed the exit command.
|
@@ -258,7 +258,7 @@ private:
|
|
258
258
|
try {
|
259
259
|
MessageClient client;
|
260
260
|
vector<string> args;
|
261
|
-
|
261
|
+
|
262
262
|
client.connect(address, username, password);
|
263
263
|
client.write("exit", NULL);
|
264
264
|
return client.read(args) && args[0] == "Passed security" &&
|
@@ -269,7 +269,7 @@ private:
|
|
269
269
|
}
|
270
270
|
return false;
|
271
271
|
}
|
272
|
-
|
272
|
+
|
273
273
|
public:
|
274
274
|
/**
|
275
275
|
* Construct a AgentsStarter object. The watchdog and the agents
|
@@ -281,7 +281,7 @@ public:
|
|
281
281
|
this->type = type;
|
282
282
|
pid = 0;
|
283
283
|
}
|
284
|
-
|
284
|
+
|
285
285
|
~AgentsStarter() {
|
286
286
|
if (pid != 0) {
|
287
287
|
this_thread::disable_syscall_interruption dsi;
|
@@ -290,7 +290,7 @@ public:
|
|
290
290
|
cleanShutdown = cleanShutdown &&
|
291
291
|
gracefullyShutdownAgent(loggingSocketAddress,
|
292
292
|
"logging", loggingSocketPassword);
|
293
|
-
|
293
|
+
|
294
294
|
/* Send a message down the feedback fd to tell the watchdog
|
295
295
|
* Whether this is a clean shutdown. Closing the fd without
|
296
296
|
* sending anything also indicates an unclean shutdown,
|
@@ -302,26 +302,26 @@ public:
|
|
302
302
|
} else {
|
303
303
|
syscalls::write(feedbackFd, "u", 1);
|
304
304
|
}
|
305
|
-
|
305
|
+
|
306
306
|
/* If we failed to send an exit command to one of the agents then we have
|
307
307
|
* to forcefully kill all agents now because otherwise one of them might
|
308
308
|
* never exit. We do this by closing the feedback fd without sending a
|
309
309
|
* random byte, to indicate that this is an abnormal shutdown. The watchdog
|
310
310
|
* will then kill all agents.
|
311
311
|
*/
|
312
|
-
|
312
|
+
|
313
313
|
feedbackFd.close();
|
314
314
|
syscalls::waitpid(pid, NULL, 0);
|
315
315
|
}
|
316
316
|
}
|
317
|
-
|
317
|
+
|
318
318
|
/**
|
319
319
|
* Returns the type as was passed to the constructor.
|
320
320
|
*/
|
321
321
|
PP_AgentsStarterType getType() const {
|
322
322
|
return type;
|
323
323
|
}
|
324
|
-
|
324
|
+
|
325
325
|
/**
|
326
326
|
* Returns the watchdog's PID. Equals 0 if the watchdog hasn't been started yet
|
327
327
|
* or if detach() is called.
|
@@ -329,41 +329,41 @@ public:
|
|
329
329
|
pid_t getPid() const {
|
330
330
|
return pid;
|
331
331
|
}
|
332
|
-
|
332
|
+
|
333
333
|
// The 'const string &' here is on purpose. The C getter functions
|
334
334
|
// return the string pointer directly.
|
335
335
|
const string &getRequestSocketFilename() const {
|
336
336
|
return requestSocketFilename;
|
337
337
|
}
|
338
|
-
|
338
|
+
|
339
339
|
const string &getRequestSocketPassword() const {
|
340
340
|
return requestSocketPassword;
|
341
341
|
}
|
342
|
-
|
342
|
+
|
343
343
|
string getHelperAgentAdminSocketFilename() const {
|
344
344
|
return parseUnixSocketAddress(helperAgentAdminSocketAddress);
|
345
345
|
}
|
346
|
-
|
346
|
+
|
347
347
|
string getHelperAgentExitPassword() const {
|
348
348
|
return helperAgentExitPassword;
|
349
349
|
}
|
350
|
-
|
350
|
+
|
351
351
|
string getLoggingSocketAddress() const {
|
352
352
|
return loggingSocketAddress;
|
353
353
|
}
|
354
|
-
|
354
|
+
|
355
355
|
string getLoggingSocketPassword() const {
|
356
356
|
return loggingSocketPassword;
|
357
357
|
}
|
358
|
-
|
358
|
+
|
359
359
|
ServerInstanceDirPtr getServerInstanceDir() const {
|
360
360
|
return serverInstanceDir;
|
361
361
|
}
|
362
|
-
|
362
|
+
|
363
363
|
ServerInstanceDir::GenerationPtr getGeneration() const {
|
364
364
|
return generation;
|
365
365
|
}
|
366
|
-
|
366
|
+
|
367
367
|
/**
|
368
368
|
* Start the agents through the watchdog.
|
369
369
|
*
|
@@ -399,7 +399,7 @@ public:
|
|
399
399
|
pid = syscalls::fork();
|
400
400
|
if (pid == 0) {
|
401
401
|
// Child
|
402
|
-
|
402
|
+
|
403
403
|
/* Become the session leader so that Apache can't kill the
|
404
404
|
* watchdog with killpg() during shutdown, so that a
|
405
405
|
* Ctrl-C only affects the web server, and so that
|
@@ -424,7 +424,7 @@ public:
|
|
424
424
|
if (afterFork) {
|
425
425
|
afterFork();
|
426
426
|
}
|
427
|
-
|
427
|
+
|
428
428
|
execl(watchdogFilename.c_str(), "PassengerWatchdog", (char *) 0);
|
429
429
|
e = errno;
|
430
430
|
try {
|
@@ -449,13 +449,13 @@ public:
|
|
449
449
|
FileDescriptor feedbackFd = fds[0];
|
450
450
|
vector<string> args;
|
451
451
|
bool result = false;
|
452
|
-
|
452
|
+
|
453
453
|
ScopeGuard guard(boost::bind(&AgentsStarter::killProcessGroupAndWait, &pid, 0));
|
454
454
|
fds[1].close();
|
455
|
-
|
456
|
-
|
455
|
+
|
456
|
+
|
457
457
|
/****** Send arguments to watchdog through the feedback channel ******/
|
458
|
-
|
458
|
+
|
459
459
|
UPDATE_TRACE_POINT();
|
460
460
|
/* Here we don't care about EPIPE and ECONNRESET errors. The watchdog
|
461
461
|
* could have sent an error message over the feedback fd without
|
@@ -468,14 +468,14 @@ public:
|
|
468
468
|
inspectWatchdogCrashReason(pid);
|
469
469
|
}
|
470
470
|
}
|
471
|
-
|
472
|
-
|
471
|
+
|
472
|
+
|
473
473
|
/****** Read agents information report ******/
|
474
|
-
|
474
|
+
|
475
475
|
this_thread::restore_interruption ri(di);
|
476
476
|
this_thread::restore_syscall_interruption rsi(dsi);
|
477
477
|
UPDATE_TRACE_POINT();
|
478
|
-
|
478
|
+
|
479
479
|
try {
|
480
480
|
result = readArrayMessage(feedbackFd, args);
|
481
481
|
} catch (const SystemException &ex) {
|
@@ -493,7 +493,7 @@ public:
|
|
493
493
|
UPDATE_TRACE_POINT();
|
494
494
|
inspectWatchdogCrashReason(pid);
|
495
495
|
}
|
496
|
-
|
496
|
+
|
497
497
|
if (args[0] == "Agents information") {
|
498
498
|
if ((args.size() - 1) % 2 != 0) {
|
499
499
|
throw RuntimeException("Unable to start the Phusion Passenger watchdog "
|
@@ -564,7 +564,7 @@ public:
|
|
564
564
|
}
|
565
565
|
}
|
566
566
|
}
|
567
|
-
|
567
|
+
|
568
568
|
/**
|
569
569
|
* Close any file descriptors that this object has, and make it so that the destructor
|
570
570
|
* doesn't try to shut down the agents.
|