summaryrefslogtreecommitdiffstats
path: root/core/modules/kiosk-chromium
diff options
context:
space:
mode:
authorSimon Rettberg2020-10-28 13:37:51 +0100
committerSimon Rettberg2020-10-28 13:37:51 +0100
commit203d71684e8dc31e8bd5316249b17345290dc086 (patch)
treece68a69bc15ab48b230c05c55de8f0c5c5ffb8d8 /core/modules/kiosk-chromium
parent[redsocks] also set all_proxy (diff)
downloadmltk-203d71684e8dc31e8bd5316249b17345290dc086.tar.gz
mltk-203d71684e8dc31e8bd5316249b17345290dc086.tar.xz
mltk-203d71684e8dc31e8bd5316249b17345290dc086.zip
[kiosk-chromium] Support black- and whitelist at the same time
Diffstat (limited to 'core/modules/kiosk-chromium')
-rw-r--r--core/modules/kiosk-chromium/data/opt/openslx/pam/hooks/session-open.d/10-chromium-urlfilter34
1 files changed, 23 insertions, 11 deletions
diff --git a/core/modules/kiosk-chromium/data/opt/openslx/pam/hooks/session-open.d/10-chromium-urlfilter b/core/modules/kiosk-chromium/data/opt/openslx/pam/hooks/session-open.d/10-chromium-urlfilter
index e9797b52..cba692fd 100644
--- a/core/modules/kiosk-chromium/data/opt/openslx/pam/hooks/session-open.d/10-chromium-urlfilter
+++ b/core/modules/kiosk-chromium/data/opt/openslx/pam/hooks/session-open.d/10-chromium-urlfilter
@@ -48,21 +48,33 @@ format_urls() {
}
main() {
- [ -e "/opt/openslx/config" ] || exit 0
- . /opt/openslx/config
+ [ -z "$SLX_PXE_CLIENT_IP" ] && . /opt/openslx/config
local url_policy_file="/etc/chromium-browser/policies/managed/url-filter.json"
+ if [ -z "$SLX_BROWSER_BLACKLIST" ] && [ -z "$SLX_BROWSER_WHITELIST" ]; then
+ # Legacy format
+ if [ "$SLX_BROWSER_IS_WHITELIST" -eq 1 ]; then
+ SLX_BROWSER_BLACKLIST="*"
+ SLX_BROWSER_WHITELIST="$SLX_BROWSER_URLLIST"
+ else
+ SLX_BROWSER_BLACKLIST="$SLX_BROWSER_URLLIST"
+ fi
+ fi
+ if [ -z "$SLX_BROWSER_BLACKLIST" ] && [ -z "$SLX_BROWSER_WHITELIST" ]; then
+ rm -f -- "$url_policy_file"
+ return
+ fi
+ # Create file
echo "{" > "$url_policy_file"
- local ttype
- if [ "$SLX_BROWSER_IS_WHITELIST" -eq 1 ]; then
- ttype="White"
- echo -e '\t"URLBlacklist": [ "*" ],' >> "$url_policy_file"
- else
- ttype="Black"
+ if [ -n "$SLX_BROWSER_BLACKLIST" ]; then
+ echo -e '\tURLBlacklist: ' >> "$url_policy_file"
+ format_urls $SLX_BROWSER_BLACKLIST \
+ | jq -Rs 'rtrimstr("\n") | split("\n")' >> "$url_policy_file"
+ [ -n "$SLX_BROWSER_WHITELIST" ] && echo ',' >> "$url_policy_file"
fi
- if [ -n "$SLX_BROWSER_URLLIST" ]; then
- echo -e '\t"'"URL${ttype}list"'": ' >> "$url_policy_file"
- format_urls $SLX_BROWSER_URLLIST \
+ if [ -n "$SLX_BROWSER_WHITELIST" ]; then
+ echo -e '\tURLWhitelist: ' >> "$url_policy_file"
+ format_urls $SLX_BROWSER_WHITELIST \
| jq -Rs 'rtrimstr("\n") | split("\n")' >> "$url_policy_file"
fi
echo '}' >> "$url_policy_file"