summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2000-10-11 19:40:56 +0000
committerSascha Schumann <sas@php.net>2000-10-11 19:40:56 +0000
commit0fd6a7ed18fc23c3b90175da5167ed8d6af9e3aa (patch)
treea0b72f17ca5e394eb869a0a676dbbec8e6cb57f6
parentaee3c65a8f58cedef14d1397c742ade93b4a79bc (diff)
downloadphp-git-0fd6a7ed18fc23c3b90175da5167ed8d6af9e3aa.tar.gz
Provide basic auth info to scripts.
Protect shutdown handler from being called multiple times.
-rw-r--r--sapi/thttpd/thttpd.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
index 1dc2b11b2f..47eed6767f 100644
--- a/sapi/thttpd/thttpd.c
+++ b/sapi/thttpd/thttpd.c
@@ -241,6 +241,23 @@ static void thttpd_request_ctor(TLS_D SLS_DC)
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
+ if (TG(hc)->authorization[0] != '\0'
+ && strncmp(TG(hc)->authorization, "Basic ", 6) == 0) {
+ char *pass;
+ char *user;
+
+ user = php_base64_decode(TG(hc)->authorization + 6, strlen(TG(hc)->authorization) - 6, NULL);
+ if (user) {
+ pass = strchr(user, ':');
+ if (pass) {
+ *pass++ = '\0';
+ SG(request_info).auth_user = user;
+ SG(request_info).auth_password = estrdup(pass);
+ } else
+ efree(user);
+ }
+ }
+
TG(post_off) = TG(hc)->read_idx - TG(hc)->checked_idx;
/* avoid feeding \r\n from POST data to SAPI */
@@ -283,6 +300,8 @@ void thttpd_php_init(void)
void thttpd_php_shutdown(void)
{
- sapi_module.shutdown(&sapi_module);
- sapi_shutdown();
+ if (SG(server_context) != NULL) {
+ sapi_module.shutdown(&sapi_module);
+ sapi_shutdown();
+ }
}