complain about global options following sections

while harmless for most options, such usage is counter to the
documentation, and actually breaks CopyArrivalDate, MaxMessages, and
ExpireUnread.
This commit is contained in:
Oswald Buddenhagen 2020-10-05 12:35:59 +02:00
parent ee39e684aa
commit 217764bd35

View File

@ -326,7 +326,7 @@ load_config( const char *where )
string_list_t *chanlist, **chanlistapp; string_list_t *chanlist, **chanlistapp;
char *arg, *p; char *arg, *p;
uint len, max_size; uint len, max_size;
int cops, gcops, fn, i; int cops, gcops, glob_ok, fn, i;
char path[_POSIX_PATH_MAX]; char path[_POSIX_PATH_MAX];
char buf[1024]; char buf[1024];
@ -351,6 +351,7 @@ load_config( const char *where )
cfile.rest = NULL; cfile.rest = NULL;
gcops = 0; gcops = 0;
glob_ok = 1;
global_conf.expire_unread = -1; global_conf.expire_unread = -1;
reloop: reloop:
while (getcline( &cfile )) { while (getcline( &cfile )) {
@ -367,6 +368,7 @@ load_config( const char *where )
storeapp = &store->next; storeapp = &store->next;
*storeapp = NULL; *storeapp = NULL;
} }
glob_ok = 0;
goto reloop; goto reloop;
} }
if (!strcasecmp( "Channel", cfile.cmd )) if (!strcasecmp( "Channel", cfile.cmd ))
@ -444,6 +446,8 @@ load_config( const char *where )
*channelapp = channel; *channelapp = channel;
channelapp = &channel->next; channelapp = &channel->next;
} }
glob_ok = 0;
goto reloop;
} }
else if (!strcasecmp( "Group", cfile.cmd )) else if (!strcasecmp( "Group", cfile.cmd ))
{ {
@ -477,6 +481,8 @@ load_config( const char *where )
cfile.err = 1; cfile.err = 1;
} }
} }
glob_ok = 0;
goto reloop;
} }
else if (!strcasecmp( "FSync", cfile.cmd )) else if (!strcasecmp( "FSync", cfile.cmd ))
{ {
@ -513,6 +519,11 @@ load_config( const char *where )
goto reloop; goto reloop;
break; break;
} }
if (!glob_ok) {
error( "%s:%d: global options may not follow sections\n",
cfile.file, cfile.line );
cfile.err = 1;
}
} }
fclose (cfile.fp); fclose (cfile.fp);
if (cfile.ms_warn) if (cfile.ms_warn)