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_API_LINUX_H
27 #define SUPHP_API_LINUX_H
32 #include "Environment.hpp"
33 #include "SmartPtr.hpp"
35 #include "API_Linux_Logger.hpp"
40 * Class encapsulating system-specific API for Linux.
42 class API_Linux : public API {
44 static SmartPtr<API_Linux_Logger> logger;
46 * Internal function for checking wheter path
49 bool isSymlink(const std::string path) const
50 throw (SystemException);
53 * Internal function to read the target of a symlink
55 std::string readSymlink(const std::string path) const
56 throw (SystemException);
60 * Get environment variable
62 virtual Environment getProcessEnvironment();
65 * Get UserInfo from username
67 virtual UserInfo getUserInfo(const std::string username)
68 throw (LookupException);
71 * Get UserInfo from UID
73 virtual UserInfo getUserInfo(const int uid);
76 * Get GroupInfo from groupname
78 virtual GroupInfo getGroupInfo(const std::string groupname)
79 throw (LookupException);
82 * Get GroupInfo from GID
84 virtual GroupInfo getGroupInfo(const int gid);
87 * Get UserInfo for effective UID
89 virtual UserInfo getEffectiveProcessUser();
92 * Get UserInfo for real UID
94 virtual UserInfo getRealProcessUser();
97 * Get GroupInfo for effective GID
99 virtual GroupInfo getEffectiveProcessGroup();
102 * Get GroupInfo for real GID
104 virtual GroupInfo getRealProcessGroup();
107 virtual Logger& getSystemLogger();
110 * Set UID of current process
112 virtual void setProcessUser(const UserInfo& user) const
113 throw (SystemException);
116 * Set GID of current process
118 virtual void setProcessGroup(const GroupInfo& group) const
119 throw (SystemException);
122 * Returns username from UserInfo
124 virtual std::string UserInfo_getUsername(const UserInfo& uinfo) const
125 throw (LookupException);
128 * Returns group from UserInfo
130 virtual GroupInfo UserInfo_getGroupInfo(const UserInfo& uinfo) const throw (LookupException);
133 * Checks whether UserInfo objects represents the super-user
135 virtual bool UserInfo_isSuperUser(const UserInfo& uinfo) const;
138 * Returns groupname from GroupInfo
140 std::string GroupInfo_getGroupname(const GroupInfo& ginfo) const
141 throw (LookupException);
144 * Checks whether file exists
146 virtual bool File_exists(const File& file) const;
149 * Returns real path to file
151 virtual std::string File_getRealPath(const File& file) const
152 throw (SystemException);
155 * Checks for a permission bit
157 virtual bool File_hasPermissionBit(const File& file, FileMode perm)
158 const throw (SystemException);
161 * Returns UID of file
163 virtual UserInfo File_getUser(const File& file) const
164 throw (SystemException);
167 * Returns GID of file
169 virtual GroupInfo File_getGroup(const File& file) const
170 throw (SystemException);
173 * Runs another program (replaces current process)
175 virtual void execute(std::string program, const CommandLine& cline,
176 const Environment& env) const
177 throw (SystemException);
180 * Returns current working directory
182 virtual std::string getCwd() const throw (SystemException);
185 * Sets current working directory
187 virtual void setCwd(const std::string& dir) const
188 throw (SystemException);
193 virtual void setUmask(int umask) const throw (SystemException);
196 * Sets new root directory for current process
198 virtual void chroot(const std::string& dir) const
199 throw (SystemException);
203 #endif // SUPHP_API_LINUX_H