}
/* Process the options. */
- while ((c = getopt(argc, argv, "Cd:D:e:fhi:l:Mmn:p:PrstTvxX")) != -1) switch (c) {
+ while ((c = getopt(argc, argv, "Cd:D:e:fhi:l:Mmn:p:PrsS:tTvxX")) != -1) switch (c) {
case 'C':
check_config = true;
config->spawn_workers = false;
config->daemonize = false;
break;
+ case 'S': /* Migration support */
+ if (main_config_parse_option(optarg) < 0) {
+ fprintf(stderr, "%s: Unknown configuration option '%s'\n",
+ config->name, optarg);
+ EXIT_WITH_FAILURE;
+ }
+ break;
+
case 't': /* no child threads */
config->spawn_workers = false;
break;
default_log.print_level = true;
/* Process the options. */
- while ((c = getopt(argc, argv, "c:d:D:f:hi:mMn:o:O:p:r:xXz")) != -1) {
+ while ((c = getopt(argc, argv, "c:d:D:f:hi:mMn:o:O:p:r:S:xXz")) != -1) {
switch (c) {
case 'c':
count = atoi(optarg);
receipt_file = optarg;
break;
+ case 'S': /* Migration support */
+ if (main_config_parse_option(optarg) < 0) {
+ fprintf(stderr, "%s: Unknown configuration option '%s'\n",
+ config->name, optarg);
+ fr_exit_now(EXIT_FAILURE);
+ }
+ break;
+
case 'X':
fr_debug_lvl += 2;
default_log.print_level = true;
CONF_PARSER_TERMINATOR
};
+/*
+ * Migration configuration.
+ */
static const CONF_PARSER migrate_config[] = {
{ FR_CONF_OFFSET("unflatten_after_decode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, unflatten_after_decode) },
{ FR_CONF_OFFSET("unflatten_before_encode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, unflatten_before_encode) },
INFO("HUP - NYI in version 4"); /* Not yet implemented in v4 */
}
+
+static fr_table_num_ordered_t config_arg_table[] = {
+ { L("parse_new_conditions"), offsetof(main_config_t, parse_new_conditions) },
+ { L("use_new_conditions"), offsetof(main_config_t, use_new_conditions) },
+ { L("tmpl_tokenize_all_nested"), offsetof(main_config_t, tmpl_tokenize_all_nested) },
+};
+static size_t config_arg_table_len = NUM_ELEMENTS(config_arg_table);
+
+/*
+ * Migration function that allows for command-line over-ride of
+ * data structures which need to be initialized before the
+ * configuration files are loaded.
+ *
+ * This should really only be temporary, until we get rid of flat vs nested.
+ */
+int main_config_parse_option(char const *value)
+{
+ fr_value_box_t box;
+ size_t offset;
+ char const *p;
+
+ p = strchr(value, '=');
+ if (!p) return -1;
+
+ offset = fr_table_value_by_substr(config_arg_table, value, p - value, 0);
+ if (!offset) return -1;
+
+ p += 1;
+
+ fr_value_box_init(&box, FR_TYPE_BOOL, NULL, false);
+ if (fr_value_box_from_str(NULL, &box, FR_TYPE_BOOL, NULL,
+ p, strlen(p), NULL, false) < 0) {
+ fr_perror("Invalid boolean \"%s\"", p);
+ fr_exit(1);
+ }
+
+ *(bool *) (((uintptr_t) main_config) + offset) = box.vb_bool;
+
+ return 0;
+}
void main_config_raddb_dir_set(main_config_t *config, char const *path);
void main_config_dict_dir_set(main_config_t *config, char const *path);
+int main_config_parse_option(char const *value); /* flat / nested migration */
+
void main_config_exclusive_proc_done(main_config_t const *config);
int main_config_exclusive_proc_child(main_config_t const *config);
int main_config_exclusive_proc(main_config_t *config);