From 8d2bdd1f1d18cb43557eef287cc5cd0aa63b2b8f Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 19 Jul 2024 08:01:05 +0200 Subject: [PATCH] confd: rename syslog format -> log-format, add must expression - For consistency and clarity, rename format -> log-format - Add must expression to ban 'bsd' format from file logging Note: technically, sysklogd silently reverts back to rfc3164 for file logging, but it's better to be clear with the user with what is possible to configure and is going to be used. Signed-off-by: Joachim Wiberg --- src/confd/src/ietf-syslog.c | 2 +- src/confd/yang/confd.inc | 2 +- ...7-18.yang => infix-syslog@2024-07-19.yang} | 20 ++++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) rename src/confd/yang/{infix-syslog@2024-07-18.yang => infix-syslog@2024-07-19.yang} (94%) diff --git a/src/confd/src/ietf-syslog.c b/src/confd/src/ietf-syslog.c index 772eb5fa..f8d94b9f 100644 --- a/src/confd/src/ietf-syslog.c +++ b/src/confd/src/ietf-syslog.c @@ -156,7 +156,7 @@ static void action(sr_session_ctx_t *session, const char *name, const char *xpat sep = ","; } - fmt = srx_get_str(session, "%s/format", xpath); + fmt = srx_get_str(session, "%s/log-format", xpath); if (fmt) { char *ptr = strchr(fmt, ':'); /* skip any prefix */ diff --git a/src/confd/yang/confd.inc b/src/confd/yang/confd.inc index 7edaab5f..866f5e15 100644 --- a/src/confd/yang/confd.inc +++ b/src/confd/yang/confd.inc @@ -20,7 +20,7 @@ MODULES=( # NOTE: ietf-tls-client must be version matched with ietf-tls-server, used by netopeer2! "ietf-tls-client@2023-12-28.yang" # used by ietf-syslog (remote) "ietf-syslog@2024-03-21.yang -e file-action -e file-limit-size -e remote-action" - "infix-syslog@2024-07-18.yang" + "infix-syslog@2024-07-19.yang" "iana-hardware@2018-03-13.yang" "ietf-hardware@2018-03-13.yang -e hardware-state" "infix-hardware@2024-04-25.yang" diff --git a/src/confd/yang/infix-syslog@2024-07-18.yang b/src/confd/yang/infix-syslog@2024-07-19.yang similarity index 94% rename from src/confd/yang/infix-syslog@2024-07-18.yang rename to src/confd/yang/infix-syslog@2024-07-19.yang index 752b8cf2..1d895d03 100644 --- a/src/confd/yang/infix-syslog@2024-07-18.yang +++ b/src/confd/yang/infix-syslog@2024-07-19.yang @@ -16,7 +16,7 @@ module infix-syslog { contact "kernelkit@googlegroups.com"; description "Infix augments and deviations to ietf-syslog, draft 32."; - revision 2024-07-18 { + revision 2024-07-19 { description "Initial revision, based on IETF syslog YANG draft 32. The following changes have been made in this model: @@ -76,16 +76,15 @@ module infix-syslog { * Shared settings */ - grouping format { - leaf format { + grouping log-format { + leaf log-format { description "Log format, one of: BSD*, RFC3164, or RFC5424. BSD : myproc[8710]: Kilroy was here. RFC3164 : Aug 24 05:14:15 192.0.2.1 myproc[8710]: Kilroy was here. RFC5424 : 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc 8710 - - Kilroy was here. - Please note, BSD format is only applicable to remote logging. - Specifying BSD for log-file action will revert to RFC3164."; + Please note, BSD format is only applicable to remote logging."; type identityref { base format-type; } @@ -157,17 +156,20 @@ module infix-syslog { augment "/syslog:syslog/syslog:actions/syslog:file/syslog:log-file" { description "Configurable log format for file logging."; - uses format { - refine format { + uses log-format { + refine log-format { default rfc3164; + must "not(../log-format = 'infix-syslog:bsd')" { + error-message "BSD log format is not applicable to file logging, only remote."; + } } } } augment "/syslog:syslog/syslog:actions/syslog:remote/syslog:destination" { description "Configurable log format for remote logging."; - uses format { - refine format { + uses log-format { + refine log-format { default bsd; } }