Centralized function to get user name, compatible with Linux & Windows (also with mpm-itk & mod_ruid2)

This commit is contained in:
Marc Stern
2023-08-11 17:22:24 +02:00
parent b3b33c9ff1
commit 0708339359
3 changed files with 821 additions and 841 deletions

View File

@@ -2843,3 +2843,14 @@ char* strtok_r(
}
#endif
// Function compatible with Linux & Windows, also with mpm-itk & mod_ruid2
char* get_username(apr_pool_t* mp) {
char* username;
apr_uid_t uid;
apr_gid_t gid;
int rc = apr_uid_current(&uid, &gid, mp);
if (rc != APR_SUCCESS) return "apache";
rc = apr_uid_name_get(&username, uid, mp);
if (rc != APR_SUCCESS) return "apache";
return username;
}