Skip to content

Commit

Permalink
Merge pull request #51 from hhslepicka/root-sandbox
Browse files Browse the repository at this point in the history
FIX: Add --no-sandbox if running Chrome and Edge as root.
  • Loading branch information
hhslepicka committed Mar 24, 2022
2 parents 6a10d75 + 7831a8f commit 56e7e32
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
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
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 56e7e32

Please sign in to comment.