Dont allow running the program as the root user

This commit is contained in:
dec05eba
2024-11-24 22:52:12 +01:00
parent 8644c72ac9
commit d472d8d41e
2 changed files with 11 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
option('systemd', type : 'boolean', value : true, description : 'Install systemd service file')
option('capabilities', type : 'boolean', value : true, description : 'Set binary admin capability to remove password prompt when recording monitor (without desktop portal option) on amd/intel or nvidia wayland')
option('capabilities', type : 'boolean', value : true, description : 'Set binary admin capability on gsr-kms-server binary to remove password prompt when recording monitor (without desktop portal option) on amd/intel or nvidia wayland')
option('nvidia_suspend_fix', type : 'boolean', value : true, description : 'Install nvidia modprobe config file to tell nvidia driver to preserve video memory on suspend. This is a workaround for an nvidia driver bug that breaks cuda (and gpu screen recorder) on suspend')
option('portal', type : 'boolean', value : true, description : 'Build with support for xdg desktop portal ScreenCast capture (wayland only) (-w portal option)')
option('app_audio', type : 'boolean', value : true, description : 'Build with support for recording a single audio source (-aa option). Requires pipewire')
option('app_audio', type : 'boolean', value : true, description : 'Build with support for recording a single audio source (-aa option). Requires pipewire')

View File

@@ -1123,9 +1123,10 @@ static void usage_full() {
fprintf(stderr, " Optional when using '-bm qp' or '-bm vbr' options, set to 'very_high' be default.\n");
fprintf(stderr, " Required when using '-bm cbr' option.\n");
fprintf(stderr, "\n");
fprintf(stderr, " -r Replay buffer size in seconds. If this is set, then only the last seconds as set by this option will be stored\n");
fprintf(stderr, " and the video will only be saved when the gpu-screen-recorder is closed. This feature is similar to Nvidia's instant replay feature.\n");
fprintf(stderr, " This option has be between 5 and 1200. Note that the replay buffer size will not always be precise, because of keyframes. Optional, disabled by default.\n");
fprintf(stderr, " -r Replay buffer time in seconds. If this is set, then only the last seconds as set by this option will be stored\n");
fprintf(stderr, " and the video will only be saved when the gpu-screen-recorder is closed. This feature is similar to Nvidia's instant replay feature This option has be between 5 and 1200.\n");
fprintf(stderr, " Note that the video data is stored in RAM, so don't use too long replay buffer time and use constant bitrate option (-bm cbr) to prevent RAM usage from going too high in busy scenes.\n");
fprintf(stderr, " Optional, disabled by default.\n");
fprintf(stderr, "\n");
fprintf(stderr, " -k Video codec to use. Should be either 'auto', 'h264', 'hevc', 'av1', 'vp8', 'vp9', 'hevc_hdr', 'av1_hdr', 'hevc_10bit' or 'av1_10bit'.\n");
fprintf(stderr, " Optional, set to 'auto' by default which defaults to 'h264'. Forcefully set to 'h264' if the file container type is 'flv'.\n");
@@ -2981,6 +2982,11 @@ int main(int argc, char **argv) {
// Same as above, but for amd/intel
unsetenv("vblank_mode");
if(geteuid() == 0) {
fprintf(stderr, "Error: don't run gpu-screen-recorder as the root user\n");
_exit(1);
}
if(argc <= 1)
usage_full();