1549 Commits
Author SHA1 Message Date
Joachim WibergandTobias Waldekranz 6c8d5472d5 src/confd: finalize initial DHCPv4 with optional client-id support
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-26 15:10:26 +02:00
Joachim WibergandTobias Waldekranz f2cb63df72 src/confd: initial support for DHCPv4 yang model
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-26 15:10:26 +02:00
Joachim WibergandTobias Waldekranz b319a2df9d src/confd: refactor commit done hook into a pre and post hook
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-26 15:10:26 +02:00
Joachim WibergandTobias Waldekranz ebc87eb0a0 src/confd: refactor handling of callbacks for SR_DS_CANDIDATE
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-26 15:10:26 +02:00
Tobias Waldekranz 3dbc59120f confd: srx: Duplicate entire tree in srx_get_diff
Use the _siblings variant to ensure that the full diff tree is
duplicated. Otherwise, the caller would only see the first branch of
changes.
2023-05-25 11:45:10 +02:00
Joachim Wiberg d4333e1a8d src/confd: fix ietf-interfaces copy-paste bug in netdat_init()
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-23 11:20:09 +02:00
Joachim Wiberg 8ab2f5f9da src/confd: system users, like admin, have no shell by default
Rudimentary support for setting login shell for new users.  Currently
hard-coded from what's selected in the Buildroot config, if Bash is
available or not.

Follow-up to f5866ee

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-15 18:45:37 +02:00
Joachim Wiberg 50963a7883 src/confd: fix regression in ietf-system:motd and ietf-system:clock
The writesf() API was hard coded to always open files in "r+" mode,
which fails if the file doesn't exist.

Add a mode option to writesf() and writedf().

Also, drop the default motd, we don't have one in NETCONF mode.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-15 16:05:08 +02:00
Joachim Wiberg 480d870587 src/confd: harmonize ietf-system, rename infix-system.yang augment
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-15 16:05:08 +02:00
Joachim Wiberg f5866ee3d4 Add support for admin/admin to manage Infix as group 'wheel'
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-15 12:53:32 +02:00
Tobias WaldekranzandJoachim Wiberg 304e65e298 confd: ietf-interfaces: Handle attribute deletions properly
When deleting a value, the old value is in nd.val, so use the absence
of a new value to catch deletions.
2023-05-15 12:17:10 +02:00
Tobias WaldekranzandJoachim Wiberg 9d5a1d893c confd: lyx: Return the modified-from-default value from the diff
I.e. return the answer to the question "has this attributes changed
from the last config generation?" Which is always what we want to know
anyway.
2023-05-15 12:17:10 +02:00
Tobias WaldekranzandJoachim Wiberg 7491c280ac confd: Reload finit after the exit phase, if services are disabled
Bringing down the current generation is a step of its own, so it makes
sense to let finit clear out all old services before setting up the
new ones.

For example, with avahi-autoipd, without this step, we would run the
following sequence when disabling it on an interface:

initctl disable zeroconf@iface
ip link set dev iface down
ip link set dev iface up
initctl reload

But we really want to stop the zeroconf service before the down/up
cycle on the interface, since that is likely to disrupt the
daemon. With this additional step, the sequence becomes:

initctl disable zeroconf@iface
initctl reload
ip link set dev iface down
ip link set dev iface up
initctl reload

Which means that finit won't try to restart zeroconf if it dies during
the down/up cycle, since the service is already gone at that point.
2023-05-15 12:17:10 +02:00
Joachim WibergandTobias Waldekranz 3b3cadd72d src/confd: simplify after review comments from wkz
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-12 15:58:20 +02:00
Joachim WibergandTobias Waldekranz c98a99df58 src/confd: use global hook also for core_startup_save()
Saving running to startup follows the same pattern as config update of
candidate to running, so we must employ the same hook mechanism here.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-12 15:58:20 +02:00
Joachim WibergandTobias Waldekranz 688e196347 src/confd: consistent whitespace
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-12 15:58:20 +02:00
Joachim WibergandTobias Waldekranz 36f38d6198 src/confd: global event hook support
Refactor register_change() wrapper, for sr_module_change_subscribe(),
with an additional twist of setting up a commit DONE event catcher.

This creates a global event hook that ensures we call 'initctl reload'
after all module callbacks have completed, regardless of the xpath and
without having to have "shadow" subscriptions to all new modules being
added to confd.

