From: Neeraj Pratap Singh Date: Wed, 13 Apr 2022 07:59:01 +0000 (+0530) Subject: cephfs-shell: allowable mask changed to 07777. X-Git-Tag: v18.0.0~958^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ddc85ece62252c0b0390f384de0d2de656a5d7d2;p=ceph.git cephfs-shell: allowable mask changed to 07777. Signed-off-by: Neeraj Pratap Singh --- diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index 1902521325cb0..bbeb31bda15e2 100755 --- a/src/tools/cephfs/cephfs-shell +++ b/src/tools/cephfs/cephfs-shell @@ -507,10 +507,9 @@ class CephFSShell(Cmd): except ValueError: res = re.match('((u?g?o?)|(a?))(=)(r?w?x?)', values) if res is None: - parser.error("invalid mode: %s\n" + parser.error(f"invalid mode: {values}\n" "mode must be a numeric octal literal\n" - "or ((u?g?o?)|(a?))(=)(r?w?x?)" % - values) + "or ((u?g?o?)|(a?))(=)(r?w?x?)") else: # we are supporting only assignment of mode and not + or - # as is generally available with the chmod command @@ -524,9 +523,8 @@ class CephFSShell(Cmd): parser.error("need assignment operator between user " "and mode specifiers") if val[4] == '': - parser.error("invalid mode: %s\n" - "mode must be combination of: r | w | x" % - values) + parser.error(f"invalid mode: {values}\n" + "mode must be combination of: r | w | x") users = '' if val[2] is None: users = val[1] @@ -552,11 +550,11 @@ class CephFSShell(Cmd): o_mode |= t_mode if o_mode < 0: - parser.error("invalid mode: %s\n" - "mode cannot be negative" % values) - if o_mode > 0o777: - parser.error("invalid mode: %s\n" - "mode cannot be greater than octal 0777" % values) + parser.error(f"invalid mode: {values}\n" + "mode cannot be negative") + if o_mode > 0o7777: + parser.error(f"invalid mode: {values}\n" + "mode cannot be greater than octal 07777") setattr(namespace, self.dest, str(oct(o_mode))) @@ -1002,15 +1000,15 @@ class CephFSShell(Cmd): """ return self.complete_filenames(text, line, begidx, endidx) - chmod_parser = argparse.ArgumentParser(description='Create Directory.') + chmod_parser = argparse.ArgumentParser(description='Change permission of a file/directory.') chmod_parser.add_argument('mode', type=str, action=ModeAction, help='Mode') chmod_parser.add_argument('paths', type=str, action=path_to_bytes, - help='Name of the file', nargs='+') + help='Path of the file/directory', nargs='+') @with_argparser(chmod_parser) def do_chmod(self, args): """ - Change permission of a file + Change permission of a file/directory """ for path in args.paths: mode = int(args.mode, base=8)