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>
import argparse
import gettext
import lxc
+import os
import re
import sys
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: