From 35c5fa482f69c188a53d39743b62f3c3c5ae01c6 Mon Sep 17 00:00:00 2001 From: Vangelis Banos Date: Fri, 15 Nov 2019 13:20:30 +0000 Subject: [PATCH 1/3] Enable running in docker / k8s When trying to run Brozzler in docker, we get the following error: ``` Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted Trace/breakpoint trap ``` This happens because chromium uses sandboxing for increased security by default and its not supported when running in a container. Adding chromium option `--no-sandbox` fixes the problem. This issue is common, I found various reports about it like this: https://github.com/Zenika/alpine-chrome/issues/33 --- brozzler/chrome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brozzler/chrome.py b/brozzler/chrome.py index cbca3e5..d049d3a 100644 --- a/brozzler/chrome.py +++ b/brozzler/chrome.py @@ -170,7 +170,7 @@ class Chrome: '--disable-background-networking', '--disable-renderer-backgrounding', '--disable-hang-monitor', '--disable-background-timer-throttling', '--mute-audio', - '--disable-web-sockets', + '--disable-web-sockets', '--no-sandbox', '--window-size=1100,900', '--no-default-browser-check', '--disable-first-run-ui', '--no-first-run', '--homepage=about:blank', '--disable-direct-npapi-requests', From 62cb051f93cac66712082073cb940f915888e412 Mon Sep 17 00:00:00 2001 From: Vangelis Banos Date: Mon, 25 Nov 2019 20:44:25 +0000 Subject: [PATCH 2/3] Pass extra CLI params to chrome using ENV variable If ENV var `BROZZLER_EXTRA_CHROME_ARGS` is set, pass its contents as extra chromium cli options. Remove `--no-sandbox` option. Its not good from a security point of view. --- brozzler/chrome.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/brozzler/chrome.py b/brozzler/chrome.py index d049d3a..4eb8c57 100644 --- a/brozzler/chrome.py +++ b/brozzler/chrome.py @@ -170,13 +170,16 @@ class Chrome: '--disable-background-networking', '--disable-renderer-backgrounding', '--disable-hang-monitor', '--disable-background-timer-throttling', '--mute-audio', - '--disable-web-sockets', '--no-sandbox', + '--disable-web-sockets', '--window-size=1100,900', '--no-default-browser-check', '--disable-first-run-ui', '--no-first-run', '--homepage=about:blank', '--disable-direct-npapi-requests', '--disable-web-security', '--disable-notifications', '--disable-extensions', '--disable-save-password-bubble'] + extra_chrome_args = os.environ.get('BROZZLER_EXTRA_CHROME_ARGS') + if extra_chrome_args: + chrome_args.append(extra_chrome_args) if disk_cache_dir: chrome_args.append('--disk-cache-dir=%s' % disk_cache_dir) if disk_cache_size: From 3bc2f434ef677056795db373753c3090eb0892f4 Mon Sep 17 00:00:00 2001 From: Vangelis Banos Date: Wed, 27 Nov 2019 20:18:41 +0000 Subject: [PATCH 3/3] Split extra chrome args on whitespace This is in case multiple args are used. --- brozzler/chrome.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brozzler/chrome.py b/brozzler/chrome.py index 4eb8c57..671000b 100644 --- a/brozzler/chrome.py +++ b/brozzler/chrome.py @@ -179,7 +179,7 @@ class Chrome: extra_chrome_args = os.environ.get('BROZZLER_EXTRA_CHROME_ARGS') if extra_chrome_args: - chrome_args.append(extra_chrome_args) + chrome_args.extend(extra_chrome_args.split()) if disk_cache_dir: chrome_args.append('--disk-cache-dir=%s' % disk_cache_dir) if disk_cache_size: