loginManager: Get the session ID from logind if XDG_SESSION_ID unset
If we're started by systemd, we won't be in the user's display session. However, this is still the session that will get locked & unlocked. Ask logind what the 'display' or 'greeter' session is, and watch for the Unlock signal for that session to know when to unlock. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/137
This commit is contained in:
parent
0dee82fb9f
commit
22392d1328
@ -40,14 +40,24 @@ const SystemdLoginSessionIface = '<node> \
|
|||||||
<signal name="Lock" /> \
|
<signal name="Lock" /> \
|
||||||
<signal name="Unlock" /> \
|
<signal name="Unlock" /> \
|
||||||
<property name="Active" type="b" access="read" /> \
|
<property name="Active" type="b" access="read" /> \
|
||||||
|
<property name="Class" type="s" access="read" /> \
|
||||||
|
<property name="Id" type="s" access="read" /> \
|
||||||
<method name="SetLockedHint"> \
|
<method name="SetLockedHint"> \
|
||||||
<arg type="b" direction="in"/> \
|
<arg type="b" direction="in"/> \
|
||||||
</method> \
|
</method> \
|
||||||
</interface> \
|
</interface> \
|
||||||
</node>';
|
</node>';
|
||||||
|
|
||||||
|
const SystemdLoginUserIface = '<node> \
|
||||||
|
<interface name="org.freedesktop.login1.User"> \
|
||||||
|
<property name="Display" type="(so)" access="read" /> \
|
||||||
|
<property name="Sessions" type="a(so)" access="read" /> \
|
||||||
|
</interface> \
|
||||||
|
</node>';
|
||||||
|
|
||||||
const SystemdLoginManager = Gio.DBusProxy.makeProxyWrapper(SystemdLoginManagerIface);
|
const SystemdLoginManager = Gio.DBusProxy.makeProxyWrapper(SystemdLoginManagerIface);
|
||||||
const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
|
const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
|
||||||
|
const SystemdLoginUser = Gio.DBusProxy.makeProxyWrapper(SystemdLoginUserIface);
|
||||||
|
|
||||||
function haveSystemd() {
|
function haveSystemd() {
|
||||||
return GLib.access("/run/systemd/seats", 0) >= 0;
|
return GLib.access("/run/systemd/seats", 0) >= 0;
|
||||||
@ -109,6 +119,9 @@ var LoginManagerSystemd = new Lang.Class({
|
|||||||
this._proxy = new SystemdLoginManager(Gio.DBus.system,
|
this._proxy = new SystemdLoginManager(Gio.DBus.system,
|
||||||
'org.freedesktop.login1',
|
'org.freedesktop.login1',
|
||||||
'/org/freedesktop/login1');
|
'/org/freedesktop/login1');
|
||||||
|
this._userProxy = new SystemdLoginUser(Gio.DBus.system,
|
||||||
|
'org.freedesktop.login1',
|
||||||
|
'/org/freedesktop/login1/user/self');
|
||||||
this._proxy.connectSignal('PrepareForSleep',
|
this._proxy.connectSignal('PrepareForSleep',
|
||||||
this._prepareForSleep.bind(this));
|
this._prepareForSleep.bind(this));
|
||||||
},
|
},
|
||||||
@ -121,8 +134,31 @@ var LoginManagerSystemd = new Lang.Class({
|
|||||||
|
|
||||||
let sessionId = GLib.getenv('XDG_SESSION_ID');
|
let sessionId = GLib.getenv('XDG_SESSION_ID');
|
||||||
if (!sessionId) {
|
if (!sessionId) {
|
||||||
log('Unset XDG_SESSION_ID, getCurrentSessionProxy() called outside a user session.');
|
log('Unset XDG_SESSION_ID, getCurrentSessionProxy() called outside a user session. Asking logind directly.');
|
||||||
return;
|
let [session, objectPath] = this._userProxy.Display;
|
||||||
|
if (session) {
|
||||||
|
log(`Will monitor session ${session}`);
|
||||||
|
sessionId = session;
|
||||||
|
} else {
|
||||||
|
log('Failed to find "Display" session; are we the greeter?');
|
||||||
|
|
||||||
|
for (let [session, objectPath] of this._userProxy.Sessions) {
|
||||||
|
let sessionProxy = new SystemdLoginSession(Gio.DBus.system,
|
||||||
|
'org.freedesktop.login1',
|
||||||
|
objectPath);
|
||||||
|
log(`Considering ${session}, class=${sessionProxy.Class}`);
|
||||||
|
if (sessionProxy.Class == 'greeter') {
|
||||||
|
log(`Yes, will monitor session ${session}`);
|
||||||
|
sessionId = session;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sessionId) {
|
||||||
|
log('No, failed to get session from logind.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._proxy.GetSessionRemote(sessionId, (result, error) => {
|
this._proxy.GetSessionRemote(sessionId, (result, error) => {
|
||||||
|
@ -697,7 +697,14 @@ var EndSessionDialog = new Lang.Class({
|
|||||||
if (proxy.State == 'closing')
|
if (proxy.State == 'closing')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (proxy.Id == GLib.getenv('XDG_SESSION_ID'))
|
let sessionId = GLib.getenv('XDG_SESSION_ID');
|
||||||
|
if (!sessionId)
|
||||||
|
this._loginManager.getCurrentSessionProxy(currentSessionProxy => {
|
||||||
|
sessionId = currentSessionProxy.Id;
|
||||||
|
log(`endSessionDialog: No XDG_SESSION_ID, fetched from logind: ${sessionId}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (proxy.Id == sessionId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
let session = { user: this._userManager.get_user(userName),
|
let session = { user: this._userManager.get_user(userName),
|
||||||
|
Loading…
Reference in New Issue
Block a user