2 suPHP - (c)2002-2008 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"
42 #include "UserInfo.hpp"
43 #include "GroupInfo.hpp"
47 * Main application class.
48 * Contains the main() function.
53 * Print message containing version information
55 void printAboutMessage();
58 * Checks wheter process has root privileges
59 * and calling user is webserver user
61 void checkProcessPermissions(Configuration& config)
62 throw (SecurityException, LookupException);
65 * Checks scriptfile (first stage).
66 * Includes check for VHost docroot, symbollink and permissions.
68 void checkScriptFileStage1(const std::string& scriptFilename,
69 const Configuration& config,
70 const Environment& environment) const
71 throw (SystemException, SoftException);
75 * Includes check for paths which might be user specific
77 void checkScriptFileStage2(const std::string& scriptFilename,
78 const Configuration& config,
79 const Environment& environment,
80 const UserInfo& targetUser,
81 const GroupInfo& targetGroup) const
82 throw (SystemException, SoftException);
85 * Determines target user and group that is to be used for script execution.
86 * Uses preprocessor macros to distinguish between modes
88 void checkProcessPermissions(const std::string& scriptFilename,
89 const Configuration& config,
90 const Environment& environment,
92 GroupInfo& targetGroup) const
93 throw (SystemException, SoftException, SecurityException);
96 * Changes process permission (user and group).
97 * Uses preprocessor macros to distinguish between modes
99 void changeProcessPermissions(const Configuration& config,
100 const UserInfo& targetUser,
101 const GroupInfo& targetGroup) const
102 throw (SystemException, SoftException, SecurityException);
105 * Prepares the environment before invoking the script
107 Environment prepareEnvironment(const Environment& sourceEnv,
108 const Configuration& config,
110 throw (KeyNotFoundException);
113 * Returns interpreter for script being executed
115 std::string getInterpreter(const Environment& env,
116 const Configuration& config)
117 throw (SecurityException);
120 * Returns mode interpreter is using
122 TargetMode getTargetMode(const std::string& interpreter)
123 throw (SecurityException);
128 void executeScript(const std::string& scriptFilename,
129 const std::string& interpreter,
131 const Environment& env,
132 const Configuration& config) const
133 throw (SoftException);
136 * Checks ownership and permissions for parent directories
138 void checkParentDirectories(const File& file,
139 const UserInfo& owner,
140 const Configuration& config) const
141 throw (SoftException);
151 * Function called by the main() function
153 int run(CommandLine& cmdline, Environment& env);
157 int main(int argc, char **argv);
159 #endif // SUPHP_APPLICATION_H