tools: kill --force-root and --qubesxml arguments

Those are no longer useful, as all actions are delegated to qubesd. Keep
--force-root argument (but ignore it and hide from help) for backward
compatibility with various scripts.

Fixes QubesOS/qubes-issues#2684
This commit is contained in:
Marek Marczykowski-Górecki 2017-03-08 23:28:20 +01:00
parent 32bd75da77
commit 61731a9490
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 4 additions and 24 deletions

View File

@ -302,7 +302,6 @@ class QubesArgumentParser(argparse.ArgumentParser):
:param bool want_app: instantiate :py:class:`qubes.Qubes` object
:param bool want_app_no_instance: don't actually instantiate \
:py:class:`qubes.Qubes` object, just add argument for custom xml file
:param bool want_force_root: add ``--force-root`` option
:param mixed vmname_nargs: The number of ``VMNAME`` arguments that should be
consumed. Values include:
- N (an integer) consumes N arguments (and produces a list)
@ -312,20 +311,18 @@ class QubesArgumentParser(argparse.ArgumentParser):
*kwargs* are passed to :py:class:`argparser.ArgumentParser`.
Currenty supported options:
``--force-root`` (optional)
``--qubesxml`` location of :file:`qubes.xml` (help is suppressed)
``--force-root`` (optional, ignored, help is suppressed)
``--offline-mode`` do not talk to hypervisor (help is suppressed)
``--verbose`` and ``--quiet``
'''
def __init__(self, want_app=True, want_app_no_instance=False,
want_force_root=False, vmname_nargs=None, **kwargs):
vmname_nargs=None, **kwargs):
super(QubesArgumentParser, self).__init__(**kwargs)
self._want_app = want_app
self._want_app_no_instance = want_app_no_instance
self._want_force_root = want_force_root
self._vmname_nargs = vmname_nargs
if self._want_app:
self.add_argument('--qubesxml', metavar='FILE', action='store',
@ -340,9 +337,8 @@ class QubesArgumentParser(argparse.ArgumentParser):
self.add_argument('--quiet', '-q', action='count',
help='decrease verbosity')
if self._want_force_root:
self.add_argument('--force-root', action='store_true',
default=False, help='force to run as root')
self.add_argument('--force-root', action='store_true',
default=False, help=argparse.SUPPRESS)
if self._vmname_nargs in [argparse.ZERO_OR_MORE, argparse.ONE_OR_MORE]:
vm_name_group = VmNameGroup(self, self._vmname_nargs)
@ -387,21 +383,6 @@ class QubesArgumentParser(argparse.ArgumentParser):
self.exit(1, '{}: error: {}\n'.format(self.prog, message))
def dont_run_as_root(self, namespace):
'''Prevent running as root.
:param argparse.Namespace args: if there is ``.force_root`` attribute \
set to true, run anyway
'''
try:
euid = os.geteuid()
except AttributeError: # no geteuid(), probably NT
return
if euid == 0 and not namespace.force_root:
self.error_runtime(
'refusing to run as root; add --force-root to override')
@staticmethod
def get_loglevel_from_verbosity(namespace):
''' Return loglevel calculated from quiet and verbose arguments '''

View File

@ -35,7 +35,6 @@ import qubesmgmt.vm
def get_parser(vmname_nargs=1):
'''Return argument parser for generic property-related tool'''
parser = qubesmgmt.tools.QubesArgumentParser(
want_force_root=True,
vmname_nargs=vmname_nargs)
# parser.add_argument('--help-properties',