gdm/util: Keep track of started services that are currently active

If we have a late activation of a service backend we may need to check
whether it has been already started, and in case it has not, we can try
loading it.

So rely on gdm to see what service has been started, instead of handling
it manually on our side only.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2267>
This commit is contained in:
Marco Trevisan (Treviño) 2022-10-21 17:47:15 +02:00
parent f1c0f65075
commit 9af029e968

View File

@ -112,6 +112,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
this._messageQueueTimeoutId = 0; this._messageQueueTimeoutId = 0;
this._failCounter = 0; this._failCounter = 0;
this._activeServices = new Set();
this._unavailableServices = new Set(); this._unavailableServices = new Set();
this._credentialManagers = {}; this._credentialManagers = {};
@ -228,6 +229,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
this._clearUserVerifier(); this._clearUserVerifier();
this._clearMessageQueue(); this._clearMessageQueue();
this._activeServices.clear();
} }
destroy() { destroy() {
@ -469,6 +471,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
'problem', this._onProblem.bind(this), 'problem', this._onProblem.bind(this),
'info-query', this._onInfoQuery.bind(this), 'info-query', this._onInfoQuery.bind(this),
'secret-info-query', this._onSecretInfoQuery.bind(this), 'secret-info-query', this._onSecretInfoQuery.bind(this),
'conversation-started', this._onConversationStarted.bind(this),
'conversation-stopped', this._onConversationStopped.bind(this), 'conversation-stopped', this._onConversationStopped.bind(this),
'service-unavailable', this._onServiceUnavailable.bind(this), 'service-unavailable', this._onServiceUnavailable.bind(this),
'reset', this._onReset.bind(this), 'reset', this._onReset.bind(this),
@ -532,6 +535,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
async _startService(serviceName) { async _startService(serviceName) {
this._hold.acquire(); this._hold.acquire();
try { try {
this._activeServices.add(serviceName);
if (this._userName) { if (this._userName) {
await this._userVerifier.call_begin_verification_for_user( await this._userVerifier.call_begin_verification_for_user(
serviceName, this._userName, this._cancellable); serviceName, this._userName, this._cancellable);
@ -540,6 +544,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
serviceName, this._cancellable); serviceName, this._cancellable);
} }
} catch (e) { } catch (e) {
this._activeServices.delete(serviceName);
if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
return; return;
if (!this.serviceIsForeground(serviceName)) { if (!this.serviceIsForeground(serviceName)) {
@ -657,6 +662,7 @@ export class ShellUserVerifier extends Signals.EventEmitter {
_onReset() { _onReset() {
// Clear previous attempts to authenticate // Clear previous attempts to authenticate
this._failCounter = 0; this._failCounter = 0;
this._activeServices.clear();
this._unavailableServices.clear(); this._unavailableServices.clear();
this._updateDefaultService(); this._updateDefaultService();
@ -739,7 +745,13 @@ export class ShellUserVerifier extends Signals.EventEmitter {
this._queueMessage(serviceName, errorMessage, MessageType.ERROR); this._queueMessage(serviceName, errorMessage, MessageType.ERROR);
} }
_onConversationStarted(client, serviceName) {
this._activeServices.add(serviceName);
}
_onConversationStopped(client, serviceName) { _onConversationStopped(client, serviceName) {
this._activeServices.delete(serviceName);
// If the login failed with the preauthenticated oVirt credentials // If the login failed with the preauthenticated oVirt credentials
// then discard the credentials and revert to default authentication // then discard the credentials and revert to default authentication
// mechanism. // mechanism.