/[monit]/monit/http/processor.c
ViewVC logotype

Diff of /monit/http/processor.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.45 by martinp, Mon Aug 2 20:06:39 2004 UTC revision 1.46 by hauk, Sun Dec 12 23:45:09 2004 UTC
# Line 220  void out_print(HttpResponse res, const c Line 220  void out_print(HttpResponse res, const c
220      ssize_t have= 0;      ssize_t have= 0;
221    
222      va_start(ap, m);      va_start(ap, m);
223      buf= format(m, ap, &need);      buf= Util_formatString(m, ap, &need);
224      va_end(ap);      va_end(ap);
225      have= res->bufsize - res->bufused;      have= res->bufsize - res->bufused;
226      if(have <= need) {      if(have <= need) {
# Line 544  static HttpRequest create_HttpRequest(So Line 544  static HttpRequest create_HttpRequest(So
544      internal_error(S, SC_BAD_REQUEST, "No request found");      internal_error(S, SC_BAD_REQUEST, "No request found");
545      return NULL;      return NULL;
546    }    }
547    chomp(line,REQ_STRLEN);    Util_chomp(line,REQ_STRLEN);
548    /* RATS: ignore */ /* chomp does zero termination */    /* RATS: ignore */ /* Util_chomp does zero termination */
549    if(sscanf(line, "%s %s HTTP/%3[1.0]", method, url, protocol) != 3) {    if(sscanf(line, "%s %s HTTP/%3[1.0]", method, url, protocol) != 3) {
550      internal_error(S, SC_BAD_REQUEST, "Cannot parse request");      internal_error(S, SC_BAD_REQUEST, "Cannot parse request");
551      return NULL;      return NULL;
# Line 556  static HttpRequest create_HttpRequest(So Line 556  static HttpRequest create_HttpRequest(So
556    }    }
557    NEW(req);    NEW(req);
558    req->S= S;    req->S= S;
559    url_decode(url);    Util_urlDecode(url);
560    req->url= xstrdup(url);    req->url= xstrdup(url);
561    req->method= xstrdup(method);    req->method= xstrdup(method);
562    req->protocol= xstrdup(protocol);    req->protocol= xstrdup(protocol);
# Line 608  static void create_headers(HttpRequest r Line 608  static void create_headers(HttpRequest r
608      if(NULL != (value= strchr(line, ':'))) {      if(NULL != (value= strchr(line, ':'))) {
609        NEW(header);        NEW(header);
610        *value++= 0;        *value++= 0;
611        trim(line);        Util_trim(line);
612        trim(value);        Util_trim(value);
613        chomp(value, (REQ_STRLEN-(value-line)));        Util_chomp(value, (REQ_STRLEN-(value-line)));
614        header->name= xstrdup(line);        header->name= xstrdup(line);
615        header->value= xstrdup(value);        header->value= xstrdup(value);
616        header->next= req->headers;        header->next= req->headers;
# Line 766  static int basic_authenticate(HttpReques Line 766  static int basic_authenticate(HttpReques
766    char uname[STRLEN];    char uname[STRLEN];
767    const char *credentials= get_header(req, "Authorization");    const char *credentials= get_header(req, "Authorization");
768    
769    if(! (credentials && starts_with(credentials, "Basic "))) {    if(! (credentials && Util_startsWith(credentials, "Basic "))) {
770      return FALSE;      return FALSE;
771    }    }
772    strncpy(buf, &credentials[6], STRLEN);    strncpy(buf, &credentials[6], STRLEN);
# Line 783  static int basic_authenticate(HttpReques Line 783  static int basic_authenticate(HttpReques
783      return FALSE;      return FALSE;
784    }    }
785    /* Check if user exist */    /* Check if user exist */
786    if(NULL==get_user_credentials(uname)) {    if(NULL==Util_getUserCredentials(uname)) {
787      log("Warning: Client '%s' supplied unknown user '%s'"      log("Warning: Client '%s' supplied unknown user '%s'"
788          " accessing monit httpd\n", socket_get_remote_host(req->S), uname);          " accessing monit httpd\n", socket_get_remote_host(req->S), uname);
789      return FALSE;      return FALSE;
790    }    }
791    /* Check if user has supplied the right password */    /* Check if user has supplied the right password */
792    if(! compare_user_credentials(uname,  password)) {    if(! Util_checkCredentials(uname,  password)) {
793      log("Warning: Client '%s' supplied wrong password for user '%s'"      log("Warning: Client '%s' supplied wrong password for user '%s'"
794          " accessing monit httpd\n", socket_get_remote_host(req->S), uname);          " accessing monit httpd\n", socket_get_remote_host(req->S), uname);
795      return FALSE;      return FALSE;

Legend:
Removed from v.1.45  
changed lines
  Added in v.1.46

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26