Skip to content
Browse files

[Nginx] Fix crash if passenger_root refers to a nonexistant directory.

Issue #599.
  • Loading branch information...
1 parent 9a81106 commit 60e4cca5db57fd734323786f2bdeca59e4a0e2ae @FooBarWidget FooBarWidget committed Dec 16, 2010
Showing with 25 additions and 5 deletions.
  1. +2 −0 NEWS
  2. +1 −0 build/common_library.rb
  3. +10 −2 ext/common/AgentsStarter.hpp
  4. +10 −2 ext/common/IniFile.h
  5. +2 −1 ext/common/ResourceLocator.h
View
2 NEWS
@@ -5,6 +5,8 @@ Release 3.0.2
The Nginx compilation process was broken due to not correctly reverting
the working directory of the Nginx configure script. This has been fixed:
issue #595.
+ * [Nginx] Fixed crash if passenger_root refers to a nonexistant directory
+ Issue #599.
* Fixed compilation problems on NetBSD
There was a typo in a NetBSD-specific fcntl() call. It also turns out that
NetBSD doesn't support some ISO C99 math functions like llroundl(); this
View
1 build/common_library.rb
@@ -71,6 +71,7 @@ def define_common_library_task(namespace, output_dir, extra_compiler_flags = nil
AgentsStarter.cpp
AgentsStarter.h
AgentsStarter.hpp
+ IniFile.h
ResourceLocator.h
MessageClient.h
MessageChannel.h
View
12 ext/common/AgentsStarter.hpp
@@ -553,11 +553,19 @@ class AgentsStarter {
killProcessGroupAndWait(&pid, 5000);
guard.clear();
if (e == ENOENT) {
+ string passengerRootConfig;
+ if (type == APACHE) {
+ passengerRootConfig = "PassengerRoot";
+ } else {
+ passengerRootConfig = "passenger_root";
+ }
throw RuntimeException("Unable to start the Phusion Passenger watchdog "
"because its executable (" + watchdogFilename + ") does "
"not exist. This probably means that your Phusion Passenger "
- "installation is broken or incomplete. Please reinstall "
- "Phusion Passenger");
+ "installation is broken or incomplete, or that your '" +
+ passengerRootConfig + "' directive is set to the wrong value. "
+ "Please reinstall Phusion Passenger or fix your '" +
+ passengerRootConfig + "' directive, whichever is applicable.");
} else {
throw SystemException("Unable to start the Phusion Passenger watchdog (" +
watchdogFilename + ")", e);
View
12 ext/common/IniFile.h
@@ -12,6 +12,7 @@
#include <cctype>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
+#include <Exceptions.h>
namespace Passenger {
@@ -295,6 +296,11 @@ class IniFileLexer {
currentColumn = 1;
upcomingTokenPtrIsStale = true;
iniFileStream.open(fileName.c_str());
+ if (iniFileStream.fail()) {
+ int e = errno;
+ throw FileSystemException("Cannot open file '" + fileName + "' for reading",
+ e, fileName);
+ }
}
~IniFileLexer() {
@@ -390,7 +396,7 @@ class IniFile {
}
void parseSection() {
- Token token = acceptAndReturnif (Token::SECTION_NAME);
+ Token token = acceptAndReturnif(Token::SECTION_NAME);
acceptIfEOL();
string sectionName = token.value;
@@ -447,7 +453,9 @@ class IniFile {
};
public:
- IniFile(const string &iniFileName) : name(iniFileName) {
+ IniFile(const string &iniFileName)
+ : name(iniFileName)
+ {
IniFileParser parser(this);
}
View
3 ext/common/ResourceLocator.h
@@ -58,7 +58,8 @@ class ResourceLocator {
public:
ResourceLocator(const string &rootOrFile) {
- if (getFileType(rootOrFile) == FT_DIRECTORY) {
+ FileType rootOrFileType = getFileType(rootOrFile);
+ if (rootOrFileType == FT_DIRECTORY || rootOrFileType == FT_NONEXISTANT) {
string root = rootOrFile;
bool nativelyPackaged = !fileExists(root + "/Rakefile") ||
!fileExists(root + "/DEVELOPERS.TXT");

0 comments on commit 60e4cca

Please sign in to comment.
Something went wrong with that request. Please try again.