This file is indexed.

/usr/share/gnome-shell/extensions/disconnect-wifi@kgshank.net/extension.js is in gnome-shell-extension-disconnect-wifi 17-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/******************************************************************************
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Orignal Author: Gopi Sankar Karmegam
******************************************************************************/

/* Ugly. This is here so that we don't crash old libnm-glib based shells unnecessarily
 * by loading the new libnm.so. Should go away eventually */
const libnm_glib = imports.gi.GIRepository.Repository.get_default().is_registered("NMClient", "1.0");

const Lang = imports.lang;
const Main = imports.ui.main;
const NM = libnm_glib ? imports.gi.NetworkManager : imports.gi.NM;
const Mainloop = imports.mainloop;

const Me = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const SignalManager = Convenience.SignalManager;

const Gettext = imports.gettext.domain('disconnect-wifi');
const _ = Gettext.gettext;

function init() {
    Convenience.initTranslations("disconnect-wifi");
}

const RECONNECT_TEXT = "Reconnect"
const SPACE = " ";

const WifiDisconnector = new Lang.Class({
    Name : 'WifiDisconnector',
    _init : function() {
        this._nAttempts = 0;
        this._signalManager = new SignalManager();
        this._activeConnections = {};
        this._accessPoints = {};
        this._checkDevices();
    },
    
    _checkDevices : function() {
    	if(this._timeoutId){
           Mainloop.source_remove(this._timeoutId);
           this._timeoutId = null;
        }
    	this._network = Main.panel.statusArea.aggregateMenu._network;
        if (this._network) {
            if (!this._network._client || (libnm_glib && !this._network._settings)) {
                // Shell not initialised completely wait for max of
                // 100 * 1 sec
                if (this._nAttempts++ < 100) {
                    this._timeoutId = Mainloop.timeout_add(1000, Lang.bind(this,
                            this._checkDevices));
                }
            } else {
                this._client = this._network._client;
                if (libnm_glib)
                    this._settings = this._network._settings;

                for (let device of this._network._nmDevices) {
                	this._deviceAdded(this._client, device);
                }
                this._signalManager.addSignal(this._client, 'device-added', 
                		Lang.bind(this, this._deviceAdded));
                this._signalManager.addSignal(this._client, 'device-removed', 
                		Lang.bind(this, this._deviceRemoved));
            }
        }
    },
    
    _deviceAdded : function(client, device) {
    	if (device.get_device_type() != NM.DeviceType.WIFI) {
            return;
        }
        if(device.active_connection) {
    		this._activeConnections[device] = device.active_connection;
    	}
        
        if(device.active_access_point) {
    		this._accessPoints[device] = device.active_access_point;
    	}
        this._addAllMenus(device);
    },
    
    _addAllMenus : function(device) {
    	if (device)
    	{
    		if (!device._delegate) {
    			if(!device.timeout) {
	    			device.timeout = Mainloop.timeout_add(1000, Lang.bind(this, function() {
	                    return this._addAllMenus(device);
	                }));
	                return true;
    			} else {
    				return true;
    			}
            }
    		
    		if(device.timeout) {
    			Mainloop.source_remove(device.timeout);
    			device.timeout = null;
    		}
    			
    		let wrapper = device._delegate;
        
	        if (!wrapper.disconnectItem) {
	            wrapper.disconnectItem 
	        		= wrapper.item.menu.addAction(_("Disconnect"), 
	                            function() {
	                                device.disconnect(null);
	                            });
	            wrapper.item.menu.moveMenuItem(wrapper.disconnectItem,2);
	        }
	        wrapper.disconnectItem.actor.visible = false;
	        
	        if (!wrapper.reconnectItem) {
	         	wrapper.reconnectItem
                    = wrapper.item.menu.addAction("", 
                            Lang.bind(this, function() {
                                this._reconnect(device);
                            }));
	         	wrapper.item.menu.moveMenuItem(wrapper.reconnectItem,3);
	        }
	        this._stateChanged(device, device.state, device.state, null);   
	        
	        this._signalManager.addSignal(device, 'state-changed', Lang.bind(this, this._stateChanged));	        
    	}
    	return false;
    },

    _reconnect : function(device) {
    	let _activeConnection = this._activeConnections[device];

        if (libnm_glib) {
            if (_activeConnection) {
                this._client.activate_connection(
                    this._settings.get_connection_by_path(_activeConnection.connection),
                         device,null,null);
            } else {
                this._client.activate_connection(null,device,null,null);
            }
        } else {
            if (_activeConnection) {
                this._client.activate_connection_async(_activeConnection.connection.path,device,null,null,null);
            } else {
                this._client.activate_connection_async(null,device,null,null,null);
            }
        }
    },

    _stateChanged :  function(device, newstate, oldstate, reason) {
    	if (device.get_device_type() != NM.DeviceType.WIFI) {
            return;
        }
    	
    	if(device.active_connection) {
    		this._activeConnections[device] = device.active_connection;
    	}
    	
    	if(device.active_access_point) {
    		this._accessPoints[device] = device.active_access_point;
    	}
    	
    	if (!device._delegate) {
    		return;
    	}
    	
    	let wrapper = device._delegate;
    	if (wrapper.disconnectItem) {
    		wrapper.disconnectItem.actor.visible 
    			= newstate > NM.DeviceState.DISCONNECTED;
    	}
    	
    	if (wrapper.reconnectItem) {
    	    wrapper.reconnectItem.actor.visible 
                    = (newstate == NM.DeviceState.DISCONNECTED) 
                         && (this._activeConnections[device] != null);
            
           let accessPoint = this._accessPoints[device];
            wrapper.reconnectItem.label.text = 
                    (accessPoint) ?  _(RECONNECT_TEXT) + SPACE 
                    + imports.ui.status.network.ssidToLabel(accessPoint.get_ssid()) : _(RECONNECT_TEXT) ;
        }
     },
        
    _deviceRemoved : function(client, device) {
    	if (device.get_device_type() != NM.DeviceType.WIFI) {
            return;
        }
        if(this._activeConnections && this._activeConnections[device]) {
        	this._activeConnections[device] = null;
        }
    	
    	if(this._accessPoints && this._accessPoints[device]) {
    		this._accessPoints[device] = null;
    	}
        
        if (!device._delegate) {
    		return;
    	}
    	
    	let wrapper = device._delegate;
        if (wrapper.disconnectItem) {
        	wrapper.disconnectItem.destroy();
        	wrapper.disconnectItem = null;
        }

        if (wrapper.reconnectItem) {
            wrapper.reconnectItem.destroy();
            wrapper.reconnectItem = null;
        }
        
        this._signalManager.disconnectBySource(device);
    },

    destroy : function() {
        if (this._network && this._network._nmDevices) {
            this._network._nmDevices.forEach(function(device){
                this._deviceRemoved(this._client, device);
            }, this);
        }
        this._signalManager.disconnectAll();
    }
});

let _instance;
function enable() {
    _instance = new WifiDisconnector();
}

function disable() {
    _instance.destroy();
    _instance = null;
}