Commit Graph

597 Commits

Author SHA1 Message Date
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
Andre Moreira Magalhaes 3800cd3818 libmalcontent: Add tests for filtering by content type
Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00
Andre Moreira Magalhaes da0e63fe99 libmalcontent: Add support for filtering by content type
This is useful for example if blacklisting all apps that can
handle certain content types is desired.

Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00
Andre Moreira Magalhaes bbd1b2bdff libmalcontent: Rename app filter paths_blacklist member to blacklist
The filter blacklist also holds information on flatpak refs that are
blacklisted (apart from paths), so lets rename it for clarity.

Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00
Philip Withnall 80288aa05a Merge branch 'accounts-service-iface' into 'master'
tests: Use gdbus-codegen to drop hand-coded interface definitions

See merge request pwithnall/malcontent!2
2019-06-13 15:43:49 +00:00
Philip Withnall 418b79ab7f tests: Use g_assert_cmpvariant() from GLib 2.60
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-13 16:40:52 +01:00
Philip Withnall d9acee829a tests: Use gdbus-codegen to drop hand-coded interface definitions
Bump our GLib dependency to 2.60 so we can use `gdbus-codegen
--interface-info-{body,header}` to generate interface definitions
dynamically rather than hand-coding them.

We actually need to depend on 2.60.1 so we get
https://gitlab.gnome.org/GNOME/glib/merge_requests/721.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-13 16:40:52 +01:00
Philip Withnall a95ae0c182 ci: Temporarily disable code coverage support
lcov in F30 doesn’t support gcc in F30, which seems like a fairly
massive oversight.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-13 16:40:52 +01:00
Philip Withnall cc53f88d8d ci: Switch from Debian unstable to Fedora 30
Fedora has GLib ≥2.60.1, which we’ll need in an upcoming commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-13 16:34:14 +01:00
Philip Withnall c96ca4575c Merge branch 'docs' into 'master'
Improve README coverage of whole system design

See merge request pwithnall/malcontent!14
2019-06-12 16:11:18 +00:00
Philip Withnall be12b67e7a docs: Add missing dependency to README
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-12 07:54:59 +01:00
Philip Withnall 027ff10cc9 docs: Expand README coverage of how the whole system is designed
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-12 07:54:39 +01:00
Philip Withnall bb36bf65c6 Merge branch 'quiet' into 'master'
Implement --quiet in the check and set subcommands of malcontent-client

See merge request pwithnall/malcontent!13
2019-06-11 14:02:55 +00:00
Philip Withnall 4051a0292a malcontent-client: Implement --quiet for set subcommand
While not entirely quiet on error, the `set` subcommand is now quieter.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-11 15:01:08 +01:00
Philip Withnall b14fa7b056 malcontent-client: Implement --quiet for check subcommand
When run with `--quiet`, the `check` subcommand will now print nothing.
It continues to exit with an appropriate exit status.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-11 15:00:26 +01:00
Philip Withnall af44861281 Merge branch 'missing-field-initializers' into 'master'
libmalcontent: Add missing field initialisers to BUILDER_INIT

See merge request pwithnall/malcontent!12
2019-05-15 13:34:03 +00:00