mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 07:37:21 +02:00
Use run_external_process for the script execution
This protects the main process against script exection and allows more detailed error handling
This commit is contained in:
parent
5facf2bba5
commit
1665447350
@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <unistd.h>
|
||||
|
||||
#include "daemon_config.h"
|
||||
#include "external-helper.h"
|
||||
#include "gamemode_client.h"
|
||||
#include "governors-query.h"
|
||||
#include "gpu-control.h"
|
||||
@ -370,7 +371,8 @@ static int run_custom_scripts_tests(struct GameModeConfig *config)
|
||||
while (*startscripts[i] != '\0' && i < CONFIG_LIST_MAX) {
|
||||
LOG_MSG(":::: Running start script [%s]\n", startscripts[i]);
|
||||
|
||||
int ret = system(startscripts[i]);
|
||||
const char *args[] = { "/bin/sh", "-c", startscripts[i], NULL };
|
||||
int ret = run_external_process(args);
|
||||
|
||||
if (ret == 0)
|
||||
LOG_MSG(":::: Passed\n");
|
||||
@ -392,7 +394,8 @@ static int run_custom_scripts_tests(struct GameModeConfig *config)
|
||||
while (*endscripts[i] != '\0' && i < CONFIG_LIST_MAX) {
|
||||
LOG_MSG(":::: Running end script [%s]\n", endscripts[i]);
|
||||
|
||||
int ret = system(endscripts[i]);
|
||||
const char *args[] = { "/bin/sh", "-c", endscripts[i], NULL };
|
||||
int ret = run_external_process(args);
|
||||
|
||||
if (ret == 0)
|
||||
LOG_MSG(":::: Passed\n");
|
||||
|
@ -692,7 +692,8 @@ static void game_mode_execute_scripts(char scripts[CONFIG_LIST_MAX][CONFIG_VALUE
|
||||
while (*scripts[i] != '\0' && i < CONFIG_LIST_MAX) {
|
||||
LOG_MSG("Executing script [%s]\n", scripts[i]);
|
||||
int err;
|
||||
if ((err = system(scripts[i])) != 0) {
|
||||
const char *args[] = { "/bin/sh", "-c", scripts[i], NULL };
|
||||
if ((err = run_external_process(args)) != 0) {
|
||||
/* Log the failure, but this is not fatal */
|
||||
LOG_ERROR("Script [%s] failed with error %d\n", scripts[i], err);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user