diff --git a/doc/man/zathurarc.5.rst b/doc/man/zathurarc.5.rst index 5a48921..5a47783 100644 --- a/doc/man/zathurarc.5.rst +++ b/doc/man/zathurarc.5.rst @@ -1055,7 +1055,7 @@ sandbox Defines the sandbox mode to use for the seccomp syscall filter. Possible values are "none", "normal" and "strict". If "none" is used, the sandbox will be disabled. The use of "normal" will provide minimal protection and -allow normal use of seccomp with support for all features. The "strict" mode +allow normal use of zathura with support for all features. The "strict" mode is a read only sandbox that is intended for viewing documents only. * Value type: String @@ -1070,6 +1070,9 @@ Some features are disabled when using strict sandbox mode: No feature regressions are expected when using normal sandbox mode. +When running under WSL, the default is "none" since seccomp is not supported in +that environment. + window-icon-document ^^^^^^^^^^^^^^^^^^^^ Defines whether the window document should be updated based on the first page of diff --git a/zathura/config.c b/zathura/config.c index 00599ab..d998169 100644 --- a/zathura/config.c +++ b/zathura/config.c @@ -292,7 +292,9 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "selection-clipboard", string_value, STRING, false, _("The clipboard into which mouse-selected data will be written"), NULL, NULL); bool_value = true; girara_setting_add(gsession, "selection-notification", &bool_value, BOOLEAN, false, _("Enable notification after selecting text"), NULL, NULL); - girara_setting_add(gsession, "sandbox", "normal", STRING, true, _("Sandbox level"), cb_sandbox_changed, NULL); + /* default to no sandbox when running in WSL */ + string_value = running_under_wsl() ? "none" : "normal"; + girara_setting_add(gsession, "sandbox", string_value, STRING, true, _("Sandbox level"), cb_sandbox_changed, NULL); #define DEFAULT_SHORTCUTS(mode) \ girara_shortcut_add(gsession, 0, GDK_KEY_a, NULL, sc_adjust_window, (mode), ZATHURA_ADJUST_BESTFIT, NULL); \ diff --git a/zathura/utils.c b/zathura/utils.c index 1af1e1a..b5d7363 100644 --- a/zathura/utils.c +++ b/zathura/utils.c @@ -298,3 +298,15 @@ parse_color(GdkRGBA* color, const char* str) } return true; } + +bool +running_under_wsl(void) +{ + bool result = false; + char* content = girara_file_read("/proc/version"); + if (content != NULL && g_strstr_len(content, -1, "Microsoft")) { + result = true; + } + free(content); + return result; +} diff --git a/zathura/utils.h b/zathura/utils.h index 57b68bd..eb0a52b 100644 --- a/zathura/utils.h +++ b/zathura/utils.h @@ -130,4 +130,11 @@ unsigned int find_first_page_column(const char* first_page_column_list, */ bool parse_color(GdkRGBA* color, const char* str); +/** + * Check if zathura is running under the Linux subsystem on Windows. + * + * @return true if running under WSL, false otherwise + */ +bool running_under_wsl(void); + #endif // UTILS_H