From 0de190d81dccc00a709c15378b74f08e4b33eb9b Mon Sep 17 00:00:00 2001
From: vfosterm
VPN Network Manager requires sudo permissions in order to remove the auto-connect script from the Network Manager directory. Please input the sudo Password or run the program with elevated priveledges.
") self.sudo_dialog.exec_() + if not self.sudo_password: # dialog was canceled + return False try: p1 = subprocess.Popen(['echo', self.sudo_password], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) p2 = subprocess.Popen(['sudo', '-S', 'rm', self.network_manager_path + 'auto_connect'], stdin=p1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -759,7 +764,11 @@ def disable_auto_connect(self): elif self.auto_connect_box.isChecked() and self.get_active_vpn() and not self.sudo_password: self.sudo_dialog = self.get_sudo() self.sudo_dialog.exec_() - self.set_auto_connect() + if self.sudo_password: + self.set_auto_connect() + else: + self.auto_connect_box.setChecked(False) + return False def set_kill_switch(self): @@ -794,6 +803,8 @@ def set_kill_switch(self): p6 = subprocess.Popen(['sudo', '-S', 'chmod', '744', self.network_manager_path + 'kill_switch'], stdin=p5.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p5.stdout.close() p6.stdout.close() + self.config['SETTINGS']['kill_switch'] = 'True' + self.write_conf() self.statusbar.showMessage('Kill switch activated', 2000) self.repaint() @@ -805,6 +816,10 @@ def disable_kill_switch(self): self.sudo_dialog = self.get_sudo() self.sudo_dialog.text_label.setText("VPN Network Manager requires sudo permissions in order to remove the kill switch script from the Network Manager directory. Please input the sudo Password or run the program with elevated priveledges.
") self.sudo_dialog.exec_() + + if not self.sudo_password: # dialog was canceled + self.killswitch_btn.setChecked(False) + return False try: p1 = subprocess.Popen(['echo', self.sudo_password], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) p2 = subprocess.Popen(['sudo', '-S', 'rm', self.network_manager_path + 'kill_switch'], stdin=p1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -835,6 +850,19 @@ def disable_kill_switch(self): self.statusbar.showMessage('ERROR disabling kill switch', 2000) self.repaint() + elif self.killswitch_btn.isChecked() and self.get_active_vpn() and self.sudo_password: + self.set_kill_switch() + + elif self.killswitch_btn.isChecked() and self.get_active_vpn() and not self.sudo_password: + self.sudo_dialog = self.get_sudo() + self.sudo_dialog.text_label.setText("VPN Network Manager requires sudo permissions in order to move the kill switch script to the Network Manager directory. Please input the sudo Password or run the program with elevated priveledges.
") + self.sudo_dialog.exec_() + if self.sudo_password: + self.set_kill_switch() + else: + self.killswitch_btn.setChecked(False) + return False + def check_connection_validity(self): if self.server_type_select.currentText() == 'Double VPN': # perhaps add pop up to give user the choice self.connection_type_select.setCurrentIndex(1) # set to TCP @@ -876,8 +904,12 @@ def connect(self): if self.auto_connect_box.isChecked() and not self.sudo_password: # prompt for sudo password self.sudo_dialog = self.get_sudo() self.sudo_dialog.exec_() - self.set_auto_connect() + if self.sudo_password: #valid password exists + self.set_auto_connect() + else: + self.auto_connect_box.setChecked(False) + return False elif self.auto_connect_box.isChecked() and self.sudo_password: # sudo password exists in memory self.set_auto_connect() @@ -893,13 +925,13 @@ def connect(self): self.sudo_dialog = self.get_sudo() self.sudo_dialog.text_label.setText("VPN Network Manager requires sudo permissions in order to move the kill switch script to the Network Manager directory. Please input the sudo Password or run the program with elevated priveledges.
") self.sudo_dialog.exec_() + if not self.sudo_password: # dialog was closed + self.killswitch_btn.setChecked(False) + return False self.set_kill_switch() - self.config['SETTINGS']['kill_switch'] = 'True' - self.write_conf() + elif self.killswitch_btn.isChecked() and self.sudo_password: self.set_kill_switch() - self.config['SETTINGS']['kill_switch'] = 'True' - self.write_conf() if self.get_active_vpn(): # if connection successful self.connect_btn.hide() @@ -908,10 +940,17 @@ def connect(self): def disconnect_vpn(self): if self.killswitch_btn.isChecked(): + self.killswitch_btn.setChecked(False) + self.statusbar.showMessage("Disabling Killswitch...", 5000) + self.repaint() self.disable_kill_switch() + time.sleep(5) + if self.auto_connect_box.isChecked(): + self.auto_connect_box.setChecked(False) + self.statusbar.showMessage("Disabling auto-connect...", 1000) + self.disable_auto_connect() self.disable_connection() - if not self.auto_connect_box.isChecked(): - self.remove_connection() + self.remove_connection() self.statusbar.clearMessage() self.repaint()