Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__/
24 changes: 18 additions & 6 deletions usr/share/sdwdate/onion-tester
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
## Copyright (C) 2017 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

import os
## Comments for reviewers:
## URLs are read from /etc/sdwdate.d/*.conf which is root-owned and trusted.
## subprocess.Popen with a list of arguments (no shell) is used in exec_curl()
## to safely pass URLs as a single argument to curl, avoiding shell interpretation.

import subprocess
import time
import datetime
from sdwdate.remote_times import get_time_from_servers
Expand All @@ -19,11 +24,18 @@ def chunks(my_list, n):
yield my_list[i:i + n]

def exec_curl(c_url):
cmd = 'curl --head '+c_url+'> /dev/null 2>&1'
c_out = os.system(cmd)
if '0' in str(c_out) :
return ' (Curl --head is OK)'
else:
try:
result = subprocess.Popen(
['curl', '--head', c_url],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
result.wait()
if result.returncode == 0:
return ' (Curl --head is OK)'
else:
return ' (Curl --head also Not OK)'
except Exception:
return ' (Curl --head also Not OK)'

class Pool:
Expand Down