mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 11:01:26 +00:00
lxc-ls: Show a simple error message when non-root
Instead of returning a python stacktrace, check what the current euid is and show an argparse error message similar to that used in lxc-start-ephemeral. Signed-off-by: Stéphane Graber <stgraber@ubuntu.com> Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
c0b5f522fe
commit
daf04e4ce9
@ -32,6 +32,7 @@ warnings.filterwarnings("ignore", "The python-lxc API isn't yet stable")
|
||||
import argparse
|
||||
import gettext
|
||||
import lxc
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
@ -115,6 +116,12 @@ parser.add_argument("filter", metavar='FILTER', type=str, nargs="?",
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Basic checks
|
||||
## The user needs to be uid 0
|
||||
if not os.geteuid() == 0:
|
||||
parser.error(_("You must be root to run this script. Try running: sudo %s"
|
||||
% (sys.argv[0])))
|
||||
|
||||
# --active is the same as --running --frozen
|
||||
if args.active:
|
||||
if not args.state:
|
||||
|
Loading…
Reference in New Issue
Block a user