From c2ae98209d0330295203eee5491095178672a177 Mon Sep 17 00:00:00 2001 From: Adel Gadllah Date: Wed, 23 Apr 2014 08:52:37 +0200 Subject: [PATCH] networkAgent: Handle empty vpn 'keyfiles' Passing back no data is valid in case both secrets (group and user passwords) are stored. Just confirm the request in that case. https://bugzilla.gnome.org/show_bug.cgi?id=728681 --- js/ui/components/networkAgent.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/ui/components/networkAgent.js b/js/ui/components/networkAgent.js index 66c462817..181aa77c1 100644 --- a/js/ui/components/networkAgent.js +++ b/js/ui/components/networkAgent.js @@ -510,10 +510,12 @@ const VPNRequestHandler = new Lang.Class({ _showNewStyleDialog: function() { let keyfile = new GLib.KeyFile(); + let data; let contentOverride; try { - let data = this._dataStdout.peek_buffer(); + data = this._dataStdout.peek_buffer(); + keyfile.load_from_data(data.toString(), data.length, GLib.KeyFileFlags.NONE); @@ -546,13 +548,16 @@ const VPNRequestHandler = new Lang.Class({ } } } catch(e) { - logError(e, 'error while reading VPN plugin output keyfile'); + // No output is a valid case it means "both secrets are stored" + if (data.length > 0) { + logError(e, 'error while reading VPN plugin output keyfile'); - this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR); - return; + this._agent.respond(this._requestId, Shell.NetworkAgentResponse.INTERNAL_ERROR); + return; + } } - if (contentOverride.secrets.length) { + if (contentOverride && contentOverride.secrets.length) { // Only show the dialog if we actually have something to ask this._shellDialog = new NetworkSecretDialog(this._agent, this._requestId, this._connection, 'vpn', [], contentOverride); this._shellDialog.open(global.get_current_time());