extensionSystem: Allow extensions to run on the login screen

At the moment it's not realy possible to extend the login screen to do
things it doesn't have built-in support for. This means in order
to support niche use cases, those cases have to change the main
code base. For instance, oVirt and Vmware deployments want to be able
to automaticaly log in guest VMs when a user pre-authenticates through a
console on a management host. To support those use cases, we added
code to the login screen directly, even though most machines will never
be associated with oVirt or Vmware management hosts.

We also get requests from e.g. government users that need certain features
at the login screen that wouldn't get used much outside of government
deployments. For instance, we've gotten requests that a machine contains
prominently displays that it has "Top Secret" information.

All of these use cases seem like they would better handled via
extensions that could be installed in the specific deployments. The
problem is extensions only run in the user session, and get
disabled at the login screen automatically.

This commit changes that. Now extensions can specify in their metadata
via a new sessionModes property, which modes that want to run in. For
backward compatibility, if an extension doesn't specify which session
modes it works in, its assumed the extension only works in the user
session.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1967>
This commit is contained in:
Ray Strode 2021-08-28 13:54:39 -04:00 committed by Marge Bot
parent 7e5ee2c282
commit 242cff7abf

View File

@ -73,6 +73,31 @@ var ExtensionManager = class {
return [...this._extensions.keys()];
}
_extensionSupportsSessionMode(uuid) {
let extension = this.lookup(uuid);
if (!extension)
return false;
if (extension.sessionModes.includes(Main.sessionMode.currentMode))
return true;
if (extension.sessionModes.includes(Main.sessionMode.parentMode))
return true;
return false;
}
_sessionModeCanUseExtension(uuid) {
if (!Main.sessionMode.allowExtensions)
return false;
if (!this._extensionSupportsSessionMode(uuid))
return false;
return true;
}
_callExtensionDisable(uuid) {
let extension = this.lookup(uuid);
if (!extension)
@ -132,7 +157,7 @@ var ExtensionManager = class {
}
_callExtensionEnable(uuid) {
if (!Main.sessionMode.allowExtensions)
if (!this._sessionModeCanUseExtension(uuid))
return;
let extension = this.lookup(uuid);
@ -314,6 +339,7 @@ var ExtensionManager = class {
hasPrefs: dir.get_child('prefs.js').query_exists(null),
hasUpdate: false,
canChange: false,
sessionModes: meta['session-modes'] ? meta['session-modes'] : ['user'],
};
this._extensions.set(uuid, extension);
@ -398,7 +424,7 @@ var ExtensionManager = class {
}
_callExtensionInit(uuid) {
if (!Main.sessionMode.allowExtensions)
if (!this._sessionModeCanUseExtension(uuid))
return false;
let extension = this.lookup(uuid);
@ -487,13 +513,15 @@ var ExtensionManager = class {
// Find and enable all the newly enabled extensions: UUIDs found in the
// new setting, but not in the old one.
newEnabledExtensions
.filter(uuid => !this._enabledExtensions.includes(uuid))
.filter(uuid => !this._enabledExtensions.includes(uuid) &&
this._extensionSupportsSessionMode(uuid))
.forEach(uuid => this._callExtensionEnable(uuid));
// Find and disable all the newly disabled extensions: UUIDs found in the
// old setting, but not in the new one.
this._extensionOrder
.filter(uuid => !newEnabledExtensions.includes(uuid))
.filter(uuid => !newEnabledExtensions.includes(uuid) ||
!this._extensionSupportsSessionMode(uuid))
.reverse().forEach(uuid => this._callExtensionDisable(uuid));
this._enabledExtensions = newEnabledExtensions;