Patreon Logo Support us on Patreon to keep GamingOnLinux alive. This ensures all of our main content remains free for everyone. Just good, fresh content! Alternatively, you can donate through PayPal Logo PayPal. You can also buy games using our partner links for GOG and Humble Store.
Latest Comments by Nevertheless
Feral Interactive have released an open source tool that’ll help get the most performance out of Linux games
11 Apr 2018 at 12:18 pm UTC

Quoting: OlliC
Quoting: Nevertheless
Quoting: OlliC
Quoting: NeverthelessEdit: I guess I will be using Ferals programm sooner or later anyway. I just don't like running root daemons without even having the time to read the source code.. or better, having some security experts reading the sourcecode. Don't get me wrong, I do trust Feral, but a daemon is in a delicate position, and even small flaws can be exploited.


It's not a root daemon. It runs as a normal user using systemds usermode and polkit.
And how does it apply CPU governor changes?
By using Polkit. I think it also logs something about executing pkexec. Start the daemon and follow the logs with 'journalctl -f --user-unit gamemoded'.
Interesting! Thanks for the info!

Feral Interactive have released an open source tool that’ll help get the most performance out of Linux games
11 Apr 2018 at 10:53 am UTC

Quoting: OlliC
Quoting: NeverthelessEdit: I guess I will be using Ferals programm sooner or later anyway. I just don't like running root daemons without even having the time to read the source code.. or better, having some security experts reading the sourcecode. Don't get me wrong, I do trust Feral, but a daemon is in a delicate position, and even small flaws can be exploited.


It's not a root daemon. It runs as a normal user using systemds usermode and polkit.
And how does it apply CPU governor changes?

Feral Interactive have released an open source tool that’ll help get the most performance out of Linux games
11 Apr 2018 at 10:10 am UTC

Quoting: marcus
Quoting: Nevertheless
Quoting: mike44Good but I would prefer not to install anything. Could we simply run a command before and after playing?
I found a simple suid program on the net, which I just had to change a bit to do the right things.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid( 0 );
system( "echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" );

return 0;
}

and to set it back to powersave:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid( 0 );
system( "echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" );

return 0;
}
This is really bogus, broken code ...
The setuid command is useless since
  • a) you are already root (per chmod u+s)

  • b) you would not be able to elevate your privileges like that if you were not. That would be a security hole. The purpose of setuid is to drop privileges when you are already root. Not to elevate them (see man setuid).



Using sudo in the system commandline makes no sense as well. It is benign if you have a setuid root binary (i.e. does nothing, just leave it out). If you are not yet root it will ask of course but then you can really just use the commandline directly. Skip the c and use bash.
Oops, yes, sorry, pasted the wrong file. Strike the sudo! It doesn't hurt, but it's absolutely not needed.
Setuid is used in a lot of cases to elevate privileges. In mount, umount, su, sudo for example. In this case it gives me exactly what I want: I can switch the governor without having to provide a password. It does nothing more. So I don't see any risk.

Feral Interactive have released an open source tool that’ll help get the most performance out of Linux games
11 Apr 2018 at 6:27 am UTC Likes: 1

Quoting: Shmerl
Quoting: NeverthelessI found a simple suid program on the net, which I just had to change a bit to do the right things.
How do you set the resulting binary? I tried making it owned by root:root and then giving it setuid flag, but it still fails when setuid is called from it.
As you said it has to be owned by root, then

sudo chmod u+s binary

That works for me.

Edit: I guess I will be using Ferals programm sooner or later anyway. I just don't like running root daemons without even having the time to read the source code.. or better, having some security experts reading the sourcecode. Don't get me wrong, I do trust Feral, but a daemon is in a delicate position, and even small flaws can be exploited.

Feral Interactive have released an open source tool that’ll help get the most performance out of Linux games
10 Apr 2018 at 7:55 pm UTC Likes: 3

Quoting: wvstolzing
Quoting: Nevertheless...
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid( 0 );
system( "echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" );

return 0;
}
...
Couldn't you do the same with something like
sudo sh -c 'echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor'
Does it have to be compiled C code?
Yes you could. But you had to provide your password before you start your game and after you quit it. You can't setuid a bash script, so a binary helps there.

Feral Interactive have released an open source tool that’ll help get the most performance out of Linux games
10 Apr 2018 at 6:54 pm UTC Likes: 2

Quoting: mike44Good but I would prefer not to install anything. Could we simply run a command before and after playing?
I found a simple suid program on the net, which I just had to change a bit to do the right things.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid( 0 );
system( "echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" );

return 0;
}

and to set it back to powersave:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
setuid( 0 );
system( "echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor" );

return 0;
}

Feral Interactive have released an open source tool that’ll help get the most performance out of Linux games
10 Apr 2018 at 3:55 pm UTC

Quoting: lucifertdark
Quoting: Nevertheless
Quoting: lucifertdark./bootstrap.sh
+ meson --prefix=/usr build -Dwith-systemd-user-unit-dir=/etc/systemd/user
The Meson build system
Version: 0.29.0
Source dir: /home/user/gamemode
Build dir: /home/user/gamemode/build
Build type: native build
Build machine cpu family: x86_64
Build machine cpu: x86_64
Project name: gamemode
Native c compiler: cc (gcc 5.4.0-6ubuntu1)

Meson encountered an error in file meson.build, line 32, column 0:
Unknown function "join_paths".

It refuses to compile for me, followed the instructions to the letter, scratching my head right now, any help would be appreciated.
/home/"user"? Is that correct?
I guess I should have said I edited the output to remove my name.
No problem. It didn't fit the error anyway!

Feral Interactive have released an open source tool that’ll help get the most performance out of Linux games
10 Apr 2018 at 3:44 pm UTC

Quoting: lucifertdark./bootstrap.sh
+ meson --prefix=/usr build -Dwith-systemd-user-unit-dir=/etc/systemd/user
The Meson build system
Version: 0.29.0
Source dir: /home/user/gamemode
Build dir: /home/user/gamemode/build
Build type: native build
Build machine cpu family: x86_64
Build machine cpu: x86_64
Project name: gamemode
Native c compiler: cc (gcc 5.4.0-6ubuntu1)

Meson encountered an error in file meson.build, line 32, column 0:
Unknown function "join_paths".

It refuses to compile for me, followed the instructions to the letter, scratching my head right now, any help would be appreciated.
/home/"user"? Is that correct?

Edit.. ok forget it! :)

Feral Interactive have released an open source tool that’ll help get the most performance out of Linux games
10 Apr 2018 at 10:44 am UTC

Quoting: mike44Good but I would prefer not to install anything. Could we simply run a command before and after playing?
You could do all it does yourself in a script before and after playing. It will just need sudo to do anything.. That's what a daemon keeps away from the user.