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
30 #include "CommandLine.hpp"
31 #include "Environment.hpp"
32 #include "UserInfo.hpp"
33 #include "GroupInfo.hpp"
39 * Class encapsulating system-specific API.
45 * Get environment variable
47 virtual Environment getProcessEnvironment() =0;
50 * Get UserInfo from username
52 virtual UserInfo getUserInfo(const std::string username)
53 throw (LookupException) =0;
56 * Get UserInfo from UID
58 virtual UserInfo getUserInfo(const int uid) =0;
61 * Get GroupInfo from groupname
63 virtual GroupInfo getGroupInfo(const std::string groupname)
64 throw (LookupException) =0;
67 * Get GroupInfo from GID
69 virtual GroupInfo getGroupInfo(const int gid) =0;
72 * Get UserInfo for effective UID
74 virtual UserInfo getEffectiveProcessUser() =0;
77 * Get UserInfo for real UID
79 virtual UserInfo getRealProcessUser() =0;
82 * Get GroupInfo for effective GID
84 virtual GroupInfo getEffectiveProcessGroup() =0;
87 * Get GroupInfo for real GID
89 virtual GroupInfo getRealProcessGroup() =0;
92 * Get Logger implementation
94 virtual Logger& getSystemLogger() =0;
97 * Set UID of current process
99 virtual void setProcessUser(const UserInfo& user) const
100 throw (SystemException) =0;
103 * Set GID of current process
105 virtual void setProcessGroup(const GroupInfo& group) const
106 throw (SystemException) =0;
109 * Returns username from UserInfo
111 virtual std::string UserInfo_getUsername(const UserInfo& uinfo) const
112 throw (LookupException) =0;
115 * Returns group from UserInfo
117 virtual GroupInfo UserInfo_getGroupInfo(const UserInfo& uinfo) const
118 throw (LookupException) =0;
121 * Checks whether UserInfo objects represents the super-user
123 virtual bool UserInfo_isSuperUser(const UserInfo& uinfo) const =0;
126 * Returns groupname from GroupInfo
128 virtual std::string GroupInfo_getGroupname(const GroupInfo& ginfo)
129 const throw (LookupException) =0;
132 * Checks whether file exists
134 virtual bool File_exists(const File& file) const =0;
137 * Returns real path to file
139 virtual std::string File_getRealPath(const File& file) const
140 throw (SystemException) =0;
143 * Checks for a permission bit
145 virtual bool File_hasPermissionBit(const File& file, FileMode perm)
146 const throw (SystemException) =0;
149 * Returns UID of file
151 virtual UserInfo File_getUser(const File& file) const
152 throw (SystemException) =0;
155 * Returns GID of file
157 virtual GroupInfo File_getGroup(const File& file) const
158 throw (SystemException) =0;
161 * Runs another program (replaces current process)
163 virtual void execute(std::string program, const CommandLine& cline,
164 const Environment& env) const
165 throw (SystemException) =0;
168 * Returns current working directory
170 virtual std::string getCwd() const throw (SystemException) =0;
174 * Sets current working directory
176 virtual void setCwd(const std::string& dir) const
177 throw (SystemException) =0;
182 virtual void setUmask(int umask) const throw (SystemException) =0;
185 * Changes root directory for the current process
187 virtual void chroot(const std::string& dir) const
188 throw (SystemException) =0;
192 #endif // SUPHP_API_H