fixed acl_evaluate

Fri, 01 Mar 2013 22:44:54 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 01 Mar 2013 22:44:54 +0100
changeset 53
5ec9abba1027
parent 52
aced2245fb1c
child 54
3a1d5a52adfc

fixed acl_evaluate

src/server/daemon/acl.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/acl.c	Fri Mar 01 21:15:52 2013 +0100
+++ b/src/server/daemon/acl.c	Fri Mar 01 22:44:54 2013 +0100
@@ -121,20 +121,36 @@
             // the acl denies access
             
             if(!user) {
-                pblock_nvinsert(
-                        "www-authenticate",
-                        "Basic realm=\"Webserver\"",
-                        rq->srvhdrs);
+                char *value = NULL;
+                if(acl->authprompt) {
+                    size_t realmlen = strlen(acl->authprompt);
+                    size_t len = realmlen + 16;
+                    value = pool_malloc(sn->pool, len);
+                    if(value) {
+                        snprintf(
+                                value,
+                                len,
+                                "Basic realm=\"%s\"",
+                                acl->authprompt);
+                    }
+                }
+                if(!value) {
+                    value = "Basic realm=\"login\"";
+                }
+                pblock_nvinsert("www-authenticate", value, rq->srvhdrs);
                 protocol_status(sn, rq, PROTOCOL_UNAUTHORIZED, NULL);
+            } else {
+                user->free(user);
             }
-            user->free(user);
             return REQ_ABORTED;
         } 
         elm = elm->next;
     }
     
     // ok - all acls allowed access
-    user->free(user);
+    if(user) {
+        user->free(user);
+    }
     return REQ_PROCEED;
 }
 

mercurial