lifecycle: expose INTERFACES_FILE env var to executors

This commit is contained in:
Ariadne Conill 2020-07-26 02:50:01 -06:00
parent 0669e897fd
commit 9e4e17707f
4 changed files with 8 additions and 4 deletions

View file

@ -30,6 +30,7 @@ struct match_options {
static bool up; static bool up;
static struct lif_execute_opts exec_opts = { static struct lif_execute_opts exec_opts = {
.executor_path = EXECUTOR_PATH, .executor_path = EXECUTOR_PATH,
.interfaces_file = INTERFACES_FILE,
}; };
void void
@ -129,7 +130,6 @@ ifupdown_main(int argc, char *argv[])
{NULL, 0, 0, 0} {NULL, 0, 0, 0}
}; };
struct match_options match_opts = {}; struct match_options match_opts = {};
char *interfaces_file = INTERFACES_FILE;
char *state_file = STATE_FILE; char *state_file = STATE_FILE;
for (;;) for (;;)
@ -146,7 +146,7 @@ ifupdown_main(int argc, char *argv[])
lif_common_version(); lif_common_version();
break; break;
case 'i': case 'i':
interfaces_file = optarg; exec_opts.interfaces_file = optarg;
break; break;
case 'a': case 'a':
match_opts.is_auto = true; match_opts.is_auto = true;
@ -179,9 +179,9 @@ ifupdown_main(int argc, char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (!lif_interface_file_parse(&collection, interfaces_file)) if (!lif_interface_file_parse(&collection, exec_opts.interfaces_file))
{ {
fprintf(stderr, "%s: could not parse %s\n", argv0, interfaces_file); fprintf(stderr, "%s: could not parse %s\n", argv0, exec_opts.interfaces_file);
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View file

@ -23,6 +23,7 @@ struct lif_execute_opts {
bool verbose; bool verbose;
bool mock; bool mock;
const char *executor_path; const char *executor_path;
const char *interfaces_file;
}; };
extern bool lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const char *fmt, ...); extern bool lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const char *fmt, ...);

View file

@ -233,6 +233,9 @@ lif_lifecycle_run_phase(const struct lif_execute_opts *opts, struct lif_interfac
if (opts->verbose) if (opts->verbose)
lif_environment_push(&envp, "VERBOSE", "1"); lif_environment_push(&envp, "VERBOSE", "1");
if (opts->interfaces_file)
lif_environment_push(&envp, "INTERFACES_FILE", opts->interfaces_file);
struct lif_node *iter; struct lif_node *iter;
bool did_address = false, did_gateway = false; bool did_address = false, did_gateway = false;

0
tests/executors/static Normal file → Executable file
View file