From 66183a1b24797b8aabc86053505d5fd115ffd988 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Fri, 13 Jun 2014 13:22:34 -0500 Subject: remove unneeded exec bit --- src/leap/bitmask/util/pastebin.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/leap/bitmask/util/pastebin.py (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/util/pastebin.py b/src/leap/bitmask/util/pastebin.py old mode 100755 new mode 100644 -- cgit v1.2.3 From 9dd06067e6bfa475c633a1edcae8d3c318b9f0f5 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Mon, 16 Jun 2014 18:50:09 -0500 Subject: use absolute paths --- src/leap/bitmask/platform_init/initializers.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/platform_init/initializers.py b/src/leap/bitmask/platform_init/initializers.py index 79fdd554..859e7fe6 100644 --- a/src/leap/bitmask/platform_init/initializers.py +++ b/src/leap/bitmask/platform_init/initializers.py @@ -248,13 +248,13 @@ def _darwin_install_missing_scripts(badexec, notfound): # We expect to execute this from some way of bundle, since # the up/down scripts should be put in place by the installer. success = False - installer_path = os.path.join( - os.getcwd(), - "..", - "Resources", - "openvpn") + installer_path = os.path.abspath( + os.path.join( + os.getcwd(), "..", "Resources", "openvpn")) launcher = DarwinVPNLauncher + + # XXX FIXME !!! call the bash script! if os.path.isdir(installer_path): fd, tempscript = tempfile.mkstemp(prefix="leap_installer-") try: @@ -397,12 +397,15 @@ def _linux_install_missing_scripts(badexec, notfound): :rtype: bool """ success = False - installer_path = os.path.join(os.getcwd(), "apps", "eip", "files") + installer_path = os.path.abspath( + os.path.join(os.getcwd(), "apps", "eip", "files")) launcher = LinuxVPNLauncher # XXX refactor with darwin, same block. if os.path.isdir(installer_path): + + # FIXME --------- call installer script --- fd, tempscript = tempfile.mkstemp(prefix="leap_installer-") polfd, pol_tempfile = tempfile.mkstemp(prefix="leap_installer-") try: -- cgit v1.2.3 From 89d126e96b1ed3ac1076b3c45129f8bc78a09700 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 17 Jun 2014 11:25:11 -0500 Subject: use bash installer instead of the temporal script --- src/leap/bitmask/platform_init/initializers.py | 28 ++++++++------------------ 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/platform_init/initializers.py b/src/leap/bitmask/platform_init/initializers.py index 859e7fe6..b7946c4c 100644 --- a/src/leap/bitmask/platform_init/initializers.py +++ b/src/leap/bitmask/platform_init/initializers.py @@ -401,39 +401,27 @@ def _linux_install_missing_scripts(badexec, notfound): os.path.join(os.getcwd(), "apps", "eip", "files")) launcher = LinuxVPNLauncher - # XXX refactor with darwin, same block. + install_helper = "linux-install-helper.sh" + install_helper_path = os.path.join(installer_path, install_helper) - if os.path.isdir(installer_path): + install_opts = ("--from-path %s --install-bitmask-root YES" + "--install-polkit-file YES --install-openvpn YES" % ( + installer_path,)) - # FIXME --------- call installer script --- - fd, tempscript = tempfile.mkstemp(prefix="leap_installer-") - polfd, pol_tempfile = tempfile.mkstemp(prefix="leap_installer-") + if os.path.isdir(installer_path): try: pkexec = first(launcher.maybe_pkexec()) - - scriptlines = launcher.cmd_for_missing_scripts(installer_path) - with os.fdopen(fd, 'w') as f: - f.write(scriptlines) - - st = os.stat(tempscript) - os.chmod(tempscript, st.st_mode | stat.S_IEXEC | stat.S_IXUSR | - stat.S_IXGRP | stat.S_IXOTH) - cmdline = ["%s %s" % (pkexec, tempscript)] + cmdline = ["%s %s" % (pkexec, install_helper_path, install_opts)] ret = subprocess.call( cmdline, stdout=subprocess.PIPE, shell=True) success = ret == 0 if not success: - logger.error("Install missing scripts failed.") + logger.error("Install of helpers failed.") except Exception as exc: logger.error(badexec) logger.error("Error was: %r" % (exc,)) - finally: - try: - os.remove(tempscript) - except OSError as exc: - logger.error("%r" % (exc,)) else: logger.error(notfound) logger.debug('path searched: %s' % (installer_path,)) -- cgit v1.2.3 From 7b128df99a9729a4b2f16bd92173d9373183e4c9 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 17 Jun 2014 13:12:41 -0500 Subject: add dialog to inform of missing helpers w/o installing them --- src/leap/bitmask/platform_init/initializers.py | 98 +++++++++++++++++++++----- 1 file changed, 81 insertions(+), 17 deletions(-) (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/platform_init/initializers.py b/src/leap/bitmask/platform_init/initializers.py index b7946c4c..8dae21bf 100644 --- a/src/leap/bitmask/platform_init/initializers.py +++ b/src/leap/bitmask/platform_init/initializers.py @@ -25,8 +25,9 @@ import sys import subprocess import tempfile -from PySide import QtGui +from PySide import QtGui, QtCore +from leap.bitmask.config import flags from leap.bitmask.config.leapsettings import LeapSettings from leap.bitmask.services.eip import get_vpn_launcher from leap.bitmask.services.eip.linuxvpnlauncher import LinuxVPNLauncher @@ -76,9 +77,9 @@ HELPERS_BADEXEC_MSG = BADEXEC_MSG % ( "helper files", "they", "be copied") -def get_missing_updown_dialog(): +def get_missing_helpers_dialog(): """ - Create a dialog for notifying of missing updown scripts. + Create a dialog for notifying of missing helpers. Returns that dialog. :rtype: QtGui.QMessageBox instance @@ -104,14 +105,25 @@ def check_missing(): raises a dialog to ask user for permission to do it. """ config = LeapSettings() + complain_missing = False alert_missing = config.get_alert_missing_scripts() + if alert_missing and not flags.STANDALONE: + # We refuse to install missing stuff if not running with standalone + # flag. Right now we rely on the flag alone, but we can disable this + # by overwriting some constant from within the debian package. + alert_missing = False + complain_missing = True + launcher = get_vpn_launcher() missing_scripts = launcher.missing_updown_scripts missing_other = launcher.missing_other_files - if alert_missing and (missing_scripts() or missing_other()): - msg = get_missing_updown_dialog() + logger.debug("MISSING OTHER: %s" % (str(missing_other()))) + + missing_some = missing_scripts() or missing_other() + if alert_missing and missing_some: + msg = get_missing_helpers_dialog() ret = msg.exec_() if ret == QtGui.QMessageBox.Yes: @@ -123,8 +135,6 @@ def check_missing(): "Installer not found for platform %s." % (_system,)) return - print "INSTALL FUN", install_missing_fun - # XXX maybe move constants to fun ok = install_missing_fun(HELPERS_BADEXEC_MSG, HELPERS_NOTFOUND_MSG) if not ok: @@ -143,6 +153,12 @@ def check_missing(): "Setting alert_missing_scripts to False, we will not " "ask again") config.set_alert_missing_scripts(False) + + if complain_missing and missing_some: + missing = missing_scripts() + missing_other() + msg = _get_missing_complain_dialog(missing) + ret = msg.exec_() + # # windows initializers # @@ -253,7 +269,6 @@ def _darwin_install_missing_scripts(badexec, notfound): os.getcwd(), "..", "Resources", "openvpn")) launcher = DarwinVPNLauncher - # XXX FIXME !!! call the bash script! if os.path.isdir(installer_path): fd, tempscript = tempfile.mkstemp(prefix="leap_installer-") @@ -352,24 +367,72 @@ def _get_missing_resolvconf_dialog(): :rtype: QtGui.QMessageBox instance """ - NO_RESOLVCONF = ( + msgstr = QtCore.QObject() + msgstr.NO_RESOLVCONF = msgstr.tr( "Could not find resolvconf installed in your system.\n" "Do you want to quit Bitmask now?") - EXPLAIN = ( + msgstr.EXPLAIN = msgstr.tr( "Encrypted Internet needs resolvconf installed to work properly.\n" "Please use your package manager to install it.\n") msg = QtGui.QMessageBox() msg.setWindowTitle(msg.tr("Missing resolvconf framework")) - msg.setText(msg.tr(NO_RESOLVCONF)) + msg.setText(msgstr.NO_RESOLVCONF) # but maybe the user really deserve to know more - msg.setInformativeText(msg.tr(EXPLAIN)) + msg.setInformativeText(msgstr.EXPLAIN) msg.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) msg.setDefaultButton(QtGui.QMessageBox.Yes) return msg +def _get_missing_complain_dialog(stuff): + """ + Create a dialog for notifying about missing helpers (but doing nothing). + Used from non-standalone runs. + + :param stuff: list of missing items to display + :type stuff: list + :rtype: QtGui.QMessageBox instance + """ + msgstr = QtCore.QObject() + msgstr.NO_HELPERS = msgstr.tr( + "Some essential helper files are missing in your system.") + msgstr.EXPLAIN = msgstr.tr( + "Reinstall your debian packages, or make sure you place them by hand.") + + class ComplainDialog(QtGui.QDialog): + + def __init__(self, parent=None): + super(ComplainDialog, self).__init__(parent) + + label = QtGui.QLabel(msgstr.NO_HELPERS) + label.setAlignment(QtCore.Qt.AlignLeft) + + label2 = QtGui.QLabel(msgstr.EXPLAIN) + label2.setAlignment(QtCore.Qt.AlignLeft) + + textedit = QtGui.QTextEdit() + textedit.setText("\n".join(stuff)) + + ok = QtGui.QPushButton() + ok.setText(self.tr("Ok, thanks")) + self.ok = ok + self.ok.clicked.connect(self.close) + + mainLayout = QtGui.QGridLayout() + mainLayout.addWidget(label, 0, 0) + mainLayout.addWidget(label2, 1, 0) + mainLayout.addWidget(textedit, 2, 0) + mainLayout.addWidget(ok, 3, 0) + + self.setLayout(mainLayout) + + msg = ComplainDialog() + msg.setWindowTitle(msg.tr("Missing Bitmask helpers")) + return msg + + def _linux_check_resolvconf(): """ Raise a dialog warning about the lack of the resolvconf framework. @@ -401,17 +464,18 @@ def _linux_install_missing_scripts(badexec, notfound): os.path.join(os.getcwd(), "apps", "eip", "files")) launcher = LinuxVPNLauncher - install_helper = "linux-install-helper.sh" + install_helper = "leap-install-helper.sh" install_helper_path = os.path.join(installer_path, install_helper) - install_opts = ("--from-path %s --install-bitmask-root YES" - "--install-polkit-file YES --install-openvpn YES" % ( - installer_path,)) + install_opts = ("--from-path %s --install-bitmask-root YES " + "--install-polkit-file YES --install-openvpn YES " + "--remove-old-files YES" % (installer_path,)) if os.path.isdir(installer_path): try: pkexec = first(launcher.maybe_pkexec()) - cmdline = ["%s %s" % (pkexec, install_helper_path, install_opts)] + cmdline = ["%s %s %s" % ( + pkexec, install_helper_path, install_opts)] ret = subprocess.call( cmdline, stdout=subprocess.PIPE, -- cgit v1.2.3