From: Sebastien Buisson Date: Tue, 19 Nov 2024 15:51:25 +0000 (+0100) Subject: LU-18462 nodemap: sanity checks for nodemap_activate X-Git-Tag: 2.16.51~14 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=fd51fda67c83afd011480b8323e0f3e05e96cfc1;p=fs%2Flustre-release.git LU-18462 nodemap: sanity checks for nodemap_activate Input parameter of 'lctl nodemap_activate' should be checked to return an error in case of invalid input value. Allowed values are, case insensitive: - to activate: 1, on, true, t, yes, y - to deactivate: 0, off, false, f, no, n We do not use kstrtobool() to parse the input parameter, as it is too permissive and looks mostly at the first character only. Test-Parameters: trivial testlist=sanity-sec Signed-off-by: Sebastien Buisson Change-Id: Ifc8528f76af0ff75bfef1febe85dc688af06321d Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57072 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Marc Vef Reviewed-by: Oleg Drokin --- diff --git a/lustre/doc/lctl-nodemap-activate.8 b/lustre/doc/lctl-nodemap-activate.8 index 44f499a..36c1520 100644 --- a/lustre/doc/lctl-nodemap-activate.8 +++ b/lustre/doc/lctl-nodemap-activate.8 @@ -3,7 +3,7 @@ lctl-nodemap_activate \- activate or deactivate the nodemap feature .SH SYNOPSIS .SY "lctl nodemap_activate" -.RB { 0 | 1 } +.RB { <0,off,false,f,no,n> | <1,on,true,t,yes,y> } .YS .SH DESCRIPTION .B nodemap_activate @@ -11,7 +11,31 @@ is used to globally activate or deactivate the nodemap feature. When nodemap is active, all client IDs are mapped based on rules specified by the administrator, and filesystem operations may be restricted or prevented. .SH OPTIONS -Passing 0 disables the nodemap feature, while 1 activates the feature. +Passing +.BI 0 +, +.BI off +, +.BI false +, +.BI f +, +.BI no +, or +.BI n +disables the nodemap feature, while +.BI 1 +, +.BI on +, +.BI true +, +.BI t +, +.BI yes +, or +.BI y +activates the feature. .SH EXAMPLES .EX .B # lctl nodemap_activate 1 diff --git a/lustre/ptlrpc/nodemap_handler.c b/lustre/ptlrpc/nodemap_handler.c index 7869ae3..51cfff7 100644 --- a/lustre/ptlrpc/nodemap_handler.c +++ b/lustre/ptlrpc/nodemap_handler.c @@ -2683,10 +2683,22 @@ int server_iocontrol_nodemap(struct obd_device *obd, if (lcfg->lcfg_bufcount != 2) GOTO(out_lcfg, rc = -EINVAL); param = lustre_cfg_string(lcfg, 1); - if (strcmp(param, "1") == 0) + if (strcmp(param, "1") == 0 || + strcasecmp(param, "on") == 0 || + strcasecmp(param, "yes") == 0 || + strcasecmp(param, "y") == 0 || + strcasecmp(param, "true") == 0 || + strcasecmp(param, "t") == 0) nodemap_activate(1); - else + else if (strcmp(param, "0") == 0 || + strcasecmp(param, "off") == 0 || + strcasecmp(param, "no") == 0 || + strcasecmp(param, "n") == 0 || + strcasecmp(param, "false") == 0 || + strcasecmp(param, "f") == 0) nodemap_activate(0); + else + rc = -EINVAL; break; case LCFG_NODEMAP_ADD: case LCFG_NODEMAP_DEL: