Skip to content

Commit

Permalink
tools/mkimap: report clearly missing 'configdirectory:' in imapd.conf
Browse files Browse the repository at this point in the history
config_read_file() contains:

  if (*p != ':') {
      snprintf(errbuf, sizeof(errbuf),
              "invalid option name on line %d of configuration file %s",
              lineno, filename);
      fatal(errbuf, EX_CONFIG);
  }
  *p++ = '\0';

  /* remove leading whitespace */
  while (*p && Uisspace(*p)) p++;

so it accepts zero spaces after the colon.  Extend mkimap to accept zero
spaces after the colon in imapd.conf and to terminate fast when imapd.conf
contains no 'configdirectory:' or does not define partition.
  • Loading branch information
dilyanpalauzov committed Oct 22, 2020
1 parent 066d725 commit 0ea353d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tools/mkimap
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,19 @@ sub read_conf {
if (/^#/) {
next;
}
if (/\@include:\s+(.*)$/) {
print "i will include configure file $1.\n";
if (/\@include:\s*(.*)$/) {
print "I will include configure file $1.\n";
push @configs, $1;
}
if (/^configdirectory:\s+(.*)$/) {
if (/^configdirectory:\s*(.*)$/) {
$confdir = $1;
print "i will configure directory $confdir.\n";
print "I will configure directory $confdir.\n";
}
if (/^(?:meta)?partition-.*:\s+(.*)$/) {
if (/^(?:meta)?partition-.*:\s*(.*)$/) {
if (grep /$1/, @parts) {
next;
}
print "i saw partition $1.\n";
print "I saw partition $1.\n";
push @parts, $1;
}
}
Expand All @@ -81,6 +81,8 @@ while ($conf = shift @configs) {
read_conf($conf);
}

defined $confdir or die "'configdirectory:' in $imapdconf is missing";
@parts or die "No partition defined in $imapdconf";
$d = $confdir;

print "configuring $d...\n";
Expand Down

0 comments on commit 0ea353d

Please sign in to comment.