299 log_ereport(LOG_MISCONFIG, "no temporary directory specified"); |
300 log_ereport(LOG_MISCONFIG, "no temporary directory specified"); |
300 return -1; |
301 return -1; |
301 } |
302 } |
302 |
303 |
303 // mime file |
304 // mime file |
304 sstr_t mf = cfg_directivelist_get_str(obj->directives, sstr("MimeFile")); |
305 sstr_t mf = cfg_directivelist_get_str(obj->directives, sstr("MimeFile")); |
305 |
306 sstr_t base = sstr("config/"); |
306 sstr_t base = sstr("config/"); |
307 sstr_t file = sstrcat(2, base, mf); |
307 sstr_t file; |
|
308 file.length = base.length + mf.length; |
|
309 file.ptr = alloca(file.length + 1); |
|
310 file.ptr[file.length] = 0; |
|
311 file = sstrncat(file, 2, base, mf); |
|
312 |
308 |
313 ConfigFile *f = cfgmgr_get_file(file); |
309 ConfigFile *f = cfgmgr_get_file(file); |
314 if(f == NULL) { |
310 if(f == NULL) { |
315 f = malloc(sizeof(ConfigFile)); |
311 f = malloc(sizeof(ConfigFile)); |
316 f->data = NULL; |
312 f->data = NULL; |
321 // load the file content |
317 // load the file content |
322 //f->reload(f, cfg); |
318 //f->reload(f, cfg); |
323 if(cfgmgr_reload_file(f, cfg, NULL)) { |
319 if(cfgmgr_reload_file(f, cfg, NULL)) { |
324 free(f->file.ptr); |
320 free(f->file.ptr); |
325 free(f); |
321 free(f); |
|
322 |
|
323 free(file.ptr); |
326 return -1; |
324 return -1; |
327 } |
325 } |
328 cfgmgr_attach_file(f); |
326 cfgmgr_attach_file(f); |
329 } |
327 } |
330 |
328 |
331 cfg->mimetypes = f->data; |
329 cfg->mimetypes = f->data; |
332 |
330 |
|
331 free(file.ptr); |
333 return 0; |
332 return 0; |
334 } |
333 } |
335 |
334 |
336 int cfg_handle_logfile(ServerConfiguration *cfg, ServerConfigObject *obj) { |
335 int cfg_handle_logfile(ServerConfiguration *cfg, ServerConfigObject *obj) { |
337 sstr_t file = cfg_directivelist_get_str(obj->directives, sstr("File")); |
336 sstr_t file = cfg_directivelist_get_str(obj->directives, sstr("File")); |
604 obj->directives, |
603 obj->directives, |
605 sstr("ACLFile")); |
604 sstr("ACLFile")); |
606 |
605 |
607 // load the object config file |
606 // load the object config file |
608 sstr_t base = sstr("config/"); |
607 sstr_t base = sstr("config/"); |
609 sstr_t file; |
608 sstr_t file = sstrcat(2, base, objfile); |
610 file.length = base.length + objfile.length + 1; |
609 file = sstrcat(2, base, objfile); |
611 file.ptr = alloca(file.length); |
|
612 file.ptr[file.length] = 0; |
|
613 file = sstrncat(file, 2, base, objfile); |
|
614 |
610 |
615 // the file is managed by the configuration manager |
611 // the file is managed by the configuration manager |
616 ConfigFile *f = cfgmgr_get_file(file); |
612 ConfigFile *f = cfgmgr_get_file(file); |
617 if(f == NULL) { |
613 if(f == NULL) { |
618 f = malloc(sizeof(ConfigFile)); |
614 f = malloc(sizeof(ConfigFile)); |
622 f->last_modified = 0; |
618 f->last_modified = 0; |
623 //f->reload(f, cfg); |
619 //f->reload(f, cfg); |
624 if(cfgmgr_reload_file(f, cfg, NULL)) { |
620 if(cfgmgr_reload_file(f, cfg, NULL)) { |
625 free(f->file.ptr); |
621 free(f->file.ptr); |
626 free(f); |
622 free(f); |
|
623 |
|
624 free(file.ptr); |
627 return -1; |
625 return -1; |
628 } |
626 } |
629 cfgmgr_attach_file(f); |
627 cfgmgr_attach_file(f); |
630 } |
628 } |
631 vs->objectfile = sstrdup(file); |
629 vs->objectfile = sstrdup(file); |
632 vs->objects = (HTTPObjectConfig*)f->data; |
630 vs->objects = (HTTPObjectConfig*)f->data; |
|
631 free(file.ptr); |
|
632 |
633 |
633 |
634 // load acl config file |
634 // load acl config file |
635 file.length = base.length + aclfile.length + 1; |
635 file = sstrcat(2, base, aclfile); |
636 file.ptr = alloca(file.length); |
|
637 file.ptr[file.length] = 0; |
|
638 file = sstrncat(file, 2, base, aclfile); |
|
639 |
636 |
640 ConfigFile *aclf = cfgmgr_get_file(file); |
637 ConfigFile *aclf = cfgmgr_get_file(file); |
641 if(aclf == NULL) { |
638 if(aclf == NULL) { |
642 aclf = malloc(sizeof(ConfigFile)); |
639 aclf = malloc(sizeof(ConfigFile)); |
643 aclf->data = NULL; |
640 aclf->data = NULL; |
646 aclf->last_modified = 0; |
643 aclf->last_modified = 0; |
647 //aclf->reload(aclf, cfg); |
644 //aclf->reload(aclf, cfg); |
648 if(cfgmgr_reload_file(aclf, cfg, NULL)) { |
645 if(cfgmgr_reload_file(aclf, cfg, NULL)) { |
649 free(aclf->file.ptr); |
646 free(aclf->file.ptr); |
650 free(aclf); |
647 free(aclf); |
|
648 |
|
649 free(file.ptr); |
651 return -1; |
650 return -1; |
652 } |
651 } |
653 cfgmgr_attach_file(aclf); |
652 cfgmgr_attach_file(aclf); |
654 } |
653 } |
655 vs->acls = aclf->data; |
654 vs->acls = aclf->data; |
|
655 free(file.ptr); |
656 |
656 |
657 // set the access log for the virtual server |
657 // set the access log for the virtual server |
658 // TODO: don't use always the default |
658 // TODO: don't use always the default |
659 vs->log = cfg->default_log; |
659 vs->log = cfg->default_log; |
660 |
660 |