diff --git a/ui/opensnitch/dialogs/prompt/__init__.py b/ui/opensnitch/dialogs/prompt/__init__.py index eb4325d8..e11ceb9b 100644 --- a/ui/opensnitch/dialogs/prompt/__init__.py +++ b/ui/opensnitch/dialogs/prompt/__init__.py @@ -419,10 +419,7 @@ class PromptDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]): self._default_action = self._cfg.getInt(self._cfg.DEFAULT_ACTION_KEY) _utils.set_default_duration(self._cfg, self.durationCombo) - if int(con.process_id) > 0 and app_name != "" and app_args != "": - self.whatCombo.setCurrentIndex(int(self._cfg.getSettings(self._cfg.DEFAULT_TARGET_KEY))) - else: - self.whatCombo.setCurrentIndex(2) + _utils.set_default_target(self.whatCombo, con, self._cfg, app_name, app_args) self.checkDstIP.setChecked(self._cfg.getBool(self._cfg.DEFAULT_POPUP_ADVANCED_DSTIP)) self.checkDstPort.setChecked(self._cfg.getBool(self._cfg.DEFAULT_POPUP_ADVANCED_DSTPORT)) diff --git a/ui/opensnitch/dialogs/prompt/_utils.py b/ui/opensnitch/dialogs/prompt/_utils.py index 8db31c1b..972f0e90 100644 --- a/ui/opensnitch/dialogs/prompt/_utils.py +++ b/ui/opensnitch/dialogs/prompt/_utils.py @@ -119,6 +119,20 @@ def set_default_duration(cfg, durationCombo): else: durationCombo.setCurrentIndex(Config.DEFAULT_DURATION_IDX) +def set_default_target(combo, con, cfg, app_name, app_args): + # set appimage as default target if the process path starts with + # /tmp/._mount + if con.process_path.startswith(_constants.APPIMAGE_PREFIX): + idx = combo.findData(_constants.FIELD_APPIMAGE) + if idx != -1: + combo.setCurrentIndex(idx) + return + + if int(con.process_id) > 0 and app_name != "" and app_args != "": + combo.setCurrentIndex(int(cfg.getSettings(cfg.DEFAULT_TARGET_KEY))) + else: + combo.setCurrentIndex(2) + def get_combo_operator(data, comboText, con): if data == _constants.FIELD_PROC_PATH: return Config.RULE_TYPE_SIMPLE, Config.OPERAND_PROCESS_PATH, con.process_path