Commit Graph

6 Commits

Author SHA1 Message Date
Thomas Haller
2800232bbf dispatcher: add NM_DISPATCHER_ACTION environment variable
Previously, the action was only passed as the first command line
argument to the dispatcher scripts. Now, also set it via the
"$NM_DISPATCHER_ACTION" environment variable.

The main purpose is to have a particular, nm-dispatcher specific
variable that is always set inside the dispatcher scripts.
For example, imagine you have a script that can be either called by
dispatcher or some other means (manually, or spawned via
/etc/NetworkManager/dispatcher.d/11-dhclient).  Then it might make
sense to differenciate from inside the script whether you are called
by nm-dispatcher. But previously, there was no specific environment
variable that was always set inside the dispatcher event. For example,
with the "hostname" action there are no other environment variables.

Now (with version 1.12), you can check for `test -n "$NM_DISPATCHER_ACTION"`.

(cherry picked from commit ce9619047c)
2018-06-18 14:19:16 +02:00
Thomas Haller
591cc60a5b dispatcher: rework creating dispatcher environment
- don't use GSList as intermediate data type to construct
  the environment, especially when all we want is to get
  a strv array at the end. This reverts the order of elements
  compared to previously.

- add and use helper methods _items_add_*() which assert against sensible
  input.

- merge IPv4 and IPv6 implementations for creating the environment.

https://github.com/NetworkManager/NetworkManager/pull/112
2018-05-24 13:07:15 +02:00
Thomas Haller
641c111277 dispatcher: fix leak in construct_device_dhcp4_items()
Fixes: c86d0b4722
2018-05-16 18:13:17 +02:00
Thomas Haller
c86d0b4722 dispatcher: extra sanitize names of environment variables
The DHCP options should already be sanitized. Still, make sure we don't
create a bogus environment.
2018-05-16 08:46:52 +02:00
Beniamino Galvani
1b5925ce88 all: remove consecutive empty lines
Normalize coding style by removing consecutive empty lines from C
sources and headers.

https://github.com/NetworkManager/NetworkManager/pull/108
2018-04-30 16:24:52 +02:00
Thomas Haller
f42466215a callouts/dispatcher: rename directory callouts
Originally, the "callouts" directory contained various programs
that NetworkManager would call, for example the dhcp helper.

For a while, it only contains nm-dispatcher. Thus rename the directory
to indicate that it's for dispatcher.
2016-10-13 21:33:33 +02:00