/[monit]/monit/util.c
ViewVC logotype

Diff of /monit/util.c

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

revision 1.97 by hauk, Tue Sep 30 16:03:13 2003 UTC revision 1.98 by chopp, Wed Oct 1 13:34:46 2003 UTC
# Line 214  char *rtrim(char *s) { Line 214  char *rtrim(char *s) {
214   * @return s with any enclosed quotes removed   * @return s with any enclosed quotes removed
215   */   */
216    
217  char *trim_quotes(char *s) {  void trim_quotes(char *s) {
218    
219    char *t= s;    char *t= s;
220    char tmp=0;    char tmp=0;
# Line 228  char *trim_quotes(char *s) { Line 228  char *trim_quotes(char *s) {
228    
229    } else {    } else {
230    
231      return s;      return;
232            
233    }    }
234    
235    if(t[strlen(t)-1]==tmp) t[strlen(t)-1]= '\0';    while ( *t != tmp && *t != '\0' ) {
236    
237    return strcpy(s, t);      *(t-1) = *t;
238        t++;
239        
240      }
241    
242      *(t-1) = '\0';
243      
244      return;
245    
246  }  }
247    
# Line 503  void printrunlist() { Line 510  void printrunlist() {
510      }      }
511    
512      printf(" %-18s = %s\n", "httpd auth. style",      printf(" %-18s = %s\n", "httpd auth. style",
513             Run.Auth.defined&&has_hosts_allow()?             (Run.credentials!=NULL)&&has_hosts_allow()?
514             "Basic Authentication and Host allow list":             "Basic Authentication and Host allow list":
515             Run.Auth.defined?"Basic Authentication":             (Run.credentials!=NULL)?"Basic Authentication":
516             has_hosts_allow()?"Host allow list":             has_hosts_allow()?"Host allow list":
517             "No authentication!");             "No authentication!");
518            
# Line 1082  char *url_encode(char *uri) { Line 1089  char *url_encode(char *uri) {
1089   */   */
1090  char *get_basic_authentication_header() {  char *get_basic_authentication_header() {
1091    
1092    if(Run.Auth.defined) {    if(Run.credentials!=NULL) {
1093    
1094      char *auth, *b64;      char *auth, *b64;
1095      char  buf[STRLEN];      char  buf[STRLEN];
1096    
1097      snprintf(buf, STRLEN, "%s:%s", Run.Auth.uname, Run.Auth.passwd);      /* We use the first credential for authorization */
1098        snprintf(buf, STRLEN, "%s:%s",
1099                 Run.credentials->uname,
1100                 Run.credentials->passwd);
1101    
1102      if(! (b64= encode_base64(strlen(buf), (unsigned char *)buf)) ) {      if(! (b64= encode_base64(strlen(buf), (unsigned char *)buf)) ) {
1103        log("Failed to base64 encode authentication header\n");        log("Failed to base64 encode authentication header\n");
# Line 1184  void fd_close() { Line 1194  void fd_close() {
1194    
1195  }  }
1196    
1197    /*
1198     * Check if monit does have credentials for this user.  If successful
1199     * a pointer to the password is returned.
1200     */
1201    char * get_user_credentials(char *uname) {
1202    
1203      Auth_T c= Run.credentials;
1204      
1205      while ( c != NULL ) {
1206    
1207        if ( strcmp(c->uname, uname) == 0 ) {
1208    
1209          return c->passwd;
1210          
1211        }
1212        
1213        c=c->next;
1214        
1215      }
1216    
1217      return NULL;
1218    }
1219    
1220    
1221  /* ----------------------------------------------------------------- Private */  /* ----------------------------------------------------------------- Private */
1222    

Legend:
Removed from v.1.97  
changed lines
  Added in v.1.98

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