Open DrYak opened 2 years ago
Update, playing around with the Python code:
diff --git a/usr/share/harbour-defender/qml/python/defender.py.orig b/usr/share/harbour-defender/qml/python/defender.py
index 906bd0d..4109128 100644
--- a/usr/share/harbour-defender/qml/python/defender.py.orig
+++ b/usr/share/harbour-defender/qml/python/defender.py
@@ -248,8 +248,19 @@ def cookie_is_locked():
return not bool(st.st_mode & S_IWUSR)
def get_stats():
- hosts_lines = int(check_output(["wc", "-l", "/etc/hosts"]).decode("utf-8").split(' ')[0])
- hosts_editable_lines = int(check_output(["wc", "-l", "/etc/hosts.editable"]).decode("utf-8").split(' ')[0])
+ try:
+ hosts_lines = int(check_output(["wc", "-l", "/etc/hosts"]).decode("utf-8").split(' ')[0])
+ except: # execution permissions missing
+ with open("/etc/hosts", "r") as hf:
+ hosts_lines = len(hf.readlines( ))
+ try:
+ hosts_editable_lines = int(check_output(["wc", "-l", "/etc/hosts.editable"]).decode("utf-8").split(' ')[0])
+ except: # execution permissions missing
+ try:
+ with open("/etc/hosts.editable", "r") as hf:
+ hosts_editable_lines = len(hf.readlines( ))
+ except: # hosts.editable file not exposed withing sailjail
+ hosts_editable_lines = 2
config_etc = configparser.ConfigParser()
config_etc.read(CONFIG_ETC_PATH)
config_home = configparser.ConfigParser()
@@ -260,10 +271,11 @@ def get_stats():
for src in sources:
if src['sourceenabled']:
sources_enabled_count += 1
- cur = sqlite3.connect(cookies_path).cursor()
- cookies_count, domains_count = cur.execute("SELECT COUNT(*) AS cookies_count, COUNT(DISTINCT baseDomain) AS domains_count FROM moz_cookies").fetchall()[0]
- cur.connection.close()
- cookie_bl_count = len(cookie_load_list(blacklist = True))
+ #cur = sqlite3.connect(cookies_path).cursor()
+ #cookies_count, domains_count = cur.execute("SELECT COUNT(*) AS cookies_count, COUNT(DISTINCT baseDomain) AS domains_count FROM moz_cookies").fetchall()[0]
+ #cur.connection.close()
+ #cookie_bl_count = len(cookie_load_list(blacklist = True))
+ cookies_count = domains_count = cookie_bl_count = 0
if os.path.isfile(LOGFILE_LAST):
with open(LOGFILE_LAST) as data_file:
data = json.load(data_file)
...gets us a bit further.
Key points:
wc -l
isn't granted to defender/etc/hosts.editable
and .local/share/org.sailfishos/browser/.mozilla/cookies.sqlite
aren't made available inside the sailjail.You can disable sailjail for defender by adding the following lines to /usr/share/applications/harbour-defender.desktop
:
[X-Sailjail]
Sandboxing=Disabled
After I did that, I was able to download and use the adblock lists via the GUI.
Hi, currently migrating to an Xperia 10 iii. After flashing SFOX 4.4.0.64, and attempting to install harbour-defender, I notice that Adblock Lists pane is empty. (nothing shows up under "Sources"), and the counters are missing on the buttons in the main pane.
Quick glance at the journal:
The failure to
wc -l /etc/hosts
seems weird, I might be due to the permissions systems that got introduced in the recent 4.x series of SFOX and defender not requesting the correct one.