From a43bdd94abc098366c13bb5e7364aa70a814afb7 Mon Sep 17 00:00:00 2001 From: Jon-Olov Vatn Date: Tue, 11 Jul 2023 16:43:24 +0200 Subject: [PATCH] Limit username length and pattern in system yang model Deviation in ietf-system.yang 'replace' username type from general string to a string with length and pattern restrictions inline with the BusyBox 'adduser' tool. Note, chk_sr_user_update is more restrictive, which should be handled. --- src/confd/yang/infix-system@2023-07-04.yang | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/confd/yang/infix-system@2023-07-04.yang b/src/confd/yang/infix-system@2023-07-04.yang index 7f894963..beb4758a 100644 --- a/src/confd/yang/infix-system@2023-07-04.yang +++ b/src/confd/yang/infix-system@2023-07-04.yang @@ -14,9 +14,10 @@ module infix-system { revision 2023-07-04 { description "Updating/adding deviation specifications: - - timezone-utc-offset (updated) - - radius (added) - - dns-resolver port (added)"; + - timezone-utc-offset (updated path for 'not-supported') + - radius ('not-supported') + - dns-resolver port ('not-supported') + - authentication username (limit length and pattern)"; reference "internal"; } @@ -25,6 +26,13 @@ module infix-system { reference "internal"; } + typedef username { + type string { + length "1..256"; + pattern "[_a-zA-Z0-9][-._a-zA-Z0-9]*$?"; + } + } + augment "/sys:system" { description "Augments to ietf-system not found in any other model."; leaf motd { @@ -44,4 +52,10 @@ module infix-system { deviation "/sys:system/sys:dns-resolver/sys:server/sys:transport/sys:udp-and-tcp/sys:udp-and-tcp/sys:port" { deviate not-supported; } + + deviation "/sys:system/sys:authentication/sys:user/sys:name" { + deviate replace { + type infix-sys:username; + } + } }