1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 * @brief APR User ID Services
26 #include "apr_errno.h"
27 #include "apr_pools.h"
31 #endif /* __cplusplus */
34 * @defgroup apr_user User and Group ID Services
40 * Structure for determining user ownership.
43 typedef PSID apr_uid_t;
45 typedef uid_t apr_uid_t;
49 * Structure for determining group ownership.
52 typedef PSID apr_gid_t;
54 typedef gid_t apr_gid_t;
60 * Get the userid (and groupid) of the calling process
61 * @param userid Returns the user id
62 * @param groupid Returns the user's group id
63 * @param p The pool from which to allocate working space
64 * @remark This function is available only if APR_HAS_USER is defined.
66 APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *userid,
70 /** @deprecated @see apr_uid_current */
71 APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *userid,
75 * Get the user name for a specified userid
76 * @param username Pointer to new string containing user name (on output)
77 * @param userid The userid
78 * @param p The pool from which to allocate the string
79 * @remark This function is available only if APR_HAS_USER is defined.
81 APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid,
84 /** @deprecated @see apr_uid_name_get */
85 APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid,
88 * Get the userid (and groupid) for the specified username
89 * @param userid Returns the user id
90 * @param groupid Returns the user's group id
91 * @param username The username to lookup
92 * @param p The pool from which to allocate working space
93 * @remark This function is available only if APR_HAS_USER is defined.
95 APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *userid, apr_gid_t *groupid,
96 const char *username, apr_pool_t *p);
98 /** @deprecated @see apr_uid_get */
99 APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t *groupid,
100 const char *username, apr_pool_t *p);
103 * Get the home directory for the named user
104 * @param dirname Pointer to new string containing directory name (on output)
105 * @param username The named user
106 * @param p The pool from which to allocate the string
107 * @remark This function is available only if APR_HAS_USER is defined.
109 APR_DECLARE(apr_status_t) apr_uid_homepath_get(char **dirname,
110 const char *username,
113 /** @deprecated @see apr_uid_homepath_get */
114 APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname,
115 const char *username,
119 * Compare two user identifiers for equality.
120 * @param left One uid to test
121 * @param right Another uid to test
122 * @return APR_SUCCESS if the apr_uid_t strutures identify the same user,
123 * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid.
124 * @remark This function is available only if APR_HAS_USER is defined.
127 APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right);
129 /** @deprecated @see apr_uid_compare */
130 APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right);
132 #define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
133 /** @deprecated @see apr_uid_compare */
134 #define apr_compare_users(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
138 * Get the group name for a specified groupid
139 * @param groupname Pointer to new string containing group name (on output)
140 * @param groupid The groupid
141 * @param p The pool from which to allocate the string
142 * @remark This function is available only if APR_HAS_USER is defined.
144 APR_DECLARE(apr_status_t) apr_gid_name_get(char **groupname,
145 apr_gid_t groupid, apr_pool_t *p);
147 /** @deprecated @see apr_gid_name_get */
148 APR_DECLARE(apr_status_t) apr_group_name_get(char **groupname,
149 apr_gid_t groupid, apr_pool_t *p);
151 /** @deprecated @see apr_gid_name_get */
152 APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname,
153 apr_gid_t groupid, apr_pool_t *p);
156 * Get the groupid for a specified group name
157 * @param groupid Pointer to the group id (on output)
158 * @param groupname The group name to look up
159 * @param p The pool from which to allocate the string
160 * @remark This function is available only if APR_HAS_USER is defined.
162 APR_DECLARE(apr_status_t) apr_gid_get(apr_gid_t *groupid,
163 const char *groupname, apr_pool_t *p);
165 /** @deprecated @see apr_gid_get */
166 APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *groupid,
167 const char *groupname, apr_pool_t *p);
170 * Compare two group identifiers for equality.
171 * @param left One gid to test
172 * @param right Another gid to test
173 * @return APR_SUCCESS if the apr_gid_t strutures identify the same group,
174 * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid.
175 * @remark This function is available only if APR_HAS_USER is defined.
178 APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right);
179 /** @deprecated @see apr_gid_compare */
180 APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right);
182 #define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
183 /** @deprecated @see apr_gid_compare */
184 #define apr_compare_groups(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
187 #endif /* ! APR_HAS_USER */
195 #endif /* ! APR_USER_H */