Ticket #463: 0003-Protect-the-status-page-with-authentication.patch

File 0003-Protect-the-status-page-with-authentication.patch, 1.1 KB (added by wichert@…, 4 years ago)
  • src/http.c

    From 7787cf19624f7cc8ce353f7295371862bd6f7500 Mon Sep 17 00:00:00 2001
    From: Wichert Akkerman <wichert@wiggy.net>
    Date: Mon, 28 Apr 2008 12:06:40 +0200
    Subject: [PATCH] Protect the status page with authentication
    
    The LibHTTPD API is a bit silly here.
    ---
     src/http.c |   10 ++++++++++
     1 files changed, 10 insertions(+), 0 deletions(-)
    
    diff --git a/src/http.c b/src/http.c
    index b2b8ff9..90e4890 100644
    a b  
    137137void  
    138138http_callback_status(httpd *webserver, request *r) 
    139139{ 
     140        const s_config *config = config_get_config(); 
    140141        char * status = NULL; 
    141142        char *buf; 
     143 
     144        if (config->httpdusername &&  
     145                        (strcmp(config->httpdusername, r->request.authUser) || 
     146                         strcmp(config->httpdpassword, r->request.authPassword))) { 
     147                debug(LOG_INFO, "Status page requested, forcing authentication"); 
     148                httpdForceAuthenticate(r, config->httpdrealm); 
     149                return; 
     150        } 
     151 
    142152        status = get_status_text(); 
    143153        safe_asprintf(&buf, "<pre>%s</pre>", status); 
    144154        send_http_page(r, "WiFiDog Status", buf);