Liebe Menschen,
vielleicht kann ja jemand (der eine Bridge oder ein Relay betreibt) meine Apparmor-Konfiguration für Tor gebrauchen. Wenn man Transport-Plugins verwenden möchte, muss man zunächst im Verzeichnis /lib/systemd/system die Dateien tor@default.service und tor@.service anpassen. Wenn diese erste Änderung durch ein Update rückgängig gemacht wird, ist dies bis auf Weiteres der wahrscheinlichste Grund dafür, dass die Transport-Plugins mit Apparmor nicht funktionieren. Hier also im Fehlerfall zuerst nachsehen.
Aus
1 | NoNewPrivileges=yes |
macht man
1 | NoNewPrivileges=no |
Dadurch können für die Transport-Plugins eigene Profile erstellt werden, ohne Tor selbst alles mögliche zu erlauben, was es gar nicht braucht. Ohne diese Änderung können die Transport-Plugins nur als "ux", also ungeschützt, oder "ix" mit einem globalgalaktisch ausgeuferten Profil betrieben werden.
Der Vollständigkeit halber hier das mitgelieferte Profil system_tor in /etc/apparmor.d/:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <tunables/global> # vim:syntax=apparmor profile system_tor flags=(attach_disconnected) { #include <abstractions/tor> #include <local/system_tor> owner /var/lib/tor/ r, owner /var/lib/tor/** wk, /var/lib/tor/** r, owner /var/log/tor/* w, /{,var/}run/systemd/notify w, /{,var/}run/tor/ r, /{,var/}run/tor/control w, /{,var/}run/tor/control.authcookie w, /{,var/}run/tor/control.authcookie.tmp rw, /{,var/}run/tor/socks w, /{,var/}run/tor/tor.pid w, } |
Unter /etc/apparmor.d/local/ ergänzen wir in system_tor folgendes:
1 2 3 4 5 | # Site-specific additions and overrides for system_tor. # For more details, please see /etc/apparmor.d/local/README. signal send set=term peer=/usr/bin/obfs4proxy, signal send set=kill peer=/usr/bin/obfs4proxy, |
und gucken, ob unter /etc/apparmor.d/abstractions in tor alles gut ist:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # vim:syntax=apparmor #include <abstractions/base> #include <abstractions/nameservice> network tcp, network udp, capability chown, capability dac_read_search, capability fowner, capability fsetid, capability setgid, capability setuid, /usr/bin/tor r, /usr/sbin/tor r, # Needed by obfs4proxy /proc/sys/net/core/somaxconn r, /proc/sys/kernel/random/uuid r, /sys/devices/system/cpu/ r, /sys/devices/system/cpu/** r, /etc/tor/* r, /usr/share/tor/** r, /usr/bin/obfsproxy PUx, #Das hier ist der /usr/bin/obfs4proxy Pix, #wichtige Teil |
Dann machen wir unter /etc/apparmor.d/ ein Profil /usr.bin.obfsproxy und unter /etc/apparmor.d/local eine leere Datei usr.bin.obfsproxy für überdauernde manuelle Anpassungen:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # Last Modified: Mon Nov 13 01:33:26 2017 #include <tunables/global> /usr/bin/obfsproxy { #include <abstractions/base> #include <abstractions/nameservice> #include <abstractions/python> #include <local/usr.bin.obfsproxy> /bin/dash Cx, /etc/apt/apt.conf.d/ r, /etc/default/apport r, /proc/*/mounts r, /proc/*/status r, /sbin/ldconfig Cx, /tmp/* rw, /usr/bin/ r, /usr/bin/obfsproxy r, /usr/bin/python2.7 r, /var/lib/tor/extended_orport_auth_cookie r, /var/lib/tor/pt_state/scramblesuit/ w, /var/lib/tor/pt_state/scramblesuit/* rw, /var/tmp/* rw, profile /bin/dash { #include <abstractions/base> /bin/dash mr, /sbin/ldconfig Cx, /usr/bin/gcc-5 Cx, } profile /sbin/ldconfig { #include <abstractions/base> #include <abstractions/bash> /bin/dash rix, /sbin/ldconfig r, /sbin/ldconfig.real Cx, } profile /sbin/ldconfig.real { #include <abstractions/base> /sbin/ldconfig.real mr, } profile /usr/bin/gcc-5 { #include <abstractions/base> /usr/bin/gcc-5 mr, } } |
Jetzt noch ein kleines Profil usr.bin.obfs4proxy unter /etc/apparmor.d/ und alles wird gut:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Last Modified: Sun Nov 12 01:53:16 2017 #include <tunables/global> /usr/bin/obfs4proxy { #include <abstractions/base> network inet stream, network inet6 stream, signal receive set=term peer=system_tor, signal receive set=kill peer=system_tor, /proc/sys/net/core/somaxconn r, /usr/bin/obfs4proxy mr, /var/lib/tor/pt_state/ w, /var/lib/tor/pt_state/obfs4_bridgeline.txt w, /var/lib/tor/pt_state/obfs4_state.json rw, } |
Voilà. Alles wurde gut. Und bitte nicht vergessen: sollte in den Logs von Tor beim Start der Transport-Plugins "permission denied" vermerkt sein, muss man wahrscheinlich nur erneut die Zeile
1 | NoNewPrivileges=no |
in tor@default.service und tor@.service unter /lib/systemd/system kontrollieren und sicherstellen.
Viele Grüße!
Moderiert von kb:
Verschoben.