don't load the built-in list when using `types'

This commit is contained in:
Omar Polo 2022-04-08 13:52:35 +00:00
parent 9b64995359
commit 54203115cd
3 changed files with 13 additions and 4 deletions

2
gmid.c
View File

@ -251,7 +251,7 @@ static int
listener_main(struct imsgbuf *ibuf) listener_main(struct imsgbuf *ibuf)
{ {
drop_priv(); drop_priv();
if (load_default_mime(&conf.mime) == -1) if (!conf.mime.skip_defaults && load_default_mime(&conf.mime) == -1)
fatal("load_default_mime: %s", strerror(errno)); fatal("load_default_mime: %s", strerror(errno));
load_vhosts(); load_vhosts();
loop(ctx, sock4, sock6, ibuf); loop(ctx, sock4, sock6, ibuf);

11
gmid.h
View File

@ -182,8 +182,15 @@ struct etm { /* extension to mime */
struct mime { struct mime {
struct etm *t; struct etm *t;
size_t len; size_t len;
size_t cap; size_t cap;
/*
* Backward compatibility: types override the built-in list,
* but the deprecated `mime' and `map' don't. It's still too
* early to remove `mime' and `map' from the config parser.
*/
int skip_defaults;
}; };
struct conf { struct conf {

View File

@ -475,7 +475,9 @@ fastcgi : SPAWN string {
} }
; ;
types : TYPES '{' optnl mediaopts_l '}' types : TYPES '{' optnl mediaopts_l '}' {
conf.mime.skip_defaults = 1;
}
; ;
mediaopts_l : mediaopts_l mediaoptsl nl mediaopts_l : mediaopts_l mediaoptsl nl