19 Commits

Author SHA1 Message Date
Alex Smith
058efe8cce Use Meson's warning_level option
Set this to 3, and then remove extra warning flags that are already included
by enabling this (#107).
2019-03-10 10:20:29 +00:00
Térence Clastres
5f91922506 Add with-pam-group meson option
This adds 10-gamemode.conf as a limits.d configuration file and with-pam-group meson option to allow renicing as an unpriviledged user being part of the specified group.

Signed-off-by: Térence Clastres <t.clastres@gmail.com>
Signed-off-by: Kai Krakow <kai@kaishome.de>
2018-12-07 21:50:58 +01:00
Alex Smith
2ae86fabd6 Update to version 1.3-dev post-1.2 release 2018-07-21 09:48:40 +01:00
Alex Smith
c3938599a8 Update to version 1.2 2018-07-21 09:33:32 +01:00
Christian Kellner
cd54ad42c3 data: make service dbus-activatable
Always install the dbus service file and specify the systemd
unit file in it. This makes the service dbus-activatable and
thus we don't need to explicitly enable it (also we have one
less daemon running, if it is not needed).
2018-06-28 19:23:02 +03:00
Marc Di Luzio
d9072607d9 Label master as 1.2-dev 2018-05-11 14:53:30 +01:00
Marc Di Luzio
fb2f3c628a Update to 1.1 ready for release 2018-04-25 15:50:05 +01:00
Marc Di Luzio
4f14c807ba 1.0: Finalised for release
Updating the README.md to bring it ready for wider release:
* Removed some points that were more implementation details
* Added Contributions section
* Simplified the usage section
* Expanded initial explanation
* Fixed steam launch command to allow the overlay to still work

Others:
* Mark as 1.0
* Update the license file for 2018
2018-04-04 10:06:23 +01:00
Marc Di Luzio
759cbc3c40 Add config file parsing
Checks for a gamemode.ini in /usr/share/gamemode/ (or in the cwd for debugging)

	Currently allows for blacklisting and whitelisting clients based on rudimentary needle-haystack executable name checks

	See the example/gamemode.ini file for expected syntax

	Using the BSD licensed inih library (with additional meson.build file)
2018-03-23 16:59:15 +00:00
Marc Di Luzio
142246366f Add -h and -v and augment the usage text with option descriptions 2018-03-23 16:59:15 +00:00
Marc Di Luzio
72e24b5292 Update meson.build for 0.3 development 2018-03-23 16:59:13 +00:00
Ikey Doherty
7f26122c62 Allow controlling whether systemd is used or not
Currently this will switch the build system between using a plain D-BUS
service file, or a user controllable systemd unit that can be actively
stopped/started.

In most cases it is more desirable to use the systemd unit approach,
as plain D-BUS services cannot be controlled and are more difficult
to introspect via the log.

For fallback cases we'll have the plain D-BUS unit, and in future we
can use this to allow untying from systemd specifics.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-03-05 17:32:43 +00:00
Ikey Doherty
e90bd98d64 Enforce strict compiler warnings
This exposed a bunch of issues that needed dealing with to ensure the
code is clean and sane. Notably the dlopen/dlsym routine has been altered
to closer match the LSI approach of safe symbol binding, by not attempting
to directly cast the result of a dlsym operation. Instead, if we succeed
in getting the dlsym() pointer, we memcpy this to the target and ensure
we have the correct constraints.

Note that in sanitizing the log helpers, I opted to remove the varargs
ability from FATAL_ERRNO given this is used exactly like perror() and
there are no examples currently using varargs with this in the tree.
This allowed me to keep the log helpers as macros and not have to implement
wrapper functions.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-03-05 17:32:26 +00:00
Ikey Doherty
68e326de60 Transform into a full D-BUS service with Polkit support
Primarily we convert the service into a thread safe one that isn't reliant
on signaling for control flow, eliminating data race conditions. We also
enable interleaving by separating game mode pivoting from explicit client
registration.

The static pid list is now converted into a dynamic list that is OOM safe
to store all registered clients (with a reasonable upper limit of 256 clients)
to better handle cases where LD_PRELOAD is used for a large process group.
Additionally we begin storing some metadata on the connected clients such
as their executable path, which will enable us to perform some basic
whitelisting in future.

The cpugovctl binary is now moved into the libexecdir as an explicit helper
of the D-BUS service, using the shared library to merge some code back into
the daemon. This saves having to execute a process to query the state of the
governors, as we don't need a privileged client to do this.

In order to sanely set the governors, we require that the binary is running
as euid 0, and execute this using `pkexec`. A PolKit policy definition is
provided which allows active/logged in users to execute this helper through
a path whitelist. As such we can convert the daemon into user-mode only, with
the privileged helper being dispatched exclusively via polkit. This removes
the need for a setuid helper or having a system mode daemon.

Lastly we clean up the codebase a bit to be consistent with modern C code
conventions, using pragmas where available. The library component still uses
the older ifdef approach to support older compilers, but the daemon portion
uses the directive to simplify intent and speed up compilation. Additionally
we move all comments to C style comments for consistency, instead of mixing
in C++ style single line comments, in order to establish a formal coding
style.

The net result is a more robust service which can be D-BUS activated when
clients need it, that can perform scaling automatically without harassing
the user with authentication popups.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-03-05 17:32:25 +00:00
Ikey Doherty
cc931a6237 Add new meson options to suppress compilation of daemon and examples
This makes it quicker and easier to build multilib + multiarch variants
of the library without having to compile the larget host-arch specific
daemon. This is required for using the automatic LD_PRELOAD module with
older 32-bit games on a 64-bit host, to ensure they all have access to
the library.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-03-05 17:32:02 +00:00
Ikey Doherty
1328e07f86 Split meson up to be more modular
This also explicitly constructs reusable library components to make it
easier to extend the project over time. Notably we make less assumptions
about the host system and use pkgconfig where appropriate to give us
system details, such as the systemd system unit directory for packaging.
This can be overriden with the meson option.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-03-05 17:32:01 +00:00
Marc Di Luzio
47b76f1496 Set meson C language to C11
This'll allow for C11 Atomics
2018-03-05 17:32:01 +00:00
Marc Di Luzio
0cb31eccbe Update meson.build to 0.2 for development 2018-03-05 17:32:01 +00:00
Marc Di Luzio
c459c05076 Initial 0.1 commit
This is a small daemon/libary to enable games to request a
performance "game mode" from the system.

Currently only implemented to upgrade the CPU governor and
automatically downgrade it once done.

A game only needs to load libgamemodeauto to activate the request.
Which means an LD_PRELOAD can be applied to any game to activate
the mode as needed.

However gamemode_client.h can be used to manually activate/deactivate
the mode as needed, and also perform error checking.

The libs are miminal loaders to call into an installed libgamemode
which, if the daemon is installed and running, will send through
the equivelant game mode request, and magic will happen.

See the README.md for more details.

Currently licensed under the BSD 3 clause license.
2018-03-05 17:32:01 +00:00