예제 #1
0
 def setUp(self):
     super(TC_00_Appmenus, self).setUp()
     vmname = VMPREFIX + 'standalone'
     self.standalone = TestVM(
         name=vmname,
         klass='StandaloneVM',
         updateable=True,
     )
     vmname = VMPREFIX + 'template'
     self.template = TestVM(
         name=vmname,
         klass='TemplateVM',
         updateable=True,
     )
     vmname = VMPREFIX + 'vm'
     self.appvm = TestVM(
         name=vmname,
         klass='AppVM',
         template=self.template,
         updateable=False,
     )
     self.app = TestApp()
     self.ext = qubesappmenus.Appmenus()
     self.basedir_obj = tempfile.TemporaryDirectory()
     self.basedir = self.basedir_obj.name
     self.basedir_patch = unittest.mock.patch('qubesappmenus.basedir',
         self.basedir)
     self.basedir_patch.start()
def main(args=None):
    '''Main function of qvm-sync-appmenus tool'''
    env_vmname = os.environ.get("QREXEC_REMOTE_DOMAIN")

    args = parser.parse_args(args)

    if os.getuid() == 0 and not args.force_root:
        parser.error('This tool should not be executed as root. If you are '
                     'absolutely sure you know what you are doing, '
                     'use --force-root')

    if env_vmname:
        vm = args.app.domains[env_vmname]
    elif not args.domains:
        parser.error("You must specify at least the VM name!")
    else:
        vm = args.domains[0]

    if env_vmname is None or args.force_rpc:
        use_stdin = False
    else:
        use_stdin = True
    appmenusext = qubesappmenus.Appmenus()
    if not args.regenerate_only:
        new_appmenus = retrieve_appmenus_templates(vm, use_stdin=use_stdin)
        if not new_appmenus and vm.klass != "AppVM":
            vm.log.info("No appmenus received, terminating")
        else:
            process_appmenus_templates(appmenusext, vm, new_appmenus)
    appmenusext.appmenus_update(vm)
예제 #3
0
def main(args=None):
    '''Main function of qvm-sync-appmenus tool'''
    env_vmname = os.environ.get("QREXEC_REMOTE_DOMAIN")

    args = parser.parse_args(args)

    if env_vmname:
        vm = args.app.domains[env_vmname]
    elif not args.domains:
        parser.error("You must specify at least the VM name!")
    else:
        vm = args.domains[0]

    if env_vmname is None or args.force_rpc:
        use_stdin = False
    else:
        use_stdin = True
    appmenusext = qubesappmenus.Appmenus()
    if not args.regenerate_only:
        new_appmenus = retrieve_appmenus_templates(vm, use_stdin=use_stdin)
        if not new_appmenus and vm.klass != "AppVM":
            vm.log.info("No appmenus received, terminating")
        else:
            process_appmenus_templates(appmenusext, vm, new_appmenus)
    appmenusext.appmenus_update(vm)
 def setUp(self):
     super(TC_10_AppmenusIntegration, self).setUp()
     self.vm = self.create_vms(['vm'])[0]
     # when tests are running as root, patch basedir to point at
     # normal user's home
     if os.getuid() == 0:
         user = grp.getgrnam('qubes').gr_mem[0]
         basedir = os.path.expanduser(
             '~{}/.local/share/qubes-appmenus'.format(user))
         self.basedir_patch = unittest.mock.patch('qubesappmenus.basedir',
                                                  basedir)
         self.basedir_patch.start()
         self.xdg_data_home = os.path.expanduser(
             '~{}/.local/share'.format(user))
     else:
         self.basedir_patch = None
         self.xdg_data_home = xdg.BaseDirectory.xdg_data_home
     self.appmenus = qubesappmenus.Appmenus()
예제 #5
0
 def setUp(self):
     super(TC_00_Appmenus, self).setUp()
     vmname = VMPREFIX + 'standalone'
     self.standalone = TestVM(
         name=vmname,
         updateable=True,
     )
     vmname = VMPREFIX + 'template'
     self.template = TestVM(
         name=vmname,
         updateable=True,
     )
     vmname = VMPREFIX + 'vm'
     self.appvm = TestVM(
         name=vmname,
         template=self.template,
         updateable=False,
     )
     self.app = TestApp()
     self.ext = qubesappmenus.Appmenus()
     self.basedir = os.path.expanduser('~/.local/share/qubes-appmenus')
예제 #6
0
 def setUp(self):
     super(TC_10_AppmenusIntegration, self).setUp()
     self.vm = self.create_vms(['vm'])[0]
     self.appmenus = qubesappmenus.Appmenus()