Commit Graph

212 Commits

Author SHA1 Message Date
Philip Withnall f670880382 malcontent-control: Fix a typo in an enum value
The values are the same so this doesn’t introduce any functional
changes, but it does fix the type.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-30 09:38:33 +00:00
Philip Withnall e54f7eaf8a malcontent-control: Ignore a harmless error
This is a backport of
https://github.com/endlessm/gnome-control-center/pull/205 from Endless’
gnome-control-center fork, applied there after the code was copied over
here.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-30 09:31:40 +00:00
Philip Withnall 368cc1fb76 malcontent-control: Fix a crash when flushing changes
The `GSource` was being removed twice, once in `blacklist_apps_cb()` and
once in `flush_update_blacklisted_apps()`, leading to a critical warning
from GLib.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-30 09:31:40 +00:00
Philip Withnall c7f975bb2b malcontent-control: Add initial draft of main interface
This replicates the old interface from Endless’ gnome-control-center,
with no attempt to improve or rework it. That will come later.

It might not work fully.

It allows a user to be selected, and their parental controls to be
changed. It currently doesn’t filter the users.

It supports a simple ‘Loading’ screen, before displaying the main
interface. If loading fails (due to a D-Bus error with accountsservice),
an error page is displayed instead.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-30 09:31:40 +00:00
Philip Withnall 1623876fbc malcontent-control: Add an MctUserSelector widget
This isn’t used yet, but will be soon. It encapsulates an
`ActUserManager` with an `MctCarousel` to provide an all-inclusive
widget for selecting a user account.

