I am writing a simple Subversion backend. Thanks to WebDAV, we have an Apache installation serving the SVN repositories. In addition, authentication is performed through the Apache and Open Directory realms. For what it's worth, it's basically a pretty vanilla setup for Mac OS X Server 10.6.
Now, some of the tasks that we face before starting work should know the name of the user who is causing the action. For example, creating a repository needs this so that we get the correct logs of the person who created them. If I did not provide this information, SVN simply uses the process that created it, in our case, this is the user running httpd.
I do this in php, but I don't have to do this with php. If I can get the information in a shell script, this is good too. The important thing is that I somehow get the information. The solution I first developed, which I assumed worked because it provided my username correctly, simply calls:
get_current_user();
However, it seems like this always returns my username, even if some other user triggers the action on login. Is there a way to get the right user?
EDIT: I may have been too fast to jump a gun here. It seems that the first variable is not set after a certain amount of time. However, the user is still registered as there is no login request. Therefore, the solution below is not applicable.
idjit. ( ):
$username = $_SERVER["PHP_AUTH_USER"];
:
$username = apache_getenv("REMOTE_USER");
- , ? , , , Apache 2. Apache 2, .