Skip to content

Commit

Permalink
FIX: Add --no-sandbox if running Chrome and Edge as root.
Browse files Browse the repository at this point in the history
  • Loading branch information
hhslepicka committed Mar 24, 2022
1 parent 6a10d75 commit 7831a8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions botcity/web/browsers/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def default_options(headless=False, download_folder_path=None, user_data_dir=Non
chrome_options.add_argument("--hide-scrollbars")
chrome_options.add_argument("--mute-audio")

# Check if user is root
try:
# This is only valid with Unix
if os.geteuid() == 0:
chrome_options.add_argument("--no-sandbox")
except AttributeError:
pass

if not user_data_dir:
temp_dir = tempfile.TemporaryDirectory(prefix="botcity_")
user_data_dir = temp_dir.name
Expand Down
8 changes: 8 additions & 0 deletions botcity/web/browsers/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def default_options(headless=False, download_folder_path=None, user_data_dir=Non
edge_options.add_argument("--hide-scrollbars")
edge_options.add_argument("--mute-audio")

# Check if user is root
try:
# This is only valid with Unix
if os.geteuid() == 0:
edge_options.add_argument("--no-sandbox")
except AttributeError:
pass

if not user_data_dir:
temp_dir = tempfile.TemporaryDirectory(prefix="botcity_")
user_data_dir = temp_dir.name
Expand Down

0 comments on commit 7831a8f

Please sign in to comment.