From e628ddfdbfbf83b9052b099cfd00abac3ba0143a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 4 Dec 2017 09:37:34 -0500 Subject: [PATCH] [plasmalnf] Try to get back to the live user before changing themes --- src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 10 +++++++++- src/modules/plasmalnf/PlasmaLnfViewStep.h | 1 + src/modules/plasmalnf/plasmalnf.conf | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index 1ac3226b1..fd6eab78d 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -125,6 +125,11 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) if ( m_lnfPath.isEmpty() ) cDebug() << "WARNING: no lnftool given for plasmalnf module."; + + QString liveUser; + if ( configurationMap.contains( "liveuser" ) && configurationMap.value( "liveuser" ).type() == QVariant::String ) + liveUser = configurationMap.value( "liveuser" ).toString(); + m_liveUser = liveUser; } void @@ -133,7 +138,10 @@ PlasmaLnfViewStep::themeSelected( const QString& id ) m_themeId = id; QProcess lnftool; - lnftool.start( m_lnfPath, {"--resetLayout", "--apply", id} ); + if ( !m_liveUser.isEmpty() ) + lnftool.start( "sudo", {"-E", "-H", "-u", m_liveUser, m_lnfPath, "--resetLayout", "--apply", id} ); + else + lnftool.start( m_lnfPath, {"--resetLayout", "--apply", id} ); if ( !lnftool.waitForStarted( 1000 ) ) { diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h index e65b59b93..7fcfc50cc 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.h +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -63,6 +63,7 @@ private: PlasmaLnfPage* m_widget; QString m_lnfPath; QString m_themeId; + QString m_liveUser; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfViewStepFactory ) diff --git a/src/modules/plasmalnf/plasmalnf.conf b/src/modules/plasmalnf/plasmalnf.conf index d9817ecbc..059ed9e36 100644 --- a/src/modules/plasmalnf/plasmalnf.conf +++ b/src/modules/plasmalnf/plasmalnf.conf @@ -2,3 +2,9 @@ # Full path to the Plasma look-and-feel tool (CLI program # for querying and applying Plasma themes). lnftool: "/usr/bin/lookandfeeltool" + +# For systems where the user Calamares runs as (usually root, +# via either sudo or pkexec) has a clean environment, set this +# to the originating username; the lnftool will be run through +# "sudo -H -u " instead of directly. +liveuser: "live"