Skip to content

Commit 56e7e32

Browse files
authored
Merge pull request #51 from hhslepicka/root-sandbox
FIX: Add --no-sandbox if running Chrome and Edge as root.
2 parents 6a10d75 + 7831a8f commit 56e7e32

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

botcity/web/browsers/chrome.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ def default_options(headless=False, download_folder_path=None, user_data_dir=Non
5454
chrome_options.add_argument("--hide-scrollbars")
5555
chrome_options.add_argument("--mute-audio")
5656

57+
# Check if user is root
58+
try:
59+
# This is only valid with Unix
60+
if os.geteuid() == 0:
61+
chrome_options.add_argument("--no-sandbox")
62+
except AttributeError:
63+
pass
64+
5765
if not user_data_dir:
5866
temp_dir = tempfile.TemporaryDirectory(prefix="botcity_")
5967
user_data_dir = temp_dir.name

botcity/web/browsers/edge.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ def default_options(headless=False, download_folder_path=None, user_data_dir=Non
5151
edge_options.add_argument("--hide-scrollbars")
5252
edge_options.add_argument("--mute-audio")
5353

54+
# Check if user is root
55+
try:
56+
# This is only valid with Unix
57+
if os.geteuid() == 0:
58+
edge_options.add_argument("--no-sandbox")
59+
except AttributeError:
60+
pass
61+
5462
if not user_data_dir:
5563
temp_dir = tempfile.TemporaryDirectory(prefix="botcity_")
5664
user_data_dir = temp_dir.name

0 commit comments

Comments
 (0)