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
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 * Returns home directory from UserInfo
123 virtual std::string
UserInfo_getHomeDirectory(const UserInfo
& uinfo
) const
124 throw (LookupException
) =0;
127 * Checks whether UserInfo objects represents the super-user
129 virtual bool UserInfo_isSuperUser(const UserInfo
& uinfo
) const =0;
132 * Returns groupname from GroupInfo
134 virtual std::string
GroupInfo_getGroupname(const GroupInfo
& ginfo
)
135 const throw (LookupException
) =0;
138 * Checks whether file exists
140 virtual bool File_exists(const File
& file
) const =0;
143 * Returns real path to file
145 virtual std::string
File_getRealPath(const File
& file
) const
146 throw (SystemException
) =0;
149 * Checks for a permission bit
151 virtual bool File_hasPermissionBit(const File
& file
, FileMode perm
)
152 const throw (SystemException
) =0;
155 * Returns UID of file
157 virtual UserInfo
File_getUser(const File
& file
) const
158 throw (SystemException
) =0;
161 * Returns GID of file
163 virtual GroupInfo
File_getGroup(const File
& file
) const
164 throw (SystemException
) =0;
167 * Checks whether a file is a symlink
169 virtual bool File_isSymlink(const File
& file
) const
170 throw (SystemException
) =0;
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
) =0;
180 * Returns current working directory
182 virtual std::string
getCwd() const throw (SystemException
) =0;
186 * Sets current working directory
188 virtual void setCwd(const std::string
& dir
) const
189 throw (SystemException
) =0;
194 virtual void setUmask(int umask
) const throw (SystemException
) =0;
197 * Changes root directory for the current process
199 virtual void chroot(const std::string
& dir
) const
200 throw (SystemException
) =0;
204 #endif // SUPHP_API_H