From 7c9dbc66d9ab1f3adad29c827fac2d7d3ee05fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 21 Apr 2018 18:39:10 +0200 Subject: [PATCH] polkitAgent: Guard against repeated close() calls We use the close() method to disconnect signal handlers set up in init(), however the handler ID is only valid in the first call in case the method is called more than once. https://gitlab.gnome.org/GNOME/gnome-shell/issues/221 --- js/ui/components/polkitAgent.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js index 316bc2ad1..7a0682c4b 100644 --- a/js/ui/components/polkitAgent.js +++ b/js/ui/components/polkitAgent.js @@ -174,61 +174,63 @@ var AuthenticationDialog = new Lang.Class({ transition: 'linear' }); } else { Tweener.addTween(this._workSpinner.actor, { opacity: 0, time: WORK_SPINNER_ANIMATION_TIME, transition: 'linear', onCompleteScope: this, onComplete() { if (this._workSpinner) this._workSpinner.stop(); } }); } }, performAuthentication() { this.destroySession(); this._session = new PolkitAgent.Session({ identity: this._identityToAuth, cookie: this._cookie }); this._session.connect('completed', this._onSessionCompleted.bind(this)); this._session.connect('request', this._onSessionRequest.bind(this)); this._session.connect('show-error', this._onSessionShowError.bind(this)); this._session.connect('show-info', this._onSessionShowInfo.bind(this)); this._session.initiate(); }, close(timestamp) { this.parent(timestamp); - Main.sessionMode.disconnect(this._sessionUpdatedId); + if (this._sessionUpdatedId) + Main.sessionMode.disconnect(this._sessionUpdatedId); + this._sessionUpdatedId = 0; }, _ensureOpen() { // NOTE: ModalDialog.open() is safe to call if the dialog is // already open - it just returns true without side-effects if (!this.open(global.get_current_time())) { // This can fail if e.g. unable to get input grab // // In an ideal world this wouldn't happen (because the // Shell is in complete control of the session) but that's // just not how things work right now. // // One way to make this happen is by running 'sleep 3; // pkexec bash' and then opening a popup menu. // // We could add retrying if this turns out to be a problem log('polkitAuthenticationAgent: Failed to show modal dialog.' + ' Dismissing authentication request for action-id ' + this.actionId + ' cookie ' + this._cookie); this._emitDone(true); } }, _emitDone(dismissed) { if (!this._doneEmitted) { this._doneEmitted = true; this.emit('done', dismissed); } }, -- 2.16.2