diff --git a/qubes/app.py b/qubes/app.py index 10cd5fd7..eb28165c 100644 --- a/qubes/app.py +++ b/qubes/app.py @@ -135,10 +135,18 @@ class VirConnectWrapper(object): class VMMConnection(object): '''Connection to Virtual Machine Manager (libvirt)''' - def __init__(self, offline_mode=False): + def __init__(self, offline_mode=None): + ''' + + :param offline_mode: enable/disable offline mode; default is to + enable when running in chroot as root, otherwise disable + ''' self._libvirt_conn = None self._xs = None self._xc = None + if offline_mode is None: + offline_mode = bool(os.getuid() == 0 and + os.stat('/') != os.stat('/proc/1/root/.')) self._offline_mode = offline_mode @property @@ -600,7 +608,7 @@ class Qubes(qubes.PropertyHolder): default=True, doc='check for updates inside qubes') - def __init__(self, store=None, load=True, offline_mode=False, lock=False, + def __init__(self, store=None, load=True, offline_mode=None, lock=False, **kwargs): #: logger instance for logging global messages self.log = logging.getLogger('app') diff --git a/qubes/tools/__init__.py b/qubes/tools/__init__.py index b9db5255..4f420b50 100644 --- a/qubes/tools/__init__.py +++ b/qubes/tools/__init__.py @@ -333,7 +333,7 @@ class QubesArgumentParser(argparse.ArgumentParser): self.add_argument('--qubesxml', metavar='FILE', action='store', dest='app', help=argparse.SUPPRESS) self.add_argument('--offline-mode', action='store_true', - default=False, dest='offline_mode', help=argparse.SUPPRESS) + default=None, dest='offline_mode', help=argparse.SUPPRESS) self.add_argument('--verbose', '-v', action='count',