Skip to content

Commit 207366c

Browse files
authored
Merge pull request #3068 from owasp-modsecurity/revert-2956-v2/mst/username
Revert "Centralized function to get user name"
2 parents 4629057 + 3f8d21c commit 207366c

File tree

4 files changed

+850
-822
lines changed

4 files changed

+850
-822
lines changed

apache2/msc_logging.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,15 @@ static char *construct_auditlog_filename(apr_pool_t *mp, const char *uniqueid) {
234234
* This is required for mpm-itk & mod_ruid2, though should be harmless for other implementations
235235
* It also changes the return statement.
236236
*/
237-
char *userinfo = get_username(mp);
237+
char *userinfo;
238+
apr_status_t rc;
239+
apr_uid_t uid;
240+
apr_gid_t gid;
241+
apr_uid_current(&uid, &gid, mp);
242+
rc = apr_uid_name_get(&userinfo, uid, mp);
243+
if (rc != APR_SUCCESS) {
244+
userinfo = apr_psprintf(mp, "%u", uid);
245+
}
238246

239247
apr_time_exp_lt(&t, apr_time_now());
240248

apache2/msc_util.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,14 +2843,3 @@ 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-
}

apache2/msc_util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ 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-
164162
#ifdef WITH_CURL
165163
int ip_tree_from_uri(TreeRoot **rtree, char *uri,
166164
apr_pool_t *mp, char **error_msg);

0 commit comments

Comments
 (0)