X-Git-Url: http://git.home-dn.net/?p=manu%2Fsuphp.git;a=blobdiff_plain;f=src%2FApplication.hpp;h=82b8d20bb72dad67a6c9b7338029c754dcbea907;hp=be7ed828baa7b345726bd989eee623e6c1e55eb7;hb=849f4a7977b5780eacae8fad7a078d05f4a615ee;hpb=b0eaa3f1fbf491fdc8a3044cf20754f14254338a diff --git a/src/Application.hpp b/src/Application.hpp index be7ed82..82b8d20 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -1,5 +1,5 @@ /* - suPHP - (c)2002-2005 Sebastian Marsching + suPHP - (c)2002-2008 Sebastian Marsching This file is part of suPHP. @@ -39,6 +39,8 @@ enum TargetMode { #include "SystemException.hpp" #include "SoftException.hpp" #include "SecurityException.hpp" +#include "UserInfo.hpp" +#include "GroupInfo.hpp" namespace suPHP { /** @@ -47,77 +49,108 @@ namespace suPHP { */ class Application { private: - /** - * Print message containing version information - */ - void printAboutMessage(); - - /** - * Checks wheter process has root privileges - * and calling user is webserver user - */ - void checkProcessPermissions(Configuration& config) - throw (SecurityException, LookupException); - /** - * Checks scriptfile. - * Includes check for path, symbollink and permissions - */ - void checkScriptFile(const std::string& scriptFilename, - const Configuration& config, - const Environment& environment) const - throw (SystemException, SoftException); - - /** - * Changes process permission (user and group). - * Uses preprocessor macros to distinguish between modes - */ - void changeProcessPermissions(const std::string& scriptFilename, - const Configuration& config, - const Environment& environment) const - throw (SystemException, SoftException, SecurityException); - - /** - * Prepares the environment before invoking the script - */ - Environment prepareEnvironment(const Environment& sourceEnv, - const Configuration& config, - TargetMode mode) - throw (KeyNotFoundException); - - /** - * Returns interpreter for script being executed - */ - std::string getInterpreter(const Environment& env, - const Configuration& config) - throw (SecurityException); - - /** - * Returns mode interpreter is using - */ - TargetMode getTargetMode(const std::string& interpreter) - throw (SecurityException); - - /** - * Runs script - */ - void executeScript(const std::string& scriptFilename, - const std::string& interpreter, - TargetMode mode, - const Environment& env, - const Configuration& config) const - throw (SoftException); + /** + * Print message containing version information + */ + void printAboutMessage(); + + /** + * Checks wheter process has root privileges + * and calling user is webserver user + */ + void checkProcessPermissions(Configuration& config) + throw (SecurityException, LookupException); + + /** + * Checks scriptfile (first stage). + * Includes check for VHost docroot, symbollink and permissions. + */ + void checkScriptFileStage1(const std::string& scriptFilename, + const Configuration& config, + const Environment& environment) const + throw (SystemException, SoftException); + + /** + * Checks scriptfile. + * Includes check for paths which might be user specific + */ + void checkScriptFileStage2(const std::string& scriptFilename, + const Configuration& config, + const Environment& environment, + const UserInfo& targetUser, + const GroupInfo& targetGroup) const + throw (SystemException, SoftException); + + /** + * Determines target user and group that is to be used for script execution. + * Uses preprocessor macros to distinguish between modes + */ + void checkProcessPermissions(const std::string& scriptFilename, + const Configuration& config, + const Environment& environment, + UserInfo& targetUser, + GroupInfo& targetGroup) const + throw (SystemException, SoftException, SecurityException); + + /** + * Changes process permission (user and group). + * Uses preprocessor macros to distinguish between modes + */ + void changeProcessPermissions(const Configuration& config, + const UserInfo& targetUser, + const GroupInfo& targetGroup) const + throw (SystemException, SoftException, SecurityException); + + /** + * Prepares the environment before invoking the script + */ + Environment prepareEnvironment(const Environment& sourceEnv, + const Configuration& config, + TargetMode mode) + throw (KeyNotFoundException); + + /** + * Returns interpreter for script being executed + */ + std::string getInterpreter(const Environment& env, + const Configuration& config) + throw (SecurityException); + + /** + * Returns mode interpreter is using + */ + TargetMode getTargetMode(const std::string& interpreter) + throw (SecurityException); + + /** + * Runs script + */ + void executeScript(const std::string& scriptFilename, + const std::string& interpreter, + TargetMode mode, + const Environment& env, + const Configuration& config) const + throw (SoftException); + + /** + * Checks ownership and permissions for parent directories + */ + void checkParentDirectories(const File& file, + const UserInfo& owner, + const Configuration& config) const + throw (SoftException); public: - /** - * Constructer - */ - Application(); - - /** - * Function called by the main() function - */ - int run(CommandLine& cmdline, Environment& env); + /** + * Constructer + */ + Application(); + + /** + * Function called by the main() function + */ + int run(CommandLine& cmdline, Environment& env); }; };