Skip to content

Commit

Permalink
Use qrexec.client.call instead of reinventing it
Browse files Browse the repository at this point in the history
  • Loading branch information
marmarta committed Jun 28, 2023
1 parent e92a307 commit e2b26c4
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions qubesmanager/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.
#
#

import os
import sys
import subprocess

import pkg_resources
from PyQt5 import QtWidgets, QtCore, QtGui # pylint: disable=import-error

from qubesadmin.utils import parse_size
from qubesadmin import exc
from qubesmanager.releasenotes import ReleaseNotesDialog
from qubesmanager.informationnotes import InformationNotesDialog
from qrexec.client import call as qrexec_call # pylint: disable=import-error

from . import ui_globalsettingsdlg # pylint: disable=no-name-in-module
from . import utils
Expand All @@ -40,31 +38,7 @@


def _run_qrexec_repo(service, arg=''):
# Set default locale to C in order to prevent error msg
# in subprocess call related to falling back to C locale
env = os.environ.copy()
env['LC_ALL'] = 'C'
# Fake up a "qrexec call" to dom0 because dom0 can't qrexec to itself yet
cmd = '/etc/qubes-rpc/' + service
p = subprocess.run(
['sudo', cmd, arg],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=False,
env=env
)
if p.returncode != 0:
msg = QtCore.QCoreApplication.translate(
"GlobalSettings",
'qrexec call exited with non-zero return code')
raise exc.QubesException(msg + ' (%s): %s',
p.returncode, p.stderr.decode('utf-8'))
if p.stderr:
msg = QtCore.QCoreApplication.translate(
"GlobalSettings",
'%s qrexec call stderr was not empty (%s)')
print(msg % (service, p.stderr.decode('utf-8')), file=sys.stderr)
return p.stdout.decode('utf-8')
return qrexec_call('dom0', service, arg)


class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
Expand Down

0 comments on commit e2b26c4

Please sign in to comment.