Merge pull request #967 from kernelkit/misc

Miscellaneous fixes

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-02-28 16:16:59 +01:00
committed by GitHub
15 changed files with 141 additions and 49 deletions
+4 -1
View File
@@ -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
+56 -3
View File
@@ -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
-5
View File
@@ -29,8 +29,3 @@ run name:error :2 log:console norestart \
service name:netopeer notify:none log env:/etc/default/confd \
[12345] <pid/confd> netopeer2-server -F -t $CONFD_TIMEOUT -v 1 \
-- NETCONF server
# Create initial /etc/resolv.conf after successful bootstrap
task name:resolv :conf norestart \
if:<run/startup/success> \
[S] <pid/dnsmasq> resolvconf -u -- Update DNS configuration
+4 -2
View File
@@ -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
+3
View File
@@ -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] <usr/bootstrap> resolvconf -u -- Update DNS configuration
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
@@ -1,7 +1,7 @@
From 74ec0f8335f811e4f5becc8bbea4a52af4d3e749 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
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
@@ -1,7 +1,7 @@
From bceb724d328f156efa4ad18f26f1760504bd093d Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
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 <troglobit@gmail.com>
@@ -0,0 +1,60 @@
From 50ddfbefe5ac4d87040cb177e7cf432d4da04e97 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg <troglobit@gmail.com>
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 <troglobit@gmail.com>
---
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
@@ -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 ]; }
@@ -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 ]; }
+4 -1
View File
@@ -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;
+2 -5
View File
@@ -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);
+4
View File
@@ -13,6 +13,7 @@
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <libite/lite.h>
#include <jansson.h>
#include <ctype.h>
#include <linux/if.h>
@@ -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);