Skip to content

Commit c2344f0

Browse files
minfrinflowerysong
authored andcommitted
Domain/Selector/KeyFile no longer mandatory in verifying mode
Limit checks for Domain/Selector/KeyFile to signing mode only. trusteddomainproject/OpenARC#159
1 parent 31afd2e commit c2344f0

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

openarc/openarc-config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ struct configdef arcf_config[] =
2929
{ "BaseDirectory", CONFIG_TYPE_STRING, FALSE },
3030
{ "Canonicalization", CONFIG_TYPE_STRING, FALSE },
3131
{ "ChangeRootDirectory", CONFIG_TYPE_STRING, FALSE },
32-
{ "Domain", CONFIG_TYPE_STRING, TRUE },
32+
{ "Domain", CONFIG_TYPE_STRING, FALSE },
3333
{ "EnableCoredumps", CONFIG_TYPE_BOOLEAN, FALSE },
3434
{ "FinalReceiver", CONFIG_TYPE_BOOLEAN, FALSE },
3535
{ "FixedTimestamp", CONFIG_TYPE_STRING, FALSE },
3636
{ "Include", CONFIG_TYPE_INCLUDE, FALSE },
3737
{ "InternalHosts", CONFIG_TYPE_STRING, FALSE },
3838
{ "KeepTemporaryFiles", CONFIG_TYPE_BOOLEAN, FALSE },
39-
{ "KeyFile", CONFIG_TYPE_STRING, TRUE },
39+
{ "KeyFile", CONFIG_TYPE_STRING, FALSE },
4040
{ "MaximumHeaders", CONFIG_TYPE_INTEGER, FALSE },
4141
{ "MilterDebug", CONFIG_TYPE_INTEGER, FALSE },
4242
{ "Mode", CONFIG_TYPE_STRING, FALSE },
4343
{ "PeerList", CONFIG_TYPE_STRING, FALSE },
4444
{ "PidFile", CONFIG_TYPE_STRING, FALSE },
45-
{ "Selector", CONFIG_TYPE_STRING, TRUE },
45+
{ "Selector", CONFIG_TYPE_STRING, FALSE },
4646
{ "SignatureAlgorithm", CONFIG_TYPE_STRING, FALSE },
4747
{ "SignHeaders", CONFIG_TYPE_STRING, FALSE },
4848
{ "OverSignHeaders", CONFIG_TYPE_STRING, FALSE },

openarc/openarc.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,17 +1469,32 @@ arcf_config_load(struct config *data, struct arcf_config *conf,
14691469
conf->conf_signalg = ARC_SIGN_RSASHA256;
14701470
}
14711471

1472-
(void) config_get(data, "Domain",
1473-
&conf->conf_domain,
1474-
sizeof conf->conf_domain);
1472+
if ((conf->conf_mode & ARC_MODE_SIGN))
1473+
{
1474+
if (config_get(data, "Domain",
1475+
&conf->conf_domain,
1476+
sizeof conf->conf_domain) < 1)
1477+
{
1478+
strlcpy(err, "parameter \"Domain\" required when signing", errlen);
1479+
return -1;
1480+
}
14751481

1476-
(void) config_get(data, "Selector",
1477-
&conf->conf_selector,
1478-
sizeof conf->conf_selector);
1482+
if (config_get(data, "Selector",
1483+
&conf->conf_selector,
1484+
sizeof conf->conf_selector) < 1)
1485+
{
1486+
strlcpy(err, "parameter \"Selector\" required when signing", errlen);
1487+
return -1;
1488+
}
14791489

1480-
(void) config_get(data, "KeyFile",
1481-
&conf->conf_keyfile,
1482-
sizeof conf->conf_keyfile);
1490+
if (config_get(data, "KeyFile",
1491+
&conf->conf_keyfile,
1492+
sizeof conf->conf_keyfile) < 1)
1493+
{
1494+
strlcpy(err, "parameter \"KeyFile\" required when signing", errlen);
1495+
return -1;
1496+
}
1497+
}
14831498

14841499
(void) config_get(data, "EnableCoredumps",
14851500
&conf->conf_enablecores,
@@ -4445,13 +4460,6 @@ main(int argc, char **argv)
44454460
return EX_CONFIG;
44464461
}
44474462

4448-
if (curconf->conf_selector == NULL || curconf->conf_domain == FALSE)
4449-
{
4450-
fprintf(stderr, "%s: selector and domain must be specified\n",
4451-
progname);
4452-
return EX_CONFIG;
4453-
}
4454-
44554463
/* suppress a bunch of things if we're in test mode */
44564464
if (testmode)
44574465
{

0 commit comments

Comments
 (0)