Skip to content

Commit c7b28f0

Browse files
author
Marc Stern
committed
Centralized function compatible with Linux & Windows (also with mpm-itk & mod_ruid2) to get username
1 parent 11f85b8 commit c7b28f0

File tree

3 files changed

+821
-841
lines changed

3 files changed

+821
-841
lines changed

Diff for: apache2/msc_util.c

+11
Original file line numberDiff line numberDiff line change
@@ -2843,3 +2843,14 @@ char* strtok_r(
28432843
}
28442844
#endif
28452845

2846+
// Function compatible with Linux & Windows, also with mpm-itk & mod_ruid2
2847+
char* get_username(apr_pool_t* mp) {
2848+
char* username;
2849+
apr_uid_t uid;
2850+
apr_gid_t gid;
2851+
int rc = apr_uid_current(&uid, &gid, mp);
2852+
if (rc != APR_SUCCESS) return "apache";
2853+
rc = apr_uid_name_get(&username, uid, mp);
2854+
if (rc != APR_SUCCESS) return "apache";
2855+
return username;
2856+
}

Diff for: apache2/msc_util.h

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ int DSOLOCAL tree_contains_ip(apr_pool_t *mp, TreeRoot *rtree,
159159
int DSOLOCAL ip_tree_from_param(apr_pool_t *pool,
160160
char *param, TreeRoot **rtree, char **error_msg);
161161

162+
char DSOLOCAL *get_username(apr_pool_t* mp);
163+
162164
#ifdef WITH_CURL
163165
int ip_tree_from_uri(TreeRoot **rtree, char *uri,
164166
apr_pool_t *mp, char **error_msg);

0 commit comments

Comments
 (0)