-
Install AppArmor support if it's not already installed:
sudo apt-get install apparmor-utils
-
Disable AppArmor:
Before you can create a custom profile, you need to disable AppArmor to prevent it from enforcing policies.
sudo systemctl stop apparmor.service
sudo systemctl disable apparmor.service
-
Create an AppArmor profile for Tor:
You can create an AppArmor profile by editing the tor-browser profile and renaming it to system_tor.
sudo vi /etc/apparmor.d/tor-browser
Add the following content to the file:
# vim:syntax=apparmor
#include <abstractions/base>
#include <abstractions/networking>
#include <abstractions/tor>
# Local policy for tor
# Contributors: <NAME> <<EMAIL>>
# Generic capabilities
capability dac_read_search,
# Networking
network,
# Tor specific capabilities
tor.*,
# User-space tor binaries
/usr/bin/tor-browser,
/usr/lib/tor-browser/tor-browser,
/usr/lib/tor-browser/Browser/start-tor-browser,
/usr/lib/tor-browser/Browser/start-tor,
/usr/lib/tor-browser/Browser/start-tor-service,
# Configuration files
/etc/tor/torrc,
# Log files
/var/log/tor/*,
# Shared libraries
/usr/lib/x86_64-linux-gnu/,
/usr/lib/i386-linux-gnu/,
# Bind mounts
/dev/null,
/dev/random,
/dev/urandom,
-
Rename the profile:
sudo mv /etc/apparmor.d/tor-browser /etc/apparmor.d/system_tor
-
Create a directory for Tor's socket:
sudo mkdir -p /var/run/tor
-
Reload AppArmor profiles:
sudo apparmor_parser -R /etc/apparmor.d/*
-
Enable AppArmor again:
sudo systemctl enable apparmor.service
sudo systemctl start apparmor.service
-
Start Tor:
Now that the AppArmor profile is set up, you should be able to start Tor without any issues.
sudo /etc/init.d/tor start
Please note that the above steps are a rough guide and may not work exactly as shown without modification. You might need to adjust the paths and permissions according to your system's setup. Also, ensure that the AppArmor profile is correctly configured for Tor to avoid any potential security issues.