00001 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as 00002 * applicable. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef APR_USER_H 00018 #define APR_USER_H 00019 00020 /** 00021 * @file apr_user.h 00022 * @brief APR User ID Services 00023 */ 00024 00025 #include "apr.h" 00026 #include "apr_errno.h" 00027 #include "apr_pools.h" 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif /* __cplusplus */ 00032 00033 /** 00034 * @defgroup apr_user User and Group ID Services 00035 * @ingroup APR 00036 * @{ 00037 */ 00038 00039 /** 00040 * Structure for determining user ownership. 00041 */ 00042 #ifdef WIN32 00043 typedef PSID apr_uid_t; 00044 #else 00045 typedef uid_t apr_uid_t; 00046 #endif 00047 00048 /** 00049 * Structure for determining group ownership. 00050 */ 00051 #ifdef WIN32 00052 typedef PSID apr_gid_t; 00053 #else 00054 typedef gid_t apr_gid_t; 00055 #endif 00056 00057 #if APR_HAS_USER 00058 00059 /** 00060 * Get the userid (and groupid) of the calling process 00061 * @param userid Returns the user id 00062 * @param groupid Returns the user's group id 00063 * @param p The pool from which to allocate working space 00064 * @remark This function is available only if APR_HAS_USER is defined. 00065 */ 00066 APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *userid, 00067 apr_gid_t *groupid, 00068 apr_pool_t *p); 00069 00070 /** @deprecated @see apr_uid_current */ 00071 APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *userid, 00072 apr_gid_t *groupid, 00073 apr_pool_t *p); 00074 /** 00075 * Get the user name for a specified userid 00076 * @param username Pointer to new string containing user name (on output) 00077 * @param userid The userid 00078 * @param p The pool from which to allocate the string 00079 * @remark This function is available only if APR_HAS_USER is defined. 00080 */ 00081 APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid, 00082 apr_pool_t *p); 00083 00084 /** @deprecated @see apr_uid_name_get */ 00085 APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid, 00086 apr_pool_t *p); 00087 /** 00088 * Get the userid (and groupid) for the specified username 00089 * @param userid Returns the user id 00090 * @param groupid Returns the user's group id 00091 * @param username The username to lookup 00092 * @param p The pool from which to allocate working space 00093 * @remark This function is available only if APR_HAS_USER is defined. 00094 */ 00095 APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *userid, apr_gid_t *groupid, 00096 const char *username, apr_pool_t *p); 00097 00098 /** @deprecated @see apr_uid_get */ 00099 APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t *groupid, 00100 const char *username, apr_pool_t *p); 00101 00102 /** 00103 * Get the home directory for the named user 00104 * @param dirname Pointer to new string containing directory name (on output) 00105 * @param username The named user 00106 * @param p The pool from which to allocate the string 00107 * @remark This function is available only if APR_HAS_USER is defined. 00108 */ 00109 APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname, 00110 const char *username, 00111 apr_pool_t *p); 00112 00113 /** @deprecated @see apr_uid_homepath_get */ 00114 APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname, 00115 const char *username, 00116 apr_pool_t *p); 00117 00118 /** 00119 * Compare two user identifiers for equality. 00120 * @param left One uid to test 00121 * @param right Another uid to test 00122 * @return APR_SUCCESS if the apr_uid_t strutures identify the same user, 00123 * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid. 00124 * @remark This function is available only if APR_HAS_USER is defined. 00125 */ 00126 #if defined(WIN32) 00127 APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right); 00128 00129 /** @deprecated @see apr_uid_compare */ 00130 APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right); 00131 #else 00132 #define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) 00133 /** @deprecated @see apr_uid_compare */ 00134 #define apr_compare_users(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) 00135 #endif 00136 00137 /** 00138 * Get the group name for a specified groupid 00139 * @param groupname Pointer to new string containing group name (on output) 00140 * @param groupid The groupid 00141 * @param p The pool from which to allocate the string 00142 * @remark This function is available only if APR_HAS_USER is defined. 00143 */ 00144 APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname, 00145 apr_gid_t groupid, apr_pool_t *p); 00146 00147 /** @deprecated @see apr_gid_name_get */ 00148 APR_DECLARE(apr_status_t) apr_group_name_get(char **groupname, 00149 apr_gid_t groupid, apr_pool_t *p); 00150 00151 /** @deprecated @see apr_gid_name_get */ 00152 APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname, 00153 apr_gid_t groupid, apr_pool_t *p); 00154 00155 /** 00156 * Get the groupid for a specified group name 00157 * @param groupid Pointer to the group id (on output) 00158 * @param groupname The group name to look up 00159 * @param p The pool from which to allocate the string 00160 * @remark This function is available only if APR_HAS_USER is defined. 00161 */ 00162 APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid, 00163 const char *groupname, apr_pool_t *p); 00164 00165 /** @deprecated @see apr_gid_get */ 00166 APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *groupid, 00167 const char *groupname, apr_pool_t *p); 00168 00169 /** 00170 * Compare two group identifiers for equality. 00171 * @param left One gid to test 00172 * @param right Another gid to test 00173 * @return APR_SUCCESS if the apr_gid_t strutures identify the same group, 00174 * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid. 00175 * @remark This function is available only if APR_HAS_USER is defined. 00176 */ 00177 #if defined(WIN32) 00178 APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right); 00179 /** @deprecated @see apr_gid_compare */ 00180 APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right); 00181 #else 00182 #define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) 00183 /** @deprecated @see apr_gid_compare */ 00184 #define apr_compare_groups(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH) 00185 #endif 00186 00187 #endif /* ! APR_HAS_USER */ 00188 00189 /** @} */ 00190 00191 #ifdef __cplusplus 00192 } 00193 #endif 00194 00195 #endif /* ! APR_USER_H */