From 79a4c41eee6719fa0f6a1f26877d01115c487fb8 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 24 Sep 2018 15:36:41 +0100 Subject: [PATCH 1/2] accounts-service: Add accounts service vendor extension for app filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use accounts service’s vendor extension support for storing the app filter per user, in a way that persists and which access to is controlled by polkit (so writes can be restricted to administrators). Signed-off-by: Philip Withnall https://phabricator.endlessm.com/T23858 --- ...om.endlessm.ParentalControls.AppFilter.xml | 35 ++++++++++++++++ .../com.endlessm.ParentalControls.policy | 42 +++++++++++++++++++ accounts-service/meson.build | 8 ++++ meson.build | 30 +++++++++++++ tools/meson-make-symlink.sh | 12 ++++++ 5 files changed, 127 insertions(+) create mode 100644 accounts-service/com.endlessm.ParentalControls.AppFilter.xml create mode 100644 accounts-service/com.endlessm.ParentalControls.policy create mode 100644 accounts-service/meson.build create mode 100644 meson.build create mode 100755 tools/meson-make-symlink.sh diff --git a/accounts-service/com.endlessm.ParentalControls.AppFilter.xml b/accounts-service/com.endlessm.ParentalControls.AppFilter.xml new file mode 100644 index 0000000..3efae8e --- /dev/null +++ b/accounts-service/com.endlessm.ParentalControls.AppFilter.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/accounts-service/com.endlessm.ParentalControls.policy b/accounts-service/com.endlessm.ParentalControls.policy new file mode 100644 index 0000000..ff09f2d --- /dev/null +++ b/accounts-service/com.endlessm.ParentalControls.policy @@ -0,0 +1,42 @@ + + + + Change your own app filter + Authentication is required to change your app filter. + + auth_admin_keep + auth_admin_keep + auth_admin_keep + + + + + Read your own app filter + Authentication is required to read your app filter. + + yes + yes + yes + + + + + Change another user’s app filter + Authentication is required to change another user’s app filter. + + auth_admin_keep + auth_admin_keep + auth_admin_keep + + + + + Read another user’s app filter + Authentication is required to read another user’s app filter. + + auth_admin_keep + auth_admin_keep + auth_admin_keep + + + \ No newline at end of file diff --git a/accounts-service/meson.build b/accounts-service/meson.build new file mode 100644 index 0000000..ce7a6ac --- /dev/null +++ b/accounts-service/meson.build @@ -0,0 +1,8 @@ +install_data('com.endlessm.ParentalControls.policy', + install_dir: polkitpolicydir) + +install_data('com.endlessm.ParentalControls.AppFilter.xml', + install_dir: dbusinterfacesdir) +meson.add_install_script(meson_make_symlink, + join_paths(dbusinterfacesdir, 'com.endlessm.ParentalControls.AppFilter.xml'), + join_paths(accountsserviceinterfacesdir, 'com.endlessm.ParentalControls.AppFilter.xml')) \ No newline at end of file diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..9f93ea9 --- /dev/null +++ b/meson.build @@ -0,0 +1,30 @@ +project('eos-parental-controls', 'c', + version : '0.1.0', + meson_version : '>= 0.47.0', + license: 'LGPLv2.1+', + default_options : [ + 'buildtype=debugoptimized', + 'warning_level=2', + 'c_std=gnu11', + ] +) + +pkgconfig = import('pkgconfig') + +meson_make_symlink = join_paths(meson.source_root(), 'tools', 'meson-make-symlink.sh') + +prefix = get_option('prefix') +datadir = join_paths(prefix, get_option('datadir')) + +# FIXME: This isn’t exposed in accountsservice.pc +accountsserviceinterfacesdir = join_paths(datadir, 'accountsservice', 'interfaces') + +dbus = dependency('dbus-1') +dbusinterfacesdir = dbus.get_pkgconfig_variable('interfaces_dir', + define_variable: ['datadir', datadir]) + +polkit_gobject = dependency('polkit-gobject-1') +polkitpolicydir = polkit_gobject.get_pkgconfig_variable('policydir', + define_variable: ['prefix', prefix]) + +subdir('accounts-service') \ No newline at end of file diff --git a/tools/meson-make-symlink.sh b/tools/meson-make-symlink.sh new file mode 100755 index 0000000..501cd43 --- /dev/null +++ b/tools/meson-make-symlink.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -eu + +# this is needed mostly because $DESTDIR is provided as a variable, +# and we need to create the target directory... + +mkdir -vp "$(dirname "${DESTDIR:-}$2")" +if [ "$(dirname $1)" = . ]; then + ln -vfs -T "$1" "${DESTDIR:-}$2" +else + ln -vfs -T --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2" +fi From b97d101db699601a00efaaf64b197171144160b6 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 24 Sep 2018 15:41:10 +0100 Subject: [PATCH 2/2] po: Add basic translation support The messages in the polkit policy file need translating. Signed-off-by: Philip Withnall https://phabricator.endlessm.com/T23858 --- ...ls.policy => com.endlessm.ParentalControls.policy.in} | 0 accounts-service/meson.build | 9 +++++++-- meson.build | 2 ++ po/LINGUAS | 0 po/POTFILES.in | 3 +++ po/meson.build | 1 + 6 files changed, 13 insertions(+), 2 deletions(-) rename accounts-service/{com.endlessm.ParentalControls.policy => com.endlessm.ParentalControls.policy.in} (100%) create mode 100644 po/LINGUAS create mode 100644 po/POTFILES.in create mode 100644 po/meson.build diff --git a/accounts-service/com.endlessm.ParentalControls.policy b/accounts-service/com.endlessm.ParentalControls.policy.in similarity index 100% rename from accounts-service/com.endlessm.ParentalControls.policy rename to accounts-service/com.endlessm.ParentalControls.policy.in diff --git a/accounts-service/meson.build b/accounts-service/meson.build index ce7a6ac..6bf4da9 100644 --- a/accounts-service/meson.build +++ b/accounts-service/meson.build @@ -1,5 +1,10 @@ -install_data('com.endlessm.ParentalControls.policy', - install_dir: polkitpolicydir) +i18n.merge_file('com.endlessm.ParentalControls.policy', + input: 'com.endlessm.ParentalControls.policy.in', + output: 'com.endlessm.ParentalControls.policy', + po_dir: po_dir, + install: true, + install_dir: polkitpolicydir, +) install_data('com.endlessm.ParentalControls.AppFilter.xml', install_dir: dbusinterfacesdir) diff --git a/meson.build b/meson.build index 9f93ea9..ace0b52 100644 --- a/meson.build +++ b/meson.build @@ -9,9 +9,11 @@ project('eos-parental-controls', 'c', ] ) +i18n = import('i18n') pkgconfig = import('pkgconfig') meson_make_symlink = join_paths(meson.source_root(), 'tools', 'meson-make-symlink.sh') +po_dir = join_paths(meson.source_root(), 'po') prefix = get_option('prefix') datadir = join_paths(prefix, get_option('datadir')) diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..e69de29 diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..3c3e360 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,3 @@ +# List of source files containing translatable strings. +# Please keep this file sorted alphabetically. +accounts-service/com.endlessm.ParentalControls.policy \ No newline at end of file diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..8d7e350 --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('eos-parental-controls', preset: 'glib') \ No newline at end of file