Based on on ideas from https://github.com/sysrepo/sysrepo/issues/2188

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-05-12 15:58:20 +02:00
Tobias WaldekranzandJoachim Wiberg 580bcf5115 confd: Support controlling IP forwarding on interfaces 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 0d09c4e16a confd: Use regular errnos internally when generation iface config
This:
1. Makes the code more familiar and easy to read
2. Let's us output more precise error messages
2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg a07910f51f confd: Simplify code with the lyx diff helpers 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg c2042bb036 confd: ietf-interfaces: Add IPv4/6 autoconf support 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 5e23b2ac79 confd: dagger: Explicitly choose order for init/exit actions
Dagger's builtin fallback to bottom-up works for init, but exit should
run top-down.
2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 580c5b06b9 confd: lyx: Add helpers to classify the modification of a node 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg cc15adb774 confd: Move from net-do to dagger for managing config generations 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 8df758dac0 confd: Add support for static IPv4/6 address configuration 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 88c845bc16 confd: Disable support for non-contiguous netmasks
Not something we need, and keeping it disabled has some nice symmetry
effects on the handling of ipv4/6 addresses.
2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 3192a69970 confd: ietf-interfaces: Initial work on net-do implementation 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg a5b4c04d08 confd: Add helper to get the diff being applied as a libyang tree 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 6e39b3dbf6 confd: Add helpers to find attributes belonging to a lyd_node
This avoids awkward XPath lookups when the structure of the lyd is
known.
2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 35ec76b0ef confd: Add helpers to read files containing a single number 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 751b22f4db confd: Avoid futile attempts to reload finit's config during boot
finit is not ready to accept the messages anyway, so we end up waiting
for the 2s timeout (2 times). Since finit won't setup a utmp entry
until it leaves runlevel S, we use that as the sync point for when
finit is ready to receive reloads.
2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 3ae4e1d9ca confd: Use printf attribute on relevant helpers
This let's the compiler catch format-specifier-to-argument mismatches.
2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 31d5dbda8c confd: Split out libyang extensions to separate file 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg a79c6ec06c confd: Remove temporary interface configuration
This will be replaced by the "net do" implementation
2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg 80d9312e36 confd: Infer type when configuring physical interfaces 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg ed41b621d9 confd: Fix -Wformat-security warning 2023-05-12 14:24:41 +02:00
Tobias WaldekranzandJoachim Wiberg f40841e5e7 confd: Consistently use srx_require_modules
This allows confd to start without errors when modules are already
loaded.
2023-05-12 14:24:41 +02:00
Richard AlpeandJoachim Wiberg def761b067 src/confd: add basic user authentication support
This patch introduces basic user authentication support via sysrepo.

Namely it adds:
* The ability to create or delete a UNIX user.
* The ability to set or delete a UNIX user password.

The password needs to be hashed and in a UNIX shadow format, such as
"$ALG$SALT$HASH". We want to avoid the handling of clear text
passwords as much as possible. In the meanwhile, passwords
can be generated in the infix shell using mkpasswd.

CLI Examples:

Add a user:
configure> set system authentication user foo

Delete a user:
configure> delete system authentication user foo

Set a user password:
configure> set system authentication user foo password ...

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-05-10 09:50:53 +02:00
Richard AlpeandJoachim Wiberg 53ad138854 sys/confd: expose systemv functions in new header
Expose systemv() and systemv_silent() to confd code that includes
core.h or systemv.h explicitly.

Signed-off-by: Richard Alpe <richard@bit42.se>
2023-05-10 09:50:53 +02:00
Joachim Wiberg 941a2d85aa src/confd: system() replacement without /bin/sh intermediary
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-30 19:49:27 +02:00
Joachim WibergandTobias Waldekranz 05d49f6cfc src/confd: set NETCONF specific motd as default
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-27 09:59:35 +02:00
Joachim WibergandTobias Waldekranz 461599e502 src/confd: hackish w/a to get 'initctl reload' for ietf-interfaces
This is very ugly, what we really want is that the commit_done_hook()
runs when *all* DONE events have been processed in all models.  The
side-effect of this hack is that the callback is run twice, both for
ietf-systm and ietf-interfaces if both are modified.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-27 09:59:35 +02:00
Joachim WibergandTobias Waldekranz 8b9504ffa5 src/confd: augment ietf-ip with an 'autoconf' setting also for IPv4
This patch adds a first Infix model to augment ietf-ip with a node,
similar to the IPv6 'autoconf' node, also for IPv4.  For IPv6 the
autoconf feature comes built-in, for IPv4 it is defined in RFC3927.

The setting behaves the same as for IPv6, but in the case of IPv4 we
enable avahi-autoipd per interface to acquire the 169.254/16 address.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-27 09:59:35 +02:00
Joachim WibergandTobias Waldekranz ae62c20d40 src/confd: minor, spellcheck
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-04-27 09:59:35 +02:00
Tobias WaldekranzandJoachim Wiberg dcf3c5fe97 confd: Infer the interface type for common patterns
When a new interface is create, but the type is not specified, try to
infer the type from the interface name.
2023-04-21 19:03:15 +02:00
Tobias WaldekranzandJoachim Wiberg 54200eaba9 confd: Add wrapper for sr_set_item
This allows the xpath to be built using format string.
2023-04-21 19:03:15 +02:00
Tobias WaldekranzandJoachim Wiberg 2259e108e4 confd: Rename srx_set_item -> lydx_new_path
Since this function wraps lyd_new_path.

This allows us to write a wrapper for sr_set_item, using the expected
name.
2023-04-21 19:03:15 +02:00
Tobias WaldekranzandJoachim Wiberg 69d6bc6942 confd: Fix some build warnings 2023-04-21 19:03:15 +02:00
Tobias WaldekranzandJoachim Wiberg 62e4a733d0 confd: Honor CFLAGS coming in from configure
This makes it easy to create unoptimized debug builds, for example.
2023-04-21 19:03:15 +02:00
Tobias WaldekranzandJoachim Wiberg 7afc650bcf confd: Fix use of uninitialized value 2023-04-21 19:03:15 +02:00