1549 Commits
Author SHA1 Message Date
Joachim Wiberg aec2514eae mech: add support for ietf-syste:system/dns-resolver
This commit adds multi-nameserver support using openresolv (resolvconf)
and dnsmasq.  This means that a DHCP client (dhcpcd) or VPN client can
be providers of nameservers to the system.  Dnsmasq takes over as the
system resolver, except when the user has set up static configuration.

Static nameserver(s), as well as search and options, are always added
first by openresolv to /etc/resolv.conf.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-27 14:05:03 +02:00
Joachim Wiberg a5258d7102 mech: wrap system() as run(), returning WEXITSTATUS() or -1 on error
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-27 14:03:03 +02:00
Joachim Wiberg 4acaa170e4 mech: add support for ietf-system:set-current-datetime rpc
Also adds:
 - namespace validation
 - proper rpc operation lookup

Fixes:
 - ietf-system:system-shutdown (broken due do invalid op)

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-24 01:50:36 +01:00
Joachim Wiberg 688c0ce2f7 mech: add support for ietf-system state data
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-24 01:50:36 +01:00
Joachim Wiberg b25a374409 mech: drop unused code
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-23 18:40:18 +01:00
Joachim Wiberg 89d08338ce mech: initial support for ietf-interfaces state data
First example of how to implement supoort for ro/state-data.
Only oper-status and phys-address per interface currently.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-23 13:25:23 +01:00
Joachim Wiberg 2abb0a5eb9 mech: add support for setting interface description as ifalias
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-23 13:24:26 +01:00
Joachim Wiberg 4730f3fe09 mech: clean up developer logs in ietf-interfaces
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-23 13:23:54 +01:00
Joachim Wiberg cbc0374251 mech: add support for ietf-system:system-restart and system-shutdown
Shutdown depends on how the kernel is configured, on most embedded
systems this just means reboot.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 19:32:24 +01:00
Joachim Wiberg 2124f27d2c mech: initial support for ietf-interfaces and ietf-ip
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 17:40:39 +01:00
Tobias Waldekranz c74203720a mech: Compress empty yang containers in CLI
E.g. instead of: `set interfaces interface eth0`

We can now say: `set interface eth0`
2023-03-16 16:13:09 +01:00
Joachim Wiberg 74cf105512 mech: fix disabling chronyd when system ntp client is disabled
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 15:55:13 +01:00
Joachim Wiberg 0da4578362 board/common: allow lldpd to run by default in NETCONF mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 15:55:13 +01:00
Tobias Waldekranz 3c6c2ec66d mech: Import ietf-{interface,ip} models 2023-03-16 15:48:38 +01:00
Joachim Wiberg 4e46b60b6f mech: deviation /sys:system/clock/timezone-utc-offset not-supported
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 08:26:21 +01:00
Joachim Wiberg 0185efeb3f mech: add support for setting timezone, e.g. Europe/Stockholm
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 08:00:40 +01:00
Joachim Wiberg 4ca2e2d8c4 mech: initial support for ietf-system ntp using chrony
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 07:26:40 +01:00
Joachim Wiberg fa45015140 mech: debug transactions
For observability. All transactions that reach ietf-system are logged
with LOG_DEBUG log level.  See /var/log/debug for details.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 06:37:56 +01:00
Joachim Wiberg d130011f96 mech: common convenience library, currently only XML debug fns
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-16 06:37:56 +01:00
Joachim Wiberg 90b4a739b5 mech: always run initctl in batch mode when in non-interactive mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-14 20:31:50 +01:00
Joachim Wiberg 7a4fe98a3e mech: remember hard-coded strings
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-14 09:06:22 +01:00
Joachim Wiberg f43b31b1f5 mech: system headers before clixon, skip sys/ prefix
The canonical location for syslog.h is in the root.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-14 09:06:22 +01:00
Joachim Wiberg 1aac798041 mech: must specify model revision
Found when debugging output from "show state", which displayed NULL for
the infix model.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-14 09:06:22 +01:00
Joachim Wiberg 77f6d5e82e mech: use same pager as Clixon by default
Add configurable pager support to Clixon later.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-14 09:06:22 +01:00
Joachim Wiberg cc5453bfbd mech: use new 'show -n' to skip shell user's help notice
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-14 09:06:22 +01:00
Joachim Wiberg 6a591ddd5a mech: use NOTICE file and spdx format for Apache 2.0 license
Recommendations on how to apply the Apache 2.0 license to a project from
https://www.linkedin.com/pulse/how-apply-apache-20-license-your-open-source-software-vladimír-gorej/

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-14 09:06:22 +01:00
Joachim Wiberg d8d761bfa4 mech: change license to Apache v2.0, same as Clixon package
To facilitate linking and circumvent any possible legal problems.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
2023-03-14 09:06:22 +01:00
Joachim Wiberg 2f7dbe110a src/mech: add some basic 'show' commands
- Example of optional args (show log [FILE])
 - Example of dynamic expansion
 - Example of how to re-enable signals for external commands
 - Example of hidden commands
 - Add basic 'help' command for the current level

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-14 09:06:22 +01:00
Joachim Wiberg 597207b7dd profeth: drop copy of p-net headers, use library headers instead
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-09 06:58:46 +01:00
Joachim Wiberg 0f38ac54f8 src/profeth: add submodules for all ports, matching the GSD file
These changes allow profeth to pass the Automatic RT Tester's first
behavior tests: Scenario 1-9.

 - Explorative changes to the GSD file to appease the conformance tool
 - Fix mismatch in installed submodules vs advertised ports in GSD file

