mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
aa63a47bc1
commit
20200f75a0
4 changed files with 19 additions and 4 deletions
2
Makefile
2
Makefile
|
@ -18,5 +18,5 @@ test:
|
|||
mkdir rules
|
||||
make
|
||||
clear
|
||||
xterm -e "python ui/main.py" &
|
||||
xterm -e "python ui/main.py ; read" &
|
||||
sudo ./daemon/daemon
|
||||
|
|
|
@ -19,6 +19,11 @@ class LinuxDesktopParser(threading.Thread):
|
|||
self.daemon = True
|
||||
self.running = False
|
||||
self.apps = {}
|
||||
# some things are just weird
|
||||
self.fixes = {
|
||||
'/opt/google/chrome/chrome': '/opt/google/chrome/google-chrome',
|
||||
'/usr/lib/firefox/firefox': '/usr/lib/firefox/firefox.sh'
|
||||
}
|
||||
|
||||
for desktop_path in DESKTOP_PATHS:
|
||||
if not os.path.exists(desktop_path):
|
||||
|
@ -44,7 +49,7 @@ class LinuxDesktopParser(threading.Thread):
|
|||
if os.path.exists(filename):
|
||||
cmd = filename
|
||||
break
|
||||
|
||||
|
||||
return cmd
|
||||
|
||||
def _parse_desktop_file(self, desktop_path):
|
||||
|
@ -60,11 +65,19 @@ class LinuxDesktopParser(threading.Thread):
|
|||
self.apps[cmd] = (name, icon, desktop_path)
|
||||
# if the command is a symlink, add the real binary too
|
||||
if os.path.islink(cmd):
|
||||
link_to = os.path.abspath(os.readlink(cmd))
|
||||
link_to = os.path.realpath(cmd)
|
||||
if "spotify" in cmd:
|
||||
print "%s -> %s" % (cmd, link_to)
|
||||
self.apps[link_to] = (name, icon, desktop_path)
|
||||
|
||||
def get_info_by_path(self, path):
|
||||
def_name = os.path.basename(path)
|
||||
# apply fixes
|
||||
for orig, to in self.fixes.iteritems():
|
||||
if path == orig:
|
||||
path = to
|
||||
break
|
||||
|
||||
return self.apps.get(path, (def_name, None, None))
|
||||
|
||||
def run(self):
|
||||
|
|
|
@ -80,6 +80,8 @@ class Dialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
icon = QtGui.QIcon().fromTheme(app_icon)
|
||||
pixmap = icon.pixmap(icon.actualSize(QtCore.QSize(48, 48)))
|
||||
self._app_icon_label.setPixmap(pixmap)
|
||||
else:
|
||||
self._app_icon_label.clear()
|
||||
|
||||
self._message_label.setText("<b>%s</b> is connecting to %s on %s port %d" % ( \
|
||||
app_name or con.process_path,
|
||||
|
|
|
@ -25,7 +25,7 @@ class UIServicer(ui_pb2_grpc.UIServicer):
|
|||
|
||||
def AskRule(self, request, context):
|
||||
rule = self.dialog.promptUser(request)
|
||||
print "%s -> %s" % ( request, rule )
|
||||
# print "%s -> %s" % ( request, rule )
|
||||
return rule
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue