Whamcloud - gitweb
LU-18462 nodemap: sanity checks for nodemap_activate 72/57072/6
authorSebastien Buisson <sbuisson@ddn.com>
Tue, 19 Nov 2024 15:51:25 +0000 (16:51 +0100)
committerOleg Drokin <green@whamcloud.com>
Thu, 2 Jan 2025 20:50:33 +0000 (20:50 +0000)
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 <sbuisson@ddn.com>
Change-Id: Ifc8528f76af0ff75bfef1febe85dc688af06321d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57072
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Marc Vef <mvef@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/doc/lctl-nodemap-activate.8
lustre/ptlrpc/nodemap_handler.c

index 44f499a..36c1520 100644 (file)
@@ -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
index 7869ae3..51cfff7 100644 (file)
@@ -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: