2 suPHP - (c)2002-2005 Sebastian Marsching <sebastian@marsching.com>
4 This file is part of suPHP.
6 suPHP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 suPHP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with suPHP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef SUPHP_APPLICATION_H
29 TARGETMODE_SELFEXECUTE
32 #define SUPHP_APPLICATION_H
37 #include "Environment.hpp"
38 #include "CommandLine.hpp"
39 #include "SystemException.hpp"
40 #include "SoftException.hpp"
41 #include "SecurityException.hpp"
45 * Main application class.
46 * Contains the main() function.
51 * Print message containing version information
53 void printAboutMessage();
56 * Checks wheter process has root privileges
57 * and calling user is webserver user
59 void checkProcessPermissions(Configuration& config)
60 throw (SecurityException, LookupException);
63 * Includes check for path, symbollink and permissions
65 void checkScriptFile(const std::string& scriptFilename,
66 const Configuration& config,
67 const Environment& environment) const
68 throw (SystemException, SoftException);
71 * Changes process permission (user and group).
72 * Uses preprocessor macros to distinguish between modes
74 void changeProcessPermissions(const std::string& scriptFilename,
75 const Configuration& config,
76 const Environment& environment) const
77 throw (SystemException, SoftException, SecurityException);
80 * Prepares the environment before invoking the script
82 Environment prepareEnvironment(const Environment& sourceEnv,
83 const Configuration& config,
85 throw (KeyNotFoundException);
88 * Returns interpreter for script being executed
90 std::string getInterpreter(const Environment& env,
91 const Configuration& config)
92 throw (SecurityException);
95 * Returns mode interpreter is using
97 TargetMode getTargetMode(const std::string& interpreter)
98 throw (SecurityException);
103 void executeScript(const std::string& scriptFilename,
104 const std::string& interpreter,
106 const Environment& env,
107 const Configuration& config) const
108 throw (SoftException);
118 * Function called by the main() function
120 int run(CommandLine& cmdline, Environment& env);
124 int main(int argc, char **argv);
126 #endif // SUPHP_APPLICATION_H