Only allow TLS connection and verify certificate - Fixes #78
Certificate is only on python >= 3.4 verified
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.18.3 -->
|
||||||
<interface>
|
<interface>
|
||||||
<!-- interface-requires gtk+ 3.0 -->
|
<requires lib="gtk+" version="3.0"/>
|
||||||
<object class="GtkWindow" id="window1">
|
<object class="GtkWindow" id="window1">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
@@ -65,10 +66,10 @@
|
|||||||
<object class="GtkLabel" id="plugin_name_label1">
|
<object class="GtkLabel" id="plugin_name_label1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="label"><empty></property>
|
<property name="label"><empty></property>
|
||||||
<property name="selectable">True</property>
|
<property name="selectable">True</property>
|
||||||
<property name="ellipsize">end</property>
|
<property name="ellipsize">end</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@@ -97,11 +98,11 @@
|
|||||||
<object class="GtkLabel" id="plugin_authors_label1">
|
<object class="GtkLabel" id="plugin_authors_label1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="xpad">6</property>
|
<property name="xpad">6</property>
|
||||||
<property name="label"><empty></property>
|
<property name="label"><empty></property>
|
||||||
<property name="selectable">True</property>
|
<property name="selectable">True</property>
|
||||||
<property name="ellipsize">end</property>
|
<property name="ellipsize">end</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
@@ -139,7 +140,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_action_appearance">False</property>
|
|
||||||
<property name="relief">none</property>
|
<property name="relief">none</property>
|
||||||
<property name="focus_on_click">False</property>
|
<property name="focus_on_click">False</property>
|
||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
@@ -238,7 +238,6 @@
|
|||||||
<property name="sensitive">False</property>
|
<property name="sensitive">False</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<property name="use_action_appearance">False</property>
|
|
||||||
<signal name="clicked" handler="on_inslall_upgrade_clicked" swapped="no"/>
|
<signal name="clicked" handler="on_inslall_upgrade_clicked" swapped="no"/>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkHBox" id="hbox1">
|
<object class="GtkHBox" id="hbox1">
|
||||||
@@ -260,8 +259,8 @@
|
|||||||
<object class="GtkLabel" id="label1">
|
<object class="GtkLabel" id="label1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="label" translatable="yes">Install/Upgrade</property>
|
<property name="label" translatable="yes">Install/Upgrade</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
@@ -316,8 +315,8 @@
|
|||||||
<object class="GtkLabel" id="label2">
|
<object class="GtkLabel" id="label2">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="label" translatable="yes">Ftp server:</property>
|
<property name="label" translatable="yes">Ftp server:</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
@@ -351,7 +350,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
|
||||||
<property name="focus_on_click">False</property>
|
<property name="focus_on_click">False</property>
|
||||||
<property name="xalign">0.5</property>
|
<property name="xalign">0.5</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
@@ -370,7 +368,6 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="receives_default">False</property>
|
<property name="receives_default">False</property>
|
||||||
<property name="use_action_appearance">False</property>
|
|
||||||
<property name="focus_on_click">False</property>
|
<property name="focus_on_click">False</property>
|
||||||
<property name="xalign">0.5</property>
|
<property name="xalign">0.5</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
@@ -383,23 +380,7 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCheckButton" id="TLS">
|
<placeholder/>
|
||||||
<property name="label" translatable="yes">Use TLS transport</property>
|
|
||||||
<property name="use_action_appearance">False</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="use_action_appearance">False</property>
|
|
||||||
<property name="focus_on_click">False</property>
|
|
||||||
<property name="xalign">0.5</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<signal name="toggled" handler="on_tls_toggled" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[info]
|
[info]
|
||||||
name: Plugin Installer
|
name: Plugin Installer
|
||||||
short_name: plugin_installer
|
short_name: plugin_installer
|
||||||
version: 0.15
|
version: 0.16
|
||||||
description: Install and upgrade plugins from ftp
|
description: Install and upgrade plugins from ftp
|
||||||
authors: Denis Fomin <fominde@gmail.com>
|
authors: Denis Fomin <fominde@gmail.com>
|
||||||
Yann Leboulanger <asterix@lagaule.org>
|
Yann Leboulanger <asterix@lagaule.org>
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ import os
|
|||||||
import fnmatch
|
import fnmatch
|
||||||
import sys
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
|
import ssl
|
||||||
|
import logging
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from plugins import GajimPlugin
|
from plugins import GajimPlugin
|
||||||
@@ -41,6 +43,8 @@ from htmltextview import HtmlTextView
|
|||||||
from dialogs import WarningDialog, HigDialog, YesNoDialog
|
from dialogs import WarningDialog, HigDialog, YesNoDialog
|
||||||
from plugins.gui import GajimPluginConfigDialog
|
from plugins.gui import GajimPluginConfigDialog
|
||||||
|
|
||||||
|
log = logging.getLogger('gajim.plugin_system.plugin_installer')
|
||||||
|
|
||||||
(
|
(
|
||||||
C_PIXBUF,
|
C_PIXBUF,
|
||||||
C_DIR,
|
C_DIR,
|
||||||
@@ -68,8 +72,7 @@ class PluginInstaller(GajimPlugin):
|
|||||||
self.config_dialog = PluginInstallerPluginConfigDialog(self)
|
self.config_dialog = PluginInstallerPluginConfigDialog(self)
|
||||||
self.config_default_values = {'ftp_server': ('ftp.gajim.org', ''),
|
self.config_default_values = {'ftp_server': ('ftp.gajim.org', ''),
|
||||||
'check_update': (True, ''),
|
'check_update': (True, ''),
|
||||||
'check_update_periodically': (True, ''),
|
'check_update_periodically': (True, '')}
|
||||||
'TLS': (True, ''),}
|
|
||||||
self.window = None
|
self.window = None
|
||||||
self.progressbar = None
|
self.progressbar = None
|
||||||
self.available_plugins_model = None
|
self.available_plugins_model = None
|
||||||
@@ -111,13 +114,15 @@ class PluginInstaller(GajimPlugin):
|
|||||||
'\n%s') % plugins_str, on_response_yes=open_update)
|
'\n%s') % plugins_str, on_response_yes=open_update)
|
||||||
|
|
||||||
def ftp_connect(self):
|
def ftp_connect(self):
|
||||||
if sys.version_info[:2] > (2, 6) and self.config['TLS'] :
|
if sys.version_info >= (3, 4):
|
||||||
con = ftplib.FTP_TLS(self.config['ftp_server'])
|
ctx = ssl.create_default_context()
|
||||||
con.login()
|
con = ftplib.FTP_TLS(self.config['ftp_server'], context=ctx)
|
||||||
con.prot_p()
|
log.debug('Plugin Server Cert verified')
|
||||||
else:
|
else:
|
||||||
con = ftplib.FTP(self.config['ftp_server'])
|
con = ftplib.FTP_TLS(self.config['ftp_server'])
|
||||||
con.login()
|
con.login()
|
||||||
|
con.prot_p()
|
||||||
|
|
||||||
return con
|
return con
|
||||||
|
|
||||||
@log_calls('PluginInstallerPlugin')
|
@log_calls('PluginInstallerPlugin')
|
||||||
@@ -612,7 +617,7 @@ class Ftp(threading.Thread):
|
|||||||
|
|
||||||
with zipfile.ZipFile(self.buffer_) as zip_file:
|
with zipfile.ZipFile(self.buffer_) as zip_file:
|
||||||
zip_file.extractall(os.path.join(user_dir))
|
zip_file.extractall(os.path.join(user_dir))
|
||||||
|
|
||||||
self.ftp.quit()
|
self.ftp.quit()
|
||||||
GLib.idle_add(self.window.emit, 'plugin_downloaded', self.remote_dirs)
|
GLib.idle_add(self.window.emit, 'plugin_downloaded', self.remote_dirs)
|
||||||
GLib.source_remove(self.pulse)
|
GLib.source_remove(self.pulse)
|
||||||
@@ -638,7 +643,6 @@ class PluginInstallerPluginConfigDialog(GajimPluginConfigDialog):
|
|||||||
self.plugin.config['check_update'])
|
self.plugin.config['check_update'])
|
||||||
self.xml.get_object('check_update_periodically').set_active(
|
self.xml.get_object('check_update_periodically').set_active(
|
||||||
self.plugin.config['check_update_periodically'])
|
self.plugin.config['check_update_periodically'])
|
||||||
self.xml.get_object('TLS').set_active(self.plugin.config['TLS'])
|
|
||||||
|
|
||||||
def on_hide(self, widget):
|
def on_hide(self, widget):
|
||||||
widget = self.xml.get_object('ftp_server')
|
widget = self.xml.get_object('ftp_server')
|
||||||
@@ -649,6 +653,3 @@ class PluginInstallerPluginConfigDialog(GajimPluginConfigDialog):
|
|||||||
|
|
||||||
def on_check_update_periodically_toggled(self, widget):
|
def on_check_update_periodically_toggled(self, widget):
|
||||||
self.plugin.config['check_update_periodically'] = widget.get_active()
|
self.plugin.config['check_update_periodically'] = widget.get_active()
|
||||||
|
|
||||||
def on_tls_toggled(self, widget):
|
|
||||||
self.plugin.config['TLS'] = widget.get_active()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user