Note: changes in GSD file only match the amd64 virtual build.  Must be
      updated for the final product.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-09 05:58:09 +01:00
Joachim Wiberg f41846fab4 src/profeth: use RT-Labs VendorID and DeviceID for now
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-06 15:08:20 +01:00
Joachim Wiberg 6c7d945e8b profeth: use /var/run/agentx/master socket instead of default
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-06 10:50:58 +01:00
Joachim Wiberg bb62d58b17 profeth: branding
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-06 10:50:58 +01:00
Joachim Wiberg c0c087e719 src/profeth: fix system IP address/netmask and gateway query
Replace the old p-net API for querying the interface address, netmask
and gateway with the new ones that use getifaddrs() and inspect the
kernel routing table.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-06 10:50:58 +01:00
Joachim Wiberg e3adc8a6e4 src/profeth: add GPLv3 license and basic README
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-06 10:50:58 +01:00
Joachim Wiberg 221cc0b1f6 mech: move Finit service .conf to package and add conditions
The new if: conditions require latest Finit master, unreleased v4.4

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-03-06 10:50:58 +01:00
Tobias WaldekranzandJoachim Wiberg 5a441252f8 profeth: Initial add 2023-03-06 10:50:58 +01:00
Joachim Wiberg 605bd7262b src/factory: use new /mnt/cfg/infix/.reset path
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-02-21 20:02:34 +01:00
Joachim Wiberg 14dea1c6e1 src/mech: allow backend to start restconf in fcgi mode
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-02-15 19:15:22 +01:00
Joachim Wiberg 0162c2382a src/mech: sock and pid files should go in /run
This introduces a dependency on /run/clixon to exist when starting up.
Requires a patch to Finit panding the upcoming tempfiles.so plugin.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-02-15 19:13:08 +01:00
Tobias Waldekranz 00c93cd70c mech: Initial ietf-system support
Only hostname is supported for now.
2023-02-10 16:11:34 +01:00
Tobias Waldekranz 3d35194341 mech: Add infrastructure for backend plugins using Augeas 2023-02-10 16:11:34 +01:00
Tobias Waldekranz 3235f00cd1 mech: Import basic autocli support from clixon's main example
This allows use the autogenerated CLI to modify the database.
2023-02-10 16:11:34 +01:00
Tobias Waldekranz e56348a916 mech: Make startup_db persistent, prepare for factory configs
Keep the transient files in the system's /mnt/tmp, and only persist
startup_db in /cfg.

This design (with a symlink) means that /cfg/startup_db _must_ exist
in order for clixon to start properly. Therefore run
/lib/infix/prep-db to take care of this.

At the moment, this just creates an empty factory config, and copies
it to startup if it doesn't exist. In the future, prep-db could select
a factory config based on some hardware identifier, or even build one
dynamically, based on available ports etc.
2023-02-10 15:51:47 +01:00
Tobias Waldekranz 5a27b30c7c mech: Startup clixon at boot 2023-02-09 10:26:10 +01:00
Joachim Wiberg 7bfb0a9478 Follow-up to 252feef: rename Orc to Mech everywhere
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-02-08 15:12:57 +01:00
Joachim Wiberg f75842ab8b src/mech: update socket group s/clixon/clicon/
Recommended group according to Clixon FAQ

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-02-08 14:55:03 +01:00
Tobias Waldekranz 252feef1c4 mech: Initial add
The mechanic, Infix's integration layer to Clixon
2023-02-08 14:05:47 +01:00
Joachim Wiberg bc21f93ec2 Add support for returning a device to factory defaults
This change adds a `factory` tool, and login shell, that schedules a
reset of all writable (overlay) filesystems.  The tool is set up with
the suid gid flag to allow all members of the wheel group to perform
the reset.

The login method only allows reset from /dev/console, to prevent any
malicious reset over SSH.  This should be further constrained later
when PAM is introduced.

To initiate factory reset from the login prompt, use login/pass:

    factory/reset

To initiate factory reset from the shell, call

    factory

Both methods are interactive by default, but two command line options
can be used to modify the behavior:

  -r  Skip reboot, and "reboot now?" question
  -y  Assume yes to all questions, for non-interactive use

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2023-01-04 15:24:36 +01:00