Commit e5d2ca48 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Merge branch 'release/0.4.8'

parents 12c8cd91 713480f1
Pipeline #374 passed with stages
in 4 minutes and 19 seconds
......@@ -15,8 +15,9 @@ build:archlinux:
stage: build
image: registry.pwmt.org/pwmt/gitlab-runner-images/archlinux:latest
script:
- meson subprojects update
- mkdir -p build && cd build
- meson ..
- meson --force-fallback-for=girara ..
- ninja
cache:
<<: *girara_cache
......@@ -50,8 +51,9 @@ build:debian-buster:
stage: build
image: registry.pwmt.org/pwmt/gitlab-runner-images/debian:buster
script:
- meson subprojects update
- mkdir -p build && cd build
- meson ..
- meson --force-fallback-for=girara ..
- ninja
cache:
<<: *girara_cache
......@@ -85,8 +87,9 @@ build:ubuntu-bionic:
stage: build
image: registry.pwmt.org/pwmt/gitlab-runner-images/ubuntu:bionic
script:
- meson subprojects update
- mkdir -p build && cd build
- meson ..
- meson --force-fallback-for=girara ..
- ninja
cache:
<<: *girara_cache
......@@ -120,8 +123,9 @@ build:ubuntu-eoan:
stage: build
image: registry.pwmt.org/pwmt/gitlab-runner-images/ubuntu:eoan
script:
- meson subprojects update
- mkdir -p build && cd build
- meson ..
- meson --force-fallback-for=girara ..
- ninja
cache:
<<: *girara_cache
......
......@@ -44,5 +44,10 @@
<arg type='u' name='column' direction='in' />
<arg type='b' name='return' direction='out' />
</method>
<!-- Execute a command as if entered in the inputbar. -->
<method name='ExecuteCommand'>
<arg type='s' name='input' direction='in' />
<arg type='b' name='return' direction='out' />
</method>
</interface>
</node>
......@@ -43,6 +43,14 @@ General settings
:type: String
:default: #9FBC00
.. describe:: highlight-fg
Defines the color that is for text when highlighting parts of the document
(e.g.: numbers for links)
:type: String
:default: #FFFFFF
.. describe:: highlight-active-color
Defines the color that is used to show the current selected highlighted
......
......@@ -113,6 +113,8 @@ General
Follow links
F
Display link target
c
Copy link target into the clipboard
\:
Enter command
r
......
......@@ -53,6 +53,9 @@ can be used
set option4 hello\ world
set option5 "hello world"
Especially for options with strings as values, note that escaping of special characters and white
spaces is necessary. In the above example, ``option4`` and ``option5`` are both set to ``hello
world``, but ``set option6 hello world`` would set ``option6`` only to ``hello``.
For colors, zathura supports HTML color codes and CSS3-style ``rgb(r,g,b)`` and ``rgba(r,g,b,a)``
values. If you want to use color codes for some options, make sure to quote them accordingly or
......@@ -525,51 +528,6 @@ girara
* Value type: String
* Default value: #FFF712
*tabbar-fg*
Defines the foreground color for a tab
* Value type: String
* Default value: #FFFFFF
*tabbar-bg*
Defines the background color for a tab
* Value type: String
* Default value: #000000
*tabbar-focus-fg*
Defines the foreground color for the focused tab
* Value type: String
* Default value: #9FBC00
*tabbar-focus-bg*
Defines the background color for the focused tab
* Value type: String
* Default value: #000000
*show-scrollbars*
Defines if both the horizontal and vertical scrollbars should be shown or not.
Deprecated, use 'guioptions' instead.
* Value type: Boolean
* Default value: false
*show-h-scrollbar*
Defines whether to show/hide the horizontal scrollbar. Deprecated, use
'guioptions' instead.
* Value type: Boolean
* Default value: false
*show-v-scrollbar*
Defines whether to show/hide the vertical scrollbar. Deprecated, use
'guioptions' instead.
* Value type: Boolean
* Default value: false
*statusbar-bg*
Defines the background color of the statusbar
......@@ -658,6 +616,13 @@ zathura
* Value type: Boolean
* Default value: true
*dbus-raise-window*
Defines whether zathura's window should be raised when receiving certain
commands via D-Bus.
* Value type: Boolean
* Default value: true
*filemonitor*
Defines the file monitor backend used to check for changes in files. Possible
values are "glib", "signal" (if signal handling is supported), and "noop". The
......@@ -679,6 +644,13 @@ zathura
* Value type: String
* Default value: #9FBC00
*highlight-fg*
Defines the color that is used for text when highlighting parts of the
document (e.g.: number for links).
* Value type: String
* Default value: #9FBC00
*highlight-active-color*
Defines the color that is used to show the current selected highlighted element
(e.g: current search result)
......
project('zathura', 'c',
version: '0.4.7',
version: '0.4.8',
meson_version: '>=0.47',
default_options: ['c_std=c11', 'warning_level=3'],
)
......@@ -37,7 +37,7 @@ plugindir = join_paths(get_option('libdir'), 'zathura')
# required dependencies
libm = cc.find_library('m', required: false)
girara = dependency('girara-gtk3', version: '>=0.3.3', fallback: ['girara', 'girara_dependency'])
girara = dependency('girara-gtk3', version: '>=0.3.6', fallback: ['girara', 'girara_dependency'])
glib = dependency('glib-2.0', version: '>=2.50')
gio = dependency('gio-unix-2.0', required: host_machine.system() != 'windows')
gthread = dependency('gthread-2.0', version: '>=2.50')
......@@ -47,6 +47,12 @@ cairo = dependency('cairo')
build_dependencies = [libm, girara, glib, gio, gthread, gmodule, gtk3, cairo]
if host_machine.system() == 'darwin'
gtk_mac_integration = dependency('gtk-mac-integration-gtk3')
build_dependencies += gtk_mac_integration
endif
# defines
defines = [
'-DGETTEXT_PACKAGE="zathura"',
......@@ -55,6 +61,10 @@ defines = [
'-D_DEFAULT_SOURCE',
]
if host_machine.system() == 'darwin'
defines += '-DGTKOSXAPPLICATION'
endif
# compile flags
flags = [
'-Werror=implicit-function-declaration',
......@@ -101,6 +111,7 @@ version_header = configure_file(
output: 'zathura-version.h',
configuration: conf_data
)
include_directories = [
include_directories('.')
]
......@@ -143,7 +154,7 @@ sources = files(
sources += zathura_resources
sources += additional_sources
# header fiels to install
# header files to install
headers = files(
'zathura/document.h',
'zathura/links.h',
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -370,6 +370,7 @@ cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
typedef enum zathura_link_action_e
{
ZATHURA_LINK_ACTION_FOLLOW,
ZATHURA_LINK_ACTION_COPY,
ZATHURA_LINK_ACTION_DISPLAY
} zathura_link_action_t;
......@@ -425,6 +426,16 @@ handle_link(GtkEntry* entry, girara_session_t* session,
case ZATHURA_LINK_ACTION_DISPLAY:
zathura_link_display(zathura, link);
break;
case ZATHURA_LINK_ACTION_COPY: {
GdkAtom* selection = get_selection(zathura);
if (selection == NULL) {
break;
}
zathura_link_copy(zathura, link, selection);
g_free(selection);
break;
}
}
}
}
......@@ -452,6 +463,13 @@ cb_sc_display_link(GtkEntry* entry, void* data)
return handle_link(entry, session, ZATHURA_LINK_ACTION_DISPLAY);
}
gboolean
cb_sc_copy_link(GtkEntry* entry, void* data)
{
girara_session_t* session = data;
return handle_link(entry, session, ZATHURA_LINK_ACTION_COPY);
}
static gboolean
file_monitor_reload(void* data)
{
......
......@@ -174,6 +174,15 @@ gboolean cb_sc_follow(GtkEntry* entry, void* session);
*/
gboolean cb_sc_display_link(GtkEntry* entry, void* session);
/**
* Called when input has been passed to the sc_copy_link dialog
*
* @param entry The dialog inputbar
* @param session The girara session
* @return true if no error occurred and the event has been handled
*/
gboolean cb_sc_copy_link(GtkEntry* entry, void* session);
/**
* Emitted when file has been changed
*
......
......@@ -253,7 +253,7 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list)
document_open_idle(zathura, girara_list_nth(argument_list, 0),
(argc == 2) ? girara_list_nth(argument_list, 1) : NULL,
ZATHURA_PAGE_NUMBER_UNSPECIFIED, NULL, NULL, NULL);
ZATHURA_PAGE_NUMBER_UNSPECIFIED, NULL, NULL, NULL, NULL);
} else {
girara_notify(session, GIRARA_ERROR, _("No arguments given."));
return false;
......@@ -313,11 +313,7 @@ cmd_save(girara_session_t* session, girara_list_t* argument_list)
}
if (girara_list_size(argument_list) == 1) {
if (document_save(zathura, girara_list_nth(argument_list, 0), false) == true) {
girara_notify(session, GIRARA_INFO, _("Document saved."));
} else {
girara_notify(session, GIRARA_INFO, _("Failed to save document."));
}
document_save(zathura, girara_list_nth(argument_list, 0), false);
} else {
girara_notify(session, GIRARA_ERROR, _("Invalid number of arguments."));
return false;
......@@ -339,11 +335,7 @@ cmd_savef(girara_session_t* session, girara_list_t* argument_list)
}
if (girara_list_size(argument_list) == 1) {
if (document_save(zathura, girara_list_nth(argument_list, 0), true) == true) {
girara_notify(session, GIRARA_INFO, _("Document saved."));
} else {
girara_notify(session, GIRARA_INFO, _("Failed to save document."));
}
document_save(zathura, girara_list_nth(argument_list, 0), true);
} else {
girara_notify(session, GIRARA_ERROR, _("Invalid number of arguments."));
return false;
......
......@@ -57,6 +57,8 @@ cb_color_change(girara_session_t* session, const char* name,
const char* string_value = (const char*) value;
if (g_strcmp0(name, "highlight-color") == 0) {
parse_color(&zathura->ui.colors.highlight_color, string_value);
} else if (g_strcmp0(name, "highlight-fg") == 0) {
parse_color(&zathura->ui.colors.highlight_color_fg, string_value);
} else if (g_strcmp0(name, "highlight-active-color") == 0) {
parse_color(&zathura->ui.colors.highlight_color_active, string_value);
} else if (g_strcmp0(name, "recolor-darkcolor") == 0) {
......@@ -209,15 +211,17 @@ config_load_default(zathura_t* zathura)
int_value = 2000;
girara_setting_add(gsession, "jumplist-size", &int_value, INT, false, _("Number of positions to remember in the jumplist"), cb_jumplist_change, NULL);
girara_setting_add(gsession, "recolor-darkcolor", "#FFFFFF", STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL);
girara_setting_add(gsession, "recolor-lightcolor", "#000000", STRING, false, _("Recoloring (light color)"), cb_color_change, NULL);
girara_setting_add(gsession, "highlight-color", NULL, STRING, false, _("Color for highlighting"), cb_color_change, NULL);
girara_setting_add(gsession, "recolor-darkcolor", "#FFFFFF", STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL);
girara_setting_add(gsession, "recolor-lightcolor", "#000000", STRING, false, _("Recoloring (light color)"), cb_color_change, NULL);
girara_setting_add(gsession, "highlight-color", NULL, STRING, false, _("Color for highlighting"), cb_color_change, NULL);
girara_setting_set(gsession, "highlight-color", "#9FBC00");
girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL);
girara_setting_add(gsession, "highlight-fg", NULL, STRING, false, _("Foreground color for highlighting"), cb_color_change, NULL);
girara_setting_set(gsession, "highlight-fg", "#000000");
girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL);
girara_setting_set(gsession, "highlight-active-color", "#00BC00");
girara_setting_add(gsession, "render-loading-bg", NULL, STRING, false, _("'Loading ...' background color"), cb_color_change, NULL);
girara_setting_add(gsession, "render-loading-bg", NULL, STRING, false, _("'Loading ...' background color"), cb_color_change, NULL);
girara_setting_set(gsession, "render-loading-bg", "#FFFFFF");
girara_setting_add(gsession, "render-loading-fg", NULL, STRING, false, _("'Loading ...' foreground color"), cb_color_change, NULL);
girara_setting_add(gsession, "render-loading-fg", NULL, STRING, false, _("'Loading ...' foreground color"), cb_color_change, NULL);
girara_setting_set(gsession, "render-loading-fg", "#000000");
girara_setting_add(gsession, "index-fg", "#DDDDDD", STRING, true, _("Index mode foreground color"), NULL, NULL);
......@@ -284,6 +288,7 @@ config_load_default(zathura_t* zathura)
girara_setting_add(gsession, "synctex-editor-command", "", STRING, false, _("Synctex editor command"), NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "dbus-service", &bool_value, BOOLEAN, false, _("Enable D-Bus service"), NULL, NULL);
girara_setting_add(gsession, "dbus-raise-window", &bool_value, BOOLEAN, false, _("Raise window on certain D-Bus commands"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "continuous-hist-save", &bool_value, BOOLEAN, false, _("Save history at each page change"), NULL, NULL);
girara_setting_add(gsession, "selection-clipboard", "primary", STRING, false, _("The clipboard into which mouse-selected data will be written"), NULL, NULL);
......@@ -298,6 +303,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, 0, GDK_KEY_s, NULL, sc_adjust_window, (mode), ZATHURA_ADJUST_WIDTH, NULL); \
\
girara_shortcut_add(gsession, 0, GDK_KEY_F, NULL, sc_display_link, (mode), 0, NULL); \
girara_shortcut_add(gsession, 0, GDK_KEY_c, NULL, sc_copy_link, (mode), 0, NULL); \
\
girara_shortcut_add(gsession, 0, GDK_KEY_slash, NULL, sc_focus_inputbar, (mode), 0, &("/")); \
girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_slash, NULL, sc_focus_inputbar, (mode), 0, &("/")); \
......@@ -493,6 +499,8 @@ config_load_default(zathura_t* zathura)
girara_inputbar_command_add(gsession, "open", "o", cmd_open, cc_open, _("Open document"));
girara_inputbar_command_add(gsession, "quit", "q", cmd_quit, NULL, _("Close zathura"));
girara_inputbar_command_add(gsession, "print", NULL, cmd_print, NULL, _("Print document"));
girara_inputbar_command_add(gsession, "save", NULL, cmd_save, cc_write, _("Save document"));
girara_inputbar_command_add(gsession, "save!", NULL, cmd_savef, cc_write, _("Save document (and force overwriting)"));
girara_inputbar_command_add(gsession, "write", NULL, cmd_save, cc_write, _("Save document"));
girara_inputbar_command_add(gsession, "write!", NULL, cmd_savef, cc_write, _("Save document (and force overwriting)"));
girara_inputbar_command_add(gsession, "export", NULL, cmd_export, cc_export, _("Save attachments"));
......@@ -512,6 +520,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_mapping_add(gsession, "bisect", sc_bisect);
girara_shortcut_mapping_add(gsession, "change_mode", sc_change_mode);
girara_shortcut_mapping_add(gsession, "display_link", sc_display_link);
girara_shortcut_mapping_add(gsession, "copy_link", sc_copy_link);
girara_shortcut_mapping_add(gsession, "exec", sc_exec);
girara_shortcut_mapping_add(gsession, "focus_inputbar", sc_focus_inputbar);
girara_shortcut_mapping_add(gsession, "follow", sc_follow);
......
......@@ -12,6 +12,7 @@
#include <girara/session.h>
#include <girara/utils.h>
#include <girara/settings.h>
#include <girara/commands.h>
#include <gio/gio.h>
#include <sys/types.h>
#include <string.h>
......@@ -221,7 +222,7 @@ handle_open_document(zathura_t* zathura, GVariant* parameters,
document_open_idle(zathura, filename,
strlen(password) > 0 ? password : NULL,
page,
NULL, NULL, NULL);
NULL, NULL, NULL, NULL);
g_free(filename);
g_free(password);
......@@ -379,6 +380,20 @@ handle_synctex_view(zathura_t* zathura, GVariant* parameters,
g_dbus_method_invocation_return_value(invocation, result);
}
static void
handle_execute_command(zathura_t* zathura, GVariant* parameters,
GDBusMethodInvocation* invocation)
{
gchar* input = NULL;
g_variant_get(parameters, "(s)", &input);
const bool ret = girara_command_run(zathura->ui.session, input);
g_free(input);
GVariant* result = g_variant_new("(b)", ret);
g_dbus_method_invocation_return_value(invocation, result);
}
static void
handle_method_call(GDBusConnection* UNUSED(connection),
const gchar* UNUSED(sender), const gchar* object_path,
......@@ -402,7 +417,8 @@ handle_method_call(GDBusConnection* UNUSED(connection),
{ "CloseDocument", handle_close_document, false, false },
{ "GotoPage", handle_goto_page, true, true },
{ "HighlightRects", handle_highlight_rects, true, true },
{ "SynctexView", handle_synctex_view, true, true }
{ "SynctexView", handle_synctex_view, true, true },
{ "ExecuteCommand", handle_execute_command, false, false }
};
for (size_t idx = 0; idx != sizeof(handlers) / sizeof(handlers[0]); ++idx) {
......@@ -420,7 +436,11 @@ handle_method_call(GDBusConnection* UNUSED(connection),
(*handlers[idx].handler)(priv->zathura, parameters, invocation);
if (handlers[idx].present_window == true && priv->zathura->ui.session->gtk.embed == 0) {
gtk_window_present(GTK_WINDOW(priv->zathura->ui.session->gtk.window));
bool present_window = true;
girara_setting_get(priv->zathura->ui.session, "dbus-raise-window", &present_window);
if (present_window == true) {
gtk_window_present(GTK_WINDOW(priv->zathura->ui.session->gtk.window));
}
}
return;
......
......@@ -291,3 +291,30 @@ zathura_link_display(zathura_t* zathura, zathura_link_t* link)
girara_notify(zathura->ui.session, GIRARA_ERROR, _("Link: Invalid"));
}
}
void
zathura_link_copy(zathura_t* zathura, zathura_link_t* link, GdkAtom* selection)
{
zathura_link_type_t type = zathura_link_get_type(link);
zathura_link_target_t target = zathura_link_get_target(link);
switch (type) {
case ZATHURA_LINK_GOTO_DEST: {
gchar* tmp = g_strdup_printf("%d", target.page_number);
gtk_clipboard_set_text(gtk_clipboard_get(*selection), tmp, -1);
g_free(tmp);
girara_notify(zathura->ui.session, GIRARA_INFO, _("Copied page number: %d"),
target.page_number);
break;
}
case ZATHURA_LINK_GOTO_REMOTE:
case ZATHURA_LINK_URI:
case ZATHURA_LINK_LAUNCH:
case ZATHURA_LINK_NAMED:
gtk_clipboard_set_text(gtk_clipboard_get(*selection), target.value, -1);
girara_notify(zathura->ui.session, GIRARA_INFO, _("Copied link: %s"),
target.value);
break;
default:
girara_notify(zathura->ui.session, GIRARA_ERROR, _("Link: Invalid"));
}
}
......@@ -5,6 +5,8 @@
#include "types.h"
#include <gtk/gtk.h>
/**
* Creates a new zathura link
*
......@@ -64,4 +66,13 @@ void zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link);
*/
void zathura_link_display(zathura_t* zathura, zathura_link_t* link);
/**
* Copy a link into the clipboard using and display it using girara_notify
*
* @param zathura Zathura instance
* @param link The link
* @param selection target clipboard
*/
void zathura_link_copy(zathura_t* zathura, zathura_link_t* link, GdkAtom* selection);
#endif // LINK_H
/* SPDX-License-Identifier: Zlib */
#ifdef GTKOSXAPPLICATION
#include <gtkosxapplication.h>
#endif
#include <girara/settings.h>
#include <girara/log.h>
......@@ -135,6 +139,7 @@ main(int argc, char* argv[])
gchar* synctex_editor = NULL;
gchar* synctex_fwd = NULL;
gchar* mode = NULL;
gchar* bookmark_name = NULL;
gchar* search_string = NULL;
bool forkback = false;
bool print_version = false;
......@@ -157,6 +162,7 @@ main(int argc, char* argv[])
{ "synctex-forward", '\0', 0, G_OPTION_ARG_STRING, &synctex_fwd, _("Move to given synctex position"), "position" },
{ "synctex-pid", '\0', 0, G_OPTION_ARG_INT, &synctex_pid, _("Highlight given position in the given process"), "pid" },
{ "mode", '\0', 0, G_OPTION_ARG_STRING, &mode, _("Start in a non-default mode"), "mode" },
{ "bookmark", 'b', 0, G_OPTION_ARG_STRING, &bookmark_name, _("Bookmark to go to"), "bookmark" },
{ "find", 'f', 0, G_OPTION_ARG_STRING, &search_string, _("Search for the given phrase and display results"), "string" },
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
};
......@@ -298,8 +304,13 @@ main(int argc, char* argv[])
if (page_number > 0) {
--page_number;
}
document_open_idle(zathura, argv[file_idx], password, page_number, mode,
synctex_fwd, search_string);
document_open_idle(zathura, argv[file_idx], password, page_number,
mode, synctex_fwd, bookmark_name, search_string);
} else if (bookmark_name != NULL) {
girara_error("Can not use bookmark argument when no file is given");
ret = -1;
zathura_free(zathura);
goto free_and_ret;
} else if (search_string != NULL) {
girara_error("Can not use find argument when no file is given");
ret = -1;
......@@ -307,6 +318,19 @@ main(int argc, char* argv[])
goto free_and_ret;
}
#ifdef GTKOSXAPPLICATION
GtkosxApplication *zathuraApp;
zathuraApp = g_object_new (GTKOSX_TYPE_APPLICATION, NULL);
gtkosx_application_set_use_quartz_accelerators (zathuraApp, FALSE);
gtkosx_application_ready (zathuraApp);
{
const gchar *id = gtkosx_application_get_bundle_id ();
if (id != NULL)
{
g_print ("TestIntegration Error! Bundle Has ID %s\n", id);
}
}
#endif //GTKOSXAPPLICATION
/* run zathura */
gtk_main();
......@@ -323,6 +347,7 @@ free_and_ret:
g_free(synctex_editor);
g_free(synctex_fwd);
g_free(mode);
g_free(bookmark_name);
g_free(search_string);
return ret;
......
......@@ -587,7 +587,8 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
cairo_fill(cairo);
/* draw text */
cairo_set_source_rgba(cairo, 0, 0, 0, 1);
const GdkRGBA color_fg = priv->zathura->ui.colors.highlight_color_fg;
cairo_set_source_rgba(cairo, color_fg.red, color_fg.green, color_fg.blue, transparency);
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1);
char* link_number = g_strdup_printf("%i", priv->links.offset + ++link_counter);
cairo_show_text(cairo, link_number);
......
......@@ -186,15 +186,16 @@ seccomp_enable_strict_filter(void)
ALLOW_RULE(mprotect);
ALLOW_RULE(mremap);
ALLOW_RULE(munmap);
//ALLOW_RULE (open); /* (zathura needs to open for writing) TODO: avoid needing this somehow */
//ALLOW_RULE (openat);
ALLOW_RULE(newfstatat);
/* ALLOW_RULE (open); specified below */
/* ALLOW_RULE (openat); specified below */
ALLOW_RULE(pipe);
ALLOW_RULE(pipe2);
ALLOW_RULE(poll);
ALLOW_RULE(pwrite64); /* TODO: build detailed filter */
ALLOW_RULE(pread64);
/* ALLOW_RULE (prlimit64); */
/* ALLOW_RULE (prctl); specified below */
/* ALLOW_RULE (prctl); specified below */
ALLOW_RULE(read);
ALLOW_RULE(readlink);
ALLOW_RULE(recvfrom);
......@@ -214,6 +215,7 @@ seccomp_enable_strict_filter(void)
ALLOW_RULE(shmget);
ALLOW_RULE(shutdown);
ALLOW_RULE(stat);
ALLOW_RULE(statx);
ALLOW_RULE(statfs);
/* ALLOW_RULE (socket); */
ALLOW_RULE(sysinfo);
......@@ -223,8 +225,17 @@ seccomp_enable_strict_filter(void)
ALLOW_RULE(writev);
ALLOW_RULE(wait4); /* trying to open links should not crash the app */
ADD_RULE("errno", SCMP_ACT_ERRNO(EPERM), sched_setattr, 0);
ADD_RULE("errno", SCMP_ACT_ERRNO(EPERM), sched_getattr, 0);
/* ADD_RULE("errno", SCMP_ACT_ERRNO(EPERM), sched_setattr, 0); */
/* ADD_RULE("errno", SCMP_ACT_ERRNO(EPERM), sched_getattr, 0); */
/* required by glib */
ALLOW_RULE(sched_setattr);
ALLOW_RULE(sched_getattr);
/* required by some X11 setups */
ADD_RULE("errno", SCMP_ACT_ERRNO(EPERM), umask, 0);
ADD_RULE("errno", SCMP_ACT_ERRNO(EPERM), socket, 0);
/* required for testing only */
ALLOW_RULE(timer_create);
......@@ -234,8 +245,6 @@ seccomp_enable_strict_filter(void)
ADD_RULE("allow", SCMP_ACT_ALLOW, ioctl, 1, SCMP_CMP(0, SCMP_CMP_EQ, 1));
ADD_RULE("allow", SCMP_ACT_ALLOW, ioctl, 1, SCMP_CMP(0, SCMP_CMP_EQ, 2));
/* needed by gtk??? (does not load content without) */
/* special restrictions for prctl, only allow PR_SET_NAME/PR_SET_PDEATHSIG */
ADD_RULE("allow", SCMP_ACT_ALLOW, prctl, 1, SCMP_CMP(0, SCMP_CMP_EQ, PR_SET_NAME));
ADD_RULE("allow", SCMP_ACT_ALLOW, prctl, 1, SCMP_CMP(0, SCMP_CMP_EQ, PR_SET_PDEATHSIG));
......@@ -292,60 +301,6 @@ seccomp_enable_strict_filter(void)
/* when zathura is run on wayland, with X11 server available but blocked, unset the DISPLAY variable */
/* otherwise it will try to connect to X11 using inet socket protocol */
/* ------------ experimental filters --------------- */
/* /\* this filter is susceptible to TOCTOU race conditions, providing limited use *\/ */
/* /\* allow opening only specified files identified by their file descriptors*\/ */
/* this requires either a list of all files to open (A LOT!!!) */
/* or needs to be applied only after initialisation, right before parsing */
/* if(seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1, */
/* SCMP_CMP(SCMP_CMP_EQ, fd)) < 0) /\* or < 1 ??? *\/ */
/* goto out; */
/* /\* restricting write access *\/ */
/* /\* allow stdin *\/ */
/* if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 1, */
/* SCMP_CMP(0, SCMP_CMP_EQ, 0)) < 0 ) */
/* goto out; */
/* /\* allow stdout *\/ */
/* if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 1, */
/* SCMP_CMP(0, SCMP_CMP_EQ, 1)) < 0 ) */
/* goto out; */
/* /\* allow stderr *\/ */
/* if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(write), 1, */
/* SCMP_CMP(0, SCMP_CMP_EQ, 2)) < 0 ) */
/* goto out; */
/* /\* restrict writev (write a vector) access *\/ */
/* this does not seem reliable but it surprisingly is. investigate more */
/* if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(writev), 1, */
/* SCMP_CMP(0, SCMP_CMP_EQ, 3)) < 0 ) */
/* goto out; */
/* test if repeating this after some time or denying it works */
/* first attempt to filter poll requests */
/* if (seccomp_rule_add (ctx, SCMP_ACT_ALLOW, SCMP_SYS(poll), 1, */
/* SCMP_CMP(0, SCMP_CMP_MASKED_EQ, POLLIN | POLL, 0)) < 0) */
/* goto out; */
/* /\* restrict fcntl calls *\/ */
/* this syscall sets the file descriptor to read write */
/* if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(fcntl), 1, */
/* SCMP_CMP(0, SCMP_CMP_EQ, 3)) < 0 ) */
/* goto out; */
/* fcntl(3, F_GETFL) = 0x2 (flags O_RDWR) */
/* fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 */
/* fcntl(3, F_SETFD, FD_CLOEXEC) = 0 */
/* ------------------ end of experimental filters ------------------ */
/* applying filter... */