Apache Portable Runtime
apr_user.h
Go to the documentation of this file.
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #ifndef APR_USER_H
18 #define APR_USER_H
19 
20 /**
21  * @file apr_user.h
22  * @brief APR User ID Services
23  */
24 
25 #include "apr.h"
26 #include "apr_errno.h"
27 #include "apr_pools.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32 
33 /**
34  * @defgroup apr_user User and Group ID Services
35  * @ingroup APR
36  * @{
37  */
38 
39 /**
40  * Structure for determining user ownership.
41  */
42 #ifdef WIN32
43 typedef PSID apr_uid_t;
44 #else
45 typedef uid_t apr_uid_t;
46 #endif
47 
48 /**
49  * Structure for determining group ownership.
50  */
51 #ifdef WIN32
52 typedef PSID apr_gid_t;
53 #else
54 typedef gid_t apr_gid_t;
55 #endif
56 
57 #if APR_HAS_USER
58 
59 /**
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.
65  */
66 APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *userid,
67  apr_gid_t *groupid,
68  apr_pool_t *p);
69 
70 /**
71  * Get the user name for a specified userid
72  * @param username Pointer to new string containing user name (on output)
73  * @param userid The userid
74  * @param p The pool from which to allocate the string
75  * @remark This function is available only if APR_HAS_USER is defined.
76  */
77 APR_DECLARE(apr_status_t) apr_uid_name_get(char **username, apr_uid_t userid,
78  apr_pool_t *p);
79 
80 /**
81  * Get the userid (and groupid) for the specified username
82  * @param userid Returns the user id
83  * @param groupid Returns the user's group id
84  * @param username The username to look up
85  * @param p The pool from which to allocate working space
86  * @remark This function is available only if APR_HAS_USER is defined.
87  */
88 APR_DECLARE(apr_status_t) apr_uid_get(apr_uid_t *userid, apr_gid_t *groupid,
89  cons