diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index c1012e80..cca12dfa 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -4,7 +4,7 @@ Change Log All notable changes to the project are documented in this file. -[v25.02.0][UNRELASED] - +[v25.02.0][] - 2025-03-03 ------------------------- ### Changes @@ -18,8 +18,11 @@ All notable changes to the project are documented in this file. setting. Note, route advertisements are always accepted. Issue #785 - Drop automatic default route (interface route) for IPv4 autoconf, not necessary and causes more confusion than good. Issue #923 + - Update scripting with new RESTCONF examples ### Fixes + - Fix #896: `/etc/resolv.conf` not properly generated when system runs + in fail secure mode (failing to load `startup-config`) - Fix #902: containers "linger" in the system (state 'exited') after having removed them from the configuration - Fix #930: container configuration changes does not apply at runtime diff --git a/doc/scripting.md b/doc/scripting.md index a2258bc3..f7da8e9e 100644 --- a/doc/scripting.md +++ b/doc/scripting.md @@ -853,14 +853,18 @@ models for details. ### Factory Reset ``` -~$ curl -kX POST -H "Content-Type: application/yang-data+json" https://example.local/restconf/operations/ietf-factory-default:factory-reset -u admin:admin +~$ curl -kX POST -u admin:admin \ + -H "Content-Type: application/yang-data+json" \ + https://example.local/restconf/operations/ietf-factory-default:factory-reset curl: (56) OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while reading, errno 0 ``` ### System Reboot ``` -~$ curl -kX POST -H "Content-Type: application/yang-data+json" https://example.local/restconf/operations/ietf-system:system-restart -u admin:admin +~$ curl -kX POST -u admin:admin \ + -H "Content-Type: application/yang-data+json" \ + https://example.local/restconf/operations/ietf-system:system-restart ``` ### Set Date and Time @@ -868,7 +872,11 @@ curl: (56) OpenSSL SSL_read: error:0A000126:SSL routines::unexpected eof while r Here's an example of an RPC that takes input/argument: ``` -~$ curl -kX POST -H "Content-Type: application/yang-data+json" https://example.local/restconf/operations/ietf-system:set-current-datetime -u admin:admin -d '{"ietf-system:input": {"current-datetime": "2024-04-17T13:48:02-01:00"}}' +~$ curl -kX POST -u admin:admin \ + -H "Content-Type: application/yang-data+json" \ + -d '{"ietf-system:input": {"current-datetime": "2024-04-17T13:48:02-01:00"}}' \ + https://example.local/restconf/operations/ietf-system:set-current-datetime + ``` You can verify that the changes took by a remote SSH command: @@ -879,6 +887,51 @@ Wed Apr 17 14:48:12 UTC 2024 ~$ ``` +### Read Hostname + +Example of fetching JSON configuration data to stdout: + +``` +~$ curl -kX GET -u admin:admin \ + -H 'Accept: application/yang-data+json' \ + https://example.local/restconf/data/ietf-system:system/hostname +{ + "ietf-system:system": { + "hostname": "foo" + } +} +``` + +### Set Hostname + +Example of inline JSON data: + +``` +~$ curl -kX PATCH -u admin:admin \ + -H 'Content-Type: application/yang-data+json' \ + -d '{"ietf-system:system":{"hostname":"bar"}}' \ + https://example.local/restconf/data/ietf-system:system +``` + +### Copy Running to Startup + +No copy command available yet to copy between datastores, and the +Rousette back-end also does not support "write-through" to the +startup datastore. + +To save running-config to startup-config, use the following example to +fetch running to a local file and then update startup with it: + +``` +~$ curl -kX GET -u admin:admin -o running-config.json \ + -H 'Accept: application/yang-data+json' \ + https://example.local/restconf/ds/ietf-datastores:running + +~$ curl -kX PUT -u admin:admin -d @running-config.json \ + -H 'Content-Type: application/yang-data+json' \ + https://example.local/restconf/ds/ietf-datastores:startup +``` + ## Miscellaneous diff --git a/package/confd/confd.conf b/package/confd/confd.conf index c8dcf4eb..91bc58ec 100644 --- a/package/confd/confd.conf +++ b/package/confd/confd.conf @@ -29,8 +29,3 @@ run name:error :2 log:console norestart \ service name:netopeer notify:none log env:/etc/default/confd \ [12345] netopeer2-server -F -t $CONFD_TIMEOUT -v 1 \ -- NETCONF server - -# Create initial /etc/resolv.conf after successful bootstrap -task name:resolv :conf norestart \ - if: \ - [S] resolvconf -u -- Update DNS configuration diff --git a/package/confd/confd.mk b/package/confd/confd.mk index 4d9fe8a5..4309ee2d 100644 --- a/package/confd/confd.mk +++ b/package/confd/confd.mk @@ -26,8 +26,10 @@ CONFD_CONF_OPTS += --disable-containers endif define CONFD_INSTALL_EXTRA - cp $(CONFD_PKGDIR)/confd.conf $(FINIT_D)/available/ - ln -sf ../available/confd.conf $(FINIT_D)/enabled/confd.conf + for fn in confd.conf resolvconf.conf; do \ + cp $(CONFD_PKGDIR)/$$fn $(FINIT_D)/available/; \ + ln -sf ../available/$$fn $(FINIT_D)/enabled/$$fn; \ + done cp $(CONFD_PKGDIR)/tmpfiles.conf $(TARGET_DIR)/etc/tmpfiles.d/confd.conf mkdir -p $(TARGET_DIR)/etc/avahi/services cp $(CONFD_PKGDIR)/avahi.service $(TARGET_DIR)/etc/avahi/services/netconf.service diff --git a/package/confd/resolvconf.conf b/package/confd/resolvconf.conf new file mode 100644 index 00000000..e08a1acc --- /dev/null +++ b/package/confd/resolvconf.conf @@ -0,0 +1,3 @@ +# Create initial /etc/resolv.conf after successful bootstrap, regardless +# of startup-config or failure-config. Condition set by confd. +task [S12345] resolvconf -u -- Update DNS configuration diff --git a/package/finit/finit.hash b/package/finit/finit.hash index 813e0ad1..be07d5ef 100644 --- a/package/finit/finit.hash +++ b/package/finit/finit.hash @@ -1,5 +1,5 @@ # From https://github.com/troglobit/finit/releases/ -sha256 ead37606012ced935c66dcfd88786d533d08964b00adb7899ea156ae29b7896a finit-4.10-rc1.tar.gz +sha256 40c8db203cb59381973146f7157bde6886f05de06f18f1bd567c70ee780cbe3f finit-4.10-rc2.tar.gz # Locally calculated sha256 2fd62c0fe6ea6d1861669f4c87bda83a0b5ceca64f4baa4d16dd078fbd218c14 LICENSE diff --git a/package/finit/finit.mk b/package/finit/finit.mk index eec7fede..37dbdb95 100644 --- a/package/finit/finit.mk +++ b/package/finit/finit.mk @@ -4,7 +4,7 @@ # ################################################################################ -FINIT_VERSION = 4.10-rc1 +FINIT_VERSION = 4.10-rc2 FINIT_SITE = https://github.com/troglobit/finit/releases/download/$(FINIT_VERSION) FINIT_LICENSE = MIT FINIT_LICENSE_FILES = LICENSE diff --git a/patches/avahi/0001-On-SIGTERM-allow-dispatcher-to-process-event-before-.patch b/patches/avahi/0001-On-SIGTERM-allow-dispatcher-to-process-event-before-.patch index d9abc24c..6a3441fc 100644 --- a/patches/avahi/0001-On-SIGTERM-allow-dispatcher-to-process-event-before-.patch +++ b/patches/avahi/0001-On-SIGTERM-allow-dispatcher-to-process-event-before-.patch @@ -1,7 +1,7 @@ From 74ec0f8335f811e4f5becc8bbea4a52af4d3e749 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 17 Sep 2024 04:08:12 +0200 -Subject: [PATCH 1/2] On SIGTERM, allow dispatcher to process event before +Subject: [PATCH 1/3] On SIGTERM, allow dispatcher to process event before exiting Organization: Addiva Elektronik diff --git a/patches/avahi/0002-avahi-daemon-allow-adjusting-log-level.patch b/patches/avahi/0002-avahi-daemon-allow-adjusting-log-level.patch index 40be33cd..0b73ec1e 100644 --- a/patches/avahi/0002-avahi-daemon-allow-adjusting-log-level.patch +++ b/patches/avahi/0002-avahi-daemon-allow-adjusting-log-level.patch @@ -1,7 +1,7 @@ From bceb724d328f156efa4ad18f26f1760504bd093d Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 27 Nov 2024 08:44:57 +0100 -Subject: [PATCH 2/2] avahi-daemon: allow adjusting log level +Subject: [PATCH 2/3] avahi-daemon: allow adjusting log level Organization: Addiva Elektronik Signed-off-by: Joachim Wiberg diff --git a/patches/avahi/0003-avahi-daemon-improve-error-reporting-in-chroot-commu.patch b/patches/avahi/0003-avahi-daemon-improve-error-reporting-in-chroot-commu.patch new file mode 100644 index 00000000..5de92a72 --- /dev/null +++ b/patches/avahi/0003-avahi-daemon-improve-error-reporting-in-chroot-commu.patch @@ -0,0 +1,60 @@ +From 50ddfbefe5ac4d87040cb177e7cf432d4da04e97 Mon Sep 17 00:00:00 2001 +From: Joachim Wiberg +Date: Wed, 26 Feb 2025 17:42:08 +0100 +Subject: [PATCH 3/3] avahi-daemon: improve error reporting in chroot + communication +Organization: Addiva Elektronik + +Improve logging of error in chroot communication by including the +filename in the log message. Instead of this: + + avahi-daemon[3590]: chroot.c: open() failed: No such file or directory + +log this: + + avahi-daemon[3590]: chroot.c: open(/etc/resolv.conf) failed: No such file or directory + +Which on a system with resolvconf would make the sysadmin a lot calmer, +since the file had not yet been created at boot. + +Signed-off-by: Joachim Wiberg +--- + avahi-daemon/chroot.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/avahi-daemon/chroot.c b/avahi-daemon/chroot.c +index ccd56be..fbaad69 100644 +--- a/avahi-daemon/chroot.c ++++ b/avahi-daemon/chroot.c +@@ -237,12 +237,13 @@ static int helper_main(int fd) { + case AVAHI_CHROOT_GET_RECORD_BROWSER_INTROSPECT: + #endif + case AVAHI_CHROOT_GET_RESOLV_CONF: { ++ const char *fn = get_file_name_table[(int) command]; + int payload; + +- if ((payload = open(get_file_name_table[(int) command], O_RDONLY)) < 0) { ++ if ((payload = open(fn, O_RDONLY)) < 0) { + uint8_t c = AVAHI_CHROOT_FAILURE; + +- avahi_log_error(__FILE__": open() failed: %s", strerror(errno)); ++ avahi_log_error(__FILE__": open(%s) failed: %s", fn, strerror(errno)); + + if (write(fd, &c, sizeof(c)) != sizeof(c)) { + avahi_log_error(__FILE__": write() failed: %s\n", strerror(errno)); +@@ -262,9 +263,11 @@ static int helper_main(int fd) { + + case AVAHI_CHROOT_UNLINK_SOCKET: + case AVAHI_CHROOT_UNLINK_PID: { ++ const char *fn = unlink_file_name_table[(int) command]; + uint8_t c = AVAHI_CHROOT_SUCCESS; + +- unlink(unlink_file_name_table[(int) command]); ++ if (unlink(fn) && errno != ENOENT) ++ avahi_log_error(__FILE__": unlink(%s) failed: %s", fn, strerror(errno)); + + if (write(fd, &c, sizeof(c)) != sizeof(c)) { + avahi_log_error(__FILE__": write() failed: %s\n", strerror(errno)); +-- +2.43.0 + diff --git a/patches/openresolv/3.12.0/finit-support.patch b/patches/openresolv/3.12.0/finit-support.patch deleted file mode 100644 index 6b9be23e..00000000 --- a/patches/openresolv/3.12.0/finit-support.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -ru openresolv-3.12.0.orig/resolvconf.in openresolv-3.12.0/resolvconf.in ---- openresolv-3.12.0.orig/resolvconf.in 2020-12-27 19:05:10.000000000 +0100 -+++ openresolv-3.12.0/resolvconf.in 2023-03-27 00:19:03.365164029 +0200 -@@ -315,6 +315,8 @@ - then - /usr/bin/systemctl restart $1.service - fi' -+ elif [ -x /sbin/initctl ]; then -+ RESTARTCMD="/sbin/initctl -bnq restart \$1" - elif [ -x /sbin/rc-service ] && - { [ -s /libexec/rc/init.d/softlevel ] || - [ -s /run/openrc/softlevel ]; } diff --git a/patches/openresolv/foo-3.12.0/finit-support.patch b/patches/openresolv/foo-3.12.0/finit-support.patch deleted file mode 100644 index 1e1588df..00000000 --- a/patches/openresolv/foo-3.12.0/finit-support.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff -ru openresolv-3.12.0.orig/resolvconf.in openresolv-3.12.0/resolvconf.in ---- openresolv-3.12.0.orig/resolvconf.in 2020-12-27 19:05:10.000000000 +0100 -+++ openresolv-3.12.0/resolvconf.in 2023-03-27 00:19:03.365164029 +0200 -@@ -315,6 +315,12 @@ - then - /usr/bin/systemctl restart $1.service - fi' -+ elif [ -x /sbin/initctl ]; then -+ # Finit -+ RESTARTCMD=' -+ if /sbin/initctl -bq status $1; then -+ /sbin/initctl -bnq restart $1 -+ fi' - elif [ -x /sbin/rc-service ] && - { [ -s /libexec/rc/init.d/softlevel ] || - [ -s /run/openrc/softlevel ]; } diff --git a/src/confd/src/core.c b/src/confd/src/core.c index f8e6bc2e..ba987f4b 100644 --- a/src/confd/src/core.c +++ b/src/confd/src/core.c @@ -76,8 +76,11 @@ int core_post_hook(sr_session_ctx_t *session, uint32_t sub_id, const char *modul } /* skip reload in bootstrap, implicit reload in runlevel change */ - if (systemf("runlevel >/dev/null 2>&1")) + if (systemf("runlevel >/dev/null 2>&1")) { + /* trigger any tasks waiting for confd to have applied *-config */ + system("initctl -nbq cond set bootstrap"); return SR_ERR_OK; + } if (systemf("initctl -b reload")) return SR_ERR_SYS; diff --git a/src/confd/src/ietf-system.c b/src/confd/src/ietf-system.c index 5f2bb746..0532797e 100644 --- a/src/confd/src/ietf-system.c +++ b/src/confd/src/ietf-system.c @@ -540,11 +540,8 @@ static int change_dns(sr_session_ctx_t *session, uint32_t sub_id, const char *mo (void)rename(RESOLV_NEXT, RESOLV_CONF); } - /* in bootstrap, another resolvconf will soon take your call */ - if (systemf("initctl -bq cond get hook/sys/up")) - return 0; + systemf("initctl -bq touch resolvconf"); - systemf("resolvconf -u"); return SR_ERR_OK; default: @@ -1761,7 +1758,7 @@ static int change_hostname(sr_session_ctx_t *session, uint32_t sub_id, const cha /* Inform any running lldpd and avahi of the change ... */ systemf("initctl -bq status lldpd && lldpcli configure system hostname %s", hostnm); systemf("initctl -bq status mdns && avahi-set-host-name %s", hostnm); - systemf("initctl -nbq touch netbrowse"); + systemf("initctl -bq touch netbrowse"); err: if (fmt) free(fmt); diff --git a/src/statd/statd.c b/src/statd/statd.c index 1fa66e41..11e3aaec 100644 --- a/src/statd/statd.c +++ b/src/statd/statd.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -409,6 +410,9 @@ int main(int argc, char *argv[]) sigusr1_watcher.data = &statd; ev_signal_start(statd.ev_loop, &sigusr1_watcher); + /* Signal readiness to Finit */ + pidfile(NULL); + INFO("Status daemon entering main event loop"); ev_run(statd.ev_loop, 0);