It’s based off code from the user accounts panel of
gnome-control-center, licenced as GPLv2+, and authored by many people
over time (see
https://gitlab.gnome.org/GNOME/gnome-control-center/commits/master/panels/user-accounts).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-30 09:31:40 +00:00
Philip Withnall 484993b658 malcontent-control: Add basic accessibility support to g-c-c widgets
Not submitting this upstream as it hasn’t been tested thoroughly enough.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-29 15:31:42 +00:00
Philip Withnall 9e73c34664 malcontent-control: Fix some minor leaks in MctCarousel
Relevant chunks upstreamed in
https://gitlab.gnome.org/GNOME/gnome-control-center/merge_requests/683.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-29 15:31:42 +00:00
Philip Withnall 2c043a6bd5 malcontent-control: Reformat and rename code from gnome-control-center
Make it fit in with the surrounding code style, and rename the classes
to `MctCarousel` and `MctUserControls`. List them in `meson.build` and
`POTFILES.in`. No other changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-29 15:31:42 +00:00
Philip Withnall aa6ece8a91 malcontent-control: Add widgets from gnome-control-center
Add `CcCarousel` and `CcAppPermissions` from gnome-control-center and
rename the files. None of the contents of the files have been changed
yet. The files are from git master of gnome-control-center on
2020-01-08.

`carousel.{c,h,ui}` are licensed under GPLv2+, and are copyright 2016
Red Hat, Inc. The original author was Felipe Borges.

`user-controls.{c,h,ui}` are licensed under GPLv3+, and are copyright
2018, 2019 Endless, Inc.

`gs-content-rating.{c,h}` are originally from gnome-software, are
licensed under GPLv2+, and are copyright 2015, 2016 Richard Hughes. He
was also the original author. These files are needed by
`user-controls.{c,h}`.

`user-image.{c,h}` are licensed under GPLv2+ and are copyright 2015, Red
Hat, Inc. The original author was Ondrej Holy.

This code will not stay as copy-paste code for too long. The ultimate
plan is to rework most of the widgets:
 • `CcCarousel`: Will be reworked to provide more information about the
   screen time usage of each user. It will become a summary widget as
   well as a selector.
 • `GsContentRating`: Will be abstracted out into libappstream-glib, or
   some other suitable library, where its implementation can be shared
   between gnome-software and malcontent.
 • `CcUserControls`: Will be reworked as the UI of malcontent evolves.
   Will also be removed from gnome-control-center once malcontent-control
   is released.
 • `CcUserImage`: As per `CcCarousel`, this will evolve into a new
   widget.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-29 15:28:21 +00:00
Philip Withnall b0f72c432f malcontent-control: Add initial main window
It’s currently empty, but it’s a start.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-29 15:27:33 +00:00
Philip Withnall cf6331cac6 malcontent-control: Add an AppData file
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-29 15:27:33 +00:00
Philip Withnall 8b62f08cf6 malcontent-control: Add a desktop file
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-29 15:27:33 +00:00
Philip Withnall 1d8f7d665c malcontent-control: Add initial skeleton application
This does nothing at the moment (not even showing a main window), but it
soon will do.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-29 15:07:15 +00:00
Philip Withnall 254eac4a55 po: A few build fixes for the translation infrastructure
It wasn’t working at all.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-21 15:49:48 +00:00
Philip Withnall 6e5f356f73 Merge branch 'fix-pamlibdir' into 'master'
build: Fix default value of pamlibdir

See merge request pwithnall/malcontent!21
2020-01-20 17:17:20 +00:00
Philip Withnall f5c74d2c80 build: Fix default value of pamlibdir
The previous version only worked on Fedora-like distributions which have
`libdir = /usr/lib{,64}`. On multi-arch Debian systems, it would
calculate `pamlibdir = /usr/x86_64-linux-gnu/security` which is not
right.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-20 17:13:53 +00:00
Philip Withnall 83d2fdb838 Merge branch 'pam-module' into 'master'
Add session limits support and PAM module

See merge request pwithnall/malcontent!19
2020-01-17 11:28:49 +00:00
Philip Withnall 0364346a4c docs: Mention that malcontent-client command line API is unstable
It might be stable one day, but while the functionality of libmalcontent
is growing, the command line tooling will continue to change.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-17 11:24:32 +00:00
Philip Withnall 876c155efb tests: Add pam_malcontent.so tests
These tests check that the built `pam_malcontent.so` module can be
loaded using `dlopen()` and that it exports the right symbol. This
should mean that PAM can load it and use it.

Unfortunately, we can’t actually run the module, since PAM hard-codes
its configuration path as being in `/etc`, and there seems to be no way
to override that to load a dummy configuration from a test directory. So
the only way to test the PAM module is to use a file system bind mount
to fake `/etc` (which requires privileges); or to actually install it on
your system and integrate it into your real PAM configuration. Neither
of those are acceptable for a unit test.

It might be possible to re-execute a test under `bwrap` (if installed)
to achieve this, bind mounting a dummy `/etc/pam.d/dummy` service file
into the subprocess’ mount namespace, and otherwise bind mounting `/` to
`/`. It would need a mock malcontent D-Bus API to talk to. Something to
experiment with another time.

(See `_pam_init_handlers()` in
https://github.com/linux-pam/linux-pam/blob/master/libpam/pam_handlers.c
for details of how PAM modules are loaded.)

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:27:17 +00:00
Philip Withnall bd7b17ffd4 pam: Add a `pam_malcontent.so` module to enforce time-limited sessions
This involves adding a build-time dependency on PAM.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:27:17 +00:00
Philip Withnall e16759e0f7 malcontent-client: Fix error when running with no arguments
The default value for the `user` argument wasn’t looked up, since
parsing an empty command line doesn’t go through the
`parser_get_app_filter` subparser.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:27:17 +00:00
Philip Withnall c02c56b3b5 malcontent-client: Add a `get-session-limits` command
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall ec1af3ef55 tests: Add tests for SessionLimits interface
This adds tests for the getter and setter for session limits, giving us
65.9% branch coverage (but that includes `g_return_if_fail()` and
friends, which are impossible and pointless to test both sides of the
branch).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall ee7ed7dc35 libmalcontent: Add support for setting session limits
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 5e49cb7831 libmalcontent: Add a SessionLimits interface for time-limited sessions
This is another extension interface on accountsservice which stores
information about time and usage limits on the user session. Currently,
only a ‘daily schedule’ limit (or no limit) is supported, but additional
types and combinations of limits can be supported in future.

The daily schedule limit allows using the computer between a certain
start time and end time each day (the same each day). The user will be
kicked out of their session when the end time is reached, if they
haven’t already logged out.

This includes the getters for the new data, polkit rules for accessing
it, and some documentation. Changes to `malcontent-client` to support
session limits, setters, and unit tests will all follow.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 9dcaa10253 libmalcontent: Drop an unused variable
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall a54415aa2c malcontent-client: Improve specificity of exit statuses
Add a couple of missing exit statuses (and document them) and convert
Malcontent errors to exit statuses more specifically.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 300b5a624f libmalcontent: Move MctAppFilterError to MctManagerError
This isn’t an API break, as compatibility defines are in place; and the
error code values are the same, so it shouldn’t be an ABI break. The
string value of the error quark has changed, but nobody should be
comparing that against a value which hasn’t come out of libmalcontent,
so changing it should be OK.

This is along the same lines as the previous commit: we don’t need one
error domain per property of an `MctManager`, so reduce the potential
for future duplication by renaming it now.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall acf2738d56 libmalcontent: Rename flags types
If we have a flag type for getting and for setting every type of value
which can be stored on an `MctManager`, that will lead to a load of flag
types which all look identical.

Refactor the types so we only have one shared flags type for getters,
and one for setters.

Add compatibility defines so that this doesn’t break API. It’s not an
ABI break because the flag member values don’t change.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 282cf9c66b libmalcontent: Set flag-like values for flag types
Previously these flags were using automatically assigned enum values,
which would have eventually resulted in having more than one bit set per
flag. Fix that before it happens by explicitly assigning flag-like
values. This was an oversight when they were first written.

This introduces no functional changes because both enums only had one
element so far.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 5f2d4046ea libmalcontent: Fix a minor typo in a comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall c9d5713f83 po: Add missing file to POTFILES.in
This has been translatable for a while.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall b2ffb160fc malcontent-client: Print usernames rather than user IDs in output
This makes the output a little easier to interpret.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 305129589e malcontent-client: Fix typo in use of flags
This doesn’t actually change the behaviour, since the two types are
equivalent.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:09:23 +00:00
Philip Withnall 983e3bfa39 malcontent-client: Rename ‘check’ command to ‘check-app-filter’
Since it operates only on the app filter. This updates the documentation
too. No compatibility fallback is provided.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:09:23 +00:00
Philip Withnall b3dbc07b92 malcontent-client: Rename ‘set’ command to ‘set-app-filter’
Since it operates only on the app filter. This doesn’t update the
documentation because none has been written for this command yet.
No compatibility fallback is provided.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:09:23 +00:00
Philip Withnall 2b180a9afd malcontent-client: Rename ‘get’ command to ‘get-app-filter’
There’ll be other types of getting happening soon.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:09:16 +00:00
Philip Withnall a7947d56e6 malcontent-client: Fix a minor typo in --help output
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:09:16 +00:00
Philip Withnall c3fdc05d62 Merge branch 'wip/lantw/build-Port-meson-make-symlink-script-to-Python' into 'master'
build: Port meson-make-symlink script to Python

See merge request pwithnall/malcontent!18
2019-12-03 11:55:00 +00:00
Ting-Wei Lan 8b7d4e46de build: Port meson-make-symlink script to Python
Instead of using non-portable features of GNU ln command, such as -T
and --relative, use Python os.path.relpath function to handle it. This
fixes installation failure on FreeBSD.
2019-12-02 22:57:13 +08:00
Philip Withnall aaa141f28b Merge branch 'readme-deps' into 'master'
docs: Update list of dependencies in README.md

Closes #6

See merge request pwithnall/malcontent!17
2019-10-30 14:41:59 +00:00
Philip Withnall 3676f386d4 docs: Update list of dependencies in README.md
Spotted by Corentin Noël.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #6
2019-10-30 14:38:24 +00:00
Philip Withnall c0cea72b6b Merge branch 'uajain/improve-docs' into 'master'
docs: Improve documentation of "app-filter-changed" signal

See merge request pwithnall/malcontent!16
2019-06-20 07:45:42 +00:00
Umang Jain b6b8873261 docs: Improve documentation of "app-filter-changed" signal 2019-06-18 19:23:17 +05:30
Philip Withnall a897a4890b Release version 0.4.0
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-17 11:57:35 +01:00
Philip Withnall 90f961dc74 Merge branch 'filter-content-type' into 'master'
Add support to filter by content type

See merge request pwithnall/malcontent!15
2019-06-14 16:02:04 +00:00
Andre Moreira Magalhaes 2c40458cd5 docs: Update malcontent-client manpage to mention new supported types
Mention content types and flatpak refs are also valid for 'check'
command arguments.

Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00
Andre Moreira Magalhaes 9f39878c93 malcontent-client: Allow getting/setting filters by content type
Note that this change breaks backward compatibility when handling
content types if the passed argument also resolves to a valid path,
in which case an exception will be raised.

Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00
Andre Moreira Magalhaes 2846db6529 malcontent-client: Refactor logic to determine type of argument for check/set
Note that this change breaks backward compatibility when handling
flatpak refs/IDs if the passed argument also resolves to a valid path,
in which case an exception will be raised.

Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00
Andre Moreira Magalhaes 6c7c386ce2 malcontent-client: Disambiguate usage of path
The cmdline arguments may refer to both paths or flatpak refs so lets
disambiguate here for clarity.

Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00