libifupdown: add interface being run for each executor

This commit is contained in:
Ariadne Conill 2020-09-09 15:50:16 -06:00
parent bdc66bcba9
commit 5a0b53cd73
3 changed files with 11 additions and 11 deletions

View file

@ -140,10 +140,10 @@ lif_file_is_executable(const char *path)
}
bool
lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[], const char *executor, const char *phase)
lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[], const char *executor, const char *phase, const char *lifname)
{
if (opts->verbose)
fprintf(stderr, "ifupdown: attempting to run %s executor for phase %s\n", executor, phase);
fprintf(stderr, "ifupdown: %s: attempting to run %s executor for phase %s\n", lifname, executor, phase);
char pathbuf[4096];
@ -156,10 +156,10 @@ lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[],
}
bool
lif_maybe_run_executor_with_result(const struct lif_execute_opts *opts, char *const envp[], const char *executor, char *buf, size_t bufsize, const char *phase)
lif_maybe_run_executor_with_result(const struct lif_execute_opts *opts, char *const envp[], const char *executor, char *buf, size_t bufsize, const char *phase, const char *lifname)
{
if (opts->verbose)
fprintf(stderr, "ifupdown: attempting to run %s executor for phase %s\n", executor, phase);
fprintf(stderr, "ifupdown: %s: attempting to run %s executor for phase %s\n", lifname, executor, phase);
char pathbuf[4096];

View file

@ -32,7 +32,7 @@ struct lif_execute_opts {
extern bool lif_execute_fmt(const struct lif_execute_opts *opts, char *const envp[], const char *fmt, ...);
extern bool lif_execute_fmt_with_result(const struct lif_execute_opts *opts, char *buf, size_t bufsize, char *const envp[], const char *fmt, ...);
extern bool lif_file_is_executable(const char *path);
extern bool lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[], const char *executor, const char *phase);
extern bool lif_maybe_run_executor_with_result(const struct lif_execute_opts *opts, char *const envp[], const char *executor, char *buf, size_t bufsize, const char *phase);
extern bool lif_maybe_run_executor(const struct lif_execute_opts *opts, char *const envp[], const char *executor, const char *phase, const char *lifname);
extern bool lif_maybe_run_executor_with_result(const struct lif_execute_opts *opts, char *const envp[], const char *executor, char *buf, size_t bufsize, const char *phase, const char *lifname);
#endif

View file

@ -47,13 +47,13 @@ handle_commands_for_phase(const struct lif_execute_opts *opts, char *const envp[
}
static inline bool
handle_single_executor_for_phase(const struct lif_dict_entry *entry, const struct lif_execute_opts *opts, char *const envp[], const char *phase)
handle_single_executor_for_phase(const struct lif_dict_entry *entry, const struct lif_execute_opts *opts, char *const envp[], const char *phase, const char *lifname)
{
if (strcmp(entry->key, "use"))
return true;
const char *cmd = entry->data;
if (!lif_maybe_run_executor(opts, envp, cmd, phase))
if (!lif_maybe_run_executor(opts, envp, cmd, phase, lifname))
return false;
return true;
@ -67,12 +67,12 @@ handle_executors_for_phase(const struct lif_execute_opts *opts, char *const envp
if (up)
{
LIF_DICT_FOREACH(iter, &iface->vars)
handle_single_executor_for_phase(iter->data, opts, envp, phase);
handle_single_executor_for_phase(iter->data, opts, envp, phase, iface->ifname);
}
else
{
LIF_DICT_FOREACH_REVERSE(iter, &iface->vars)
handle_single_executor_for_phase(iter->data, opts, envp, phase);
handle_single_executor_for_phase(iter->data, opts, envp, phase, iface->ifname);
}
return true;
@ -97,7 +97,7 @@ query_dependents_from_executors(const struct lif_execute_opts *opts, char *const
continue;
const char *cmd = entry->data;
if (!lif_maybe_run_executor_with_result(&exec_opts, envp, cmd, resbuf, sizeof resbuf, phase))
if (!lif_maybe_run_executor_with_result(&exec_opts, envp, cmd, resbuf, sizeof resbuf, phase, iface->ifname))
return false;
if (!*resbuf)