Vinzenz Feenstra has uploaded a new change for review. Change subject: linux: Logout active user support ......................................................................
linux: Logout active user support Change-Id: I1173dc8cb6c2bd68b5e2a2ba4ad69284b2085171 Bug-Url: https://bugzilla.redhat.com/758516 Signed-off-by: Vinzenz Feenstra <[email protected]> --- M ovirt-guest-agent/LockActiveSession.py A ovirt-guest-agent/LogoutActiveUser.py A ovirt-guest-agent/consoleapps/ovirt-logout M scripts/wrappers/Makefile.am A scripts/wrappers/ovirt-logout-wrapper.sh 5 files changed, 70 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-guest-agent refs/changes/16/35416/1 diff --git a/ovirt-guest-agent/LockActiveSession.py b/ovirt-guest-agent/LockActiveSession.py index dc0d055..a390a2d 100755 --- a/ovirt-guest-agent/LockActiveSession.py +++ b/ovirt-guest-agent/LockActiveSession.py @@ -110,6 +110,25 @@ return screensaver +def LogoutUserGnome(session): + pid = os.fork() + if pid == 0: + os.setuid(session.GetUnixUser()) + os.environ['DISPLAY'] = session.GetX11Display() + subprocess.call(['/usr/bin/gnome-session-save', '--force-logout']) + else: + os.waitpid(pid, 0) + + +def LogoutUser(): + session = GetActiveSession() + if os.path.exists('/usr/bin/loginctl'): + subprocess.call(['/usr/bin/loginctl', 'terminate-session', + session.GetId()]) + else: + LogoutUserGnome(session) + + def LockSession(session): # First try to lock in the KDE "standard" interface. Since KDE is # using a session bus, all operations must be execued in the user diff --git a/ovirt-guest-agent/LogoutActiveUser.py b/ovirt-guest-agent/LogoutActiveUser.py new file mode 100755 index 0000000..975c0b2 --- /dev/null +++ b/ovirt-guest-agent/LogoutActiveUser.py @@ -0,0 +1,24 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- +# vim:fenc=utf-8 +# +# Copyright 2014 Vinzenz Feenstra, Red Hat, Inc. and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Refer to the README and COPYING files for full details of the license. +# +from LockActiveSession import LogoutUser + +if __name__ == '__main__': + LogoutUser() diff --git a/ovirt-guest-agent/consoleapps/ovirt-logout b/ovirt-guest-agent/consoleapps/ovirt-logout new file mode 100644 index 0000000..c1dfa7b --- /dev/null +++ b/ovirt-guest-agent/consoleapps/ovirt-logout @@ -0,0 +1 @@ +PROGRAM=/usr/share/ovirt-guest-agent/LogoutActiveUser.py diff --git a/scripts/wrappers/Makefile.am b/scripts/wrappers/Makefile.am index 3d87087..b9b51f1 100644 --- a/scripts/wrappers/Makefile.am +++ b/scripts/wrappers/Makefile.am @@ -1,6 +1,7 @@ EXTRA_DIST = \ ovirt-hibernate-wrapper.sh \ + ovirt-logout-wrapper.sh \ ovirt-locksession-wrapper.sh \ ovirt-shutdown-wrapper.sh \ ovirt-sudo-wrapper.sh \ @@ -14,6 +15,7 @@ sudoscripts_SCRIPTS= \ ovirt-sudo-wrapper.sh \ ovirt-hibernate-wrapper.sh \ + ovirt-logout-wrapper.sh \ ovirt-shutdown-wrapper.sh \ ovirt-locksession-wrapper.sh \ $(NULL) @@ -22,6 +24,7 @@ $(LN_S) -f $(pkgdatadir)/ovirt-sudo-wrapper.sh $(DESTDIR)/$(pkgdatadir)/ovirt-hibernate $(LN_S) -f $(pkgdatadir)/ovirt-sudo-wrapper.sh $(DESTDIR)/$(pkgdatadir)/ovirt-locksession $(LN_S) -f $(pkgdatadir)/ovirt-sudo-wrapper.sh $(DESTDIR)/$(pkgdatadir)/ovirt-shutdown + $(LN_S) -f $(pkgdatadir)/ovirt-sudo-wrapper.sh $(DESTDIR)/$(pkgdatadir)/ovirt-logout endif if INSTALL_USERMODE_SCRIPTS @@ -29,4 +32,5 @@ $(LN_S) -f $(bindir)/consolehelper $(DESTDIR)/$(pkgdatadir)/ovirt-locksession $(LN_S) -f $(bindir)/consolehelper $(DESTDIR)/$(pkgdatadir)/ovirt-shutdown $(LN_S) -f $(bindir)/consolehelper $(DESTDIR)/$(pkgdatadir)/ovirt-hibernate + $(LN_S) -f $(bindir)/consolehelper $(DESTDIR)/$(pkgdatadir)/ovirt-logout endif diff --git a/scripts/wrappers/ovirt-logout-wrapper.sh b/scripts/wrappers/ovirt-logout-wrapper.sh new file mode 100755 index 0000000..e1ed246 --- /dev/null +++ b/scripts/wrappers/ovirt-logout-wrapper.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Copyright (C) 2014 Vinzenz Feenstra, Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Refer to the README and COPYING files for full details of the license. +# + +/usr/share/ovirt-guest-agent/LogoutActiveUser.py $@ &> /dev/null + + -- To view, visit http://gerrit.ovirt.org/35416 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1173dc8cb6c2bd68b5e2a2ba4ad69284b2085171 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-guest-agent Gerrit-Branch: master Gerrit-Owner: Vinzenz Feenstra <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
