From 30a872759e550a36196543b834a7607a389d9a0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Beamonte?= Date: Tue, 7 Aug 2018 15:13:59 -0400 Subject: [PATCH] Add a valid_user type This types is meant to be used to check if strings provided are valid user names. This is however designed to be overriden by site-specific policies. The regex used as default for this type is the one suggested by the useradd man page. --- quattor/functions/validation.pan | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/quattor/functions/validation.pan b/quattor/functions/validation.pan index 58675383e..f944406e6 100644 --- a/quattor/functions/validation.pan +++ b/quattor/functions/validation.pan @@ -139,3 +139,13 @@ function valid_absolute_file_paths = { }; true; }; + +variable VALID_USER_PATTERN ?= '^[a-zA-Z_][a-zA-Z0-9_-]{0,30}([a-zA-Z0-9_-]|\$)?$'; + +@documentation{ + This type is meant to be used to check if strings provided are + valid user names. This is however designed to be overriden by + site-specific policies. The regex used here as default is the + one suggested by the useradd man page. +} +type valid_user = string with match(SELF, VALID_USER_PATTERN);