~ubuntu-branches/debian/jessie/suphp/jessie

« back to all changes in this revision

Viewing changes to src/Application.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Emmanuel Lacour
  • Date: 2009-08-03 15:15:38 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090803151538-431r96du70316dpk
Tags: 0.7.1-1
* New upstream release (closes: #528379, #520182) 
* debian/NEWS: add information about AddHandler -> AddType change introduced
  in 0.6.2-2 (closes: #517805)
* debian/conf/suphp.conf, debian/patches/01_debian.dpatch: switch from
  application/x-httpd-php to application/x-httpd-suphp to allow
  simultaneous use of mod_suphp and mod_php (closes: #519005, #514725)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    suPHP - (c)2002-2005 Sebastian Marsching <sebastian@marsching.com>
 
2
    suPHP - (c)2002-2008 Sebastian Marsching <sebastian@marsching.com>
3
3
 
4
4
    This file is part of suPHP.
5
5
 
39
39
#include "SystemException.hpp"
40
40
#include "SoftException.hpp"
41
41
#include "SecurityException.hpp"
 
42
#include "UserInfo.hpp"
 
43
#include "GroupInfo.hpp"
42
44
 
43
45
namespace suPHP {
44
46
    /**
47
49
     */
48
50
    class Application {
49
51
    private:
50
 
        /**
51
 
         * Print message containing version information
52
 
         */
53
 
        void printAboutMessage();
54
 
        
55
 
        /**
56
 
         * Checks wheter process has root privileges
57
 
         * and calling user is webserver user
58
 
         */
59
 
        void checkProcessPermissions(Configuration& config) 
60
 
            throw (SecurityException, LookupException);
61
 
        /**
62
 
         * Checks scriptfile.
63
 
         * Includes check for path, symbollink and permissions
64
 
         */
65
 
        void checkScriptFile(const std::string& scriptFilename, 
66
 
                             const Configuration& config, 
67
 
                             const Environment& environment) const
68
 
            throw (SystemException, SoftException);
69
 
        
70
 
        /**
71
 
         * Changes process permission (user and group).
72
 
         * Uses preprocessor macros to distinguish between modes
73
 
         */
74
 
        void changeProcessPermissions(const std::string& scriptFilename,
75
 
                                      const Configuration& config,
76
 
                                      const Environment& environment) const
77
 
            throw (SystemException, SoftException, SecurityException);
78
 
 
79
 
        /**
80
 
         * Prepares the environment before invoking the script
81
 
         */
82
 
        Environment prepareEnvironment(const Environment& sourceEnv,
83
 
                                       const Configuration& config,
84
 
                                       TargetMode mode)
85
 
            throw (KeyNotFoundException);
86
 
 
87
 
        /**
88
 
         * Returns interpreter for script being executed
89
 
         */
90
 
        std::string getInterpreter(const Environment& env,
91
 
                                   const Configuration& config)
92
 
            throw (SecurityException);
93
 
        
94
 
        /**
95
 
         * Returns mode interpreter is using
96
 
         */
97
 
        TargetMode getTargetMode(const std::string& interpreter)
98
 
            throw (SecurityException);
99
 
 
100
 
        /**
101
 
         * Runs script
102
 
         */
103
 
        void executeScript(const std::string& scriptFilename,
104
 
                           const std::string& interpreter,
105
 
                           TargetMode mode,
106
 
                           const Environment& env,
107
 
                           const Configuration& config) const
108
 
            throw (SoftException);
 
52
        /**
 
53
         * Print message containing version information
 
54
         */
 
55
        void printAboutMessage();
 
56
        
 
57
        /**
 
58
         * Checks wheter process has root privileges
 
59
         * and calling user is webserver user
 
60
         */
 
61
        void checkProcessPermissions(Configuration& config) 
 
62
            throw (SecurityException, LookupException);
 
63
        
 
64
        /**
 
65
         * Checks scriptfile (first stage).
 
66
         * Includes check for VHost docroot, symbollink and permissions.
 
67
         */
 
68
        void checkScriptFileStage1(const std::string& scriptFilename, 
 
69
                             const Configuration& config, 
 
70
                             const Environment& environment) const
 
71
            throw (SystemException, SoftException);
 
72
        
 
73
        /**
 
74
         * Checks scriptfile.
 
75
         * Includes check for paths which might be user specific
 
76
         */
 
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);
 
83
        
 
84
        /**
 
85
         * Determines target user and group that is to be used for script execution.
 
86
         * Uses preprocessor macros to distinguish between modes
 
87
         */
 
88
        void checkProcessPermissions(const std::string& scriptFilename,
 
89
                                      const Configuration& config,
 
90
                                      const Environment& environment,
 
91
                                      UserInfo& targetUser,
 
92
                                      GroupInfo& targetGroup) const
 
93
            throw (SystemException, SoftException, SecurityException);
 
94
        
 
95
        /**
 
96
         * Changes process permission (user and group).
 
97
         * Uses preprocessor macros to distinguish between modes
 
98
         */
 
99
        void changeProcessPermissions(const Configuration& config,
 
100
                                      const UserInfo& targetUser,
 
101
                                      const GroupInfo& targetGroup) const
 
102
            throw (SystemException, SoftException, SecurityException);
 
103
 
 
104
        /**
 
105
         * Prepares the environment before invoking the script
 
106
         */
 
107
        Environment prepareEnvironment(const Environment& sourceEnv,
 
108
                                       const Configuration& config,
 
109
                                       TargetMode mode)
 
110
            throw (KeyNotFoundException);
 
111
 
 
112
        /**
 
113
         * Returns interpreter for script being executed
 
114
         */
 
115
        std::string getInterpreter(const Environment& env,
 
116
                                   const Configuration& config)
 
117
            throw (SecurityException);
 
118
        
 
119
        /**
 
120
         * Returns mode interpreter is using
 
121
         */
 
122
        TargetMode getTargetMode(const std::string& interpreter)
 
123
            throw (SecurityException);
 
124
 
 
125
        /**
 
126
         * Runs script
 
127
         */
 
128
        void executeScript(const std::string& scriptFilename,
 
129
                           const std::string& interpreter,
 
130
                           TargetMode mode,
 
131
                           const Environment& env,
 
132
                           const Configuration& config) const
 
133
            throw (SoftException);
 
134
        
 
135
        /**
 
136
         * Checks ownership and permissions for parent directories
 
137
         */
 
138
        void checkParentDirectories(const File& file,
 
139
                                    const UserInfo& owner,
 
140
                                    const Configuration& config) const
 
141
            throw (SoftException);
109
142
 
110
143
 
111
144
    public:
112
 
        /**
113
 
         * Constructer
114
 
         */
115
 
        Application();
116
 
        
117
 
        /**
118
 
         * Function called by the main() function
119
 
         */
120
 
        int run(CommandLine& cmdline, Environment& env);
 
145
        /**
 
146
         * Constructer
 
147
         */
 
148
        Application();
 
149
        
 
150
        /**
 
151
         * Function called by the main() function
 
152
         */
 
153
        int run(CommandLine& cmdline, Environment& env);
121
154
    };
122
155
};
123
156