From 927e666cb9e1c48551d7237ce5a61eb7a6069aa2 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig <hch@lst.de> Date: Wed, 23 Mar 2016 20:21:07 +0100 Subject: [PATCH] nvmetcli: print a useful warning when not called as root user Signed-off-by: Christoph Hellwig <hch@lst.de> --- nvmetcli | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nvmetcli b/nvmetcli index 0650cab..f8ef5c6 100755 --- a/nvmetcli +++ b/nvmetcli @@ -18,6 +18,9 @@ License for the specific language governing permissions and limitations under the License. ''' +from __future__ import print_function + +import os import sys import configshell_fb as configshell import nvmet.nvme as nvme @@ -215,6 +218,10 @@ funcs = dict(save=save, restore=restore, clear=clear) def main(): + if os.geteuid() != 0: + print("%s: must run as root." % sys.argv[0], file=sys.stderr) + sys.exit(-1) + if len(sys.argv) > 3: usage() -- GitLab