Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions modprobe-utils/nvidia-modprobe-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ static int modprobe_helper(const int print_errors, const char *module_name,
{
char modprobe_path[NV_PROC_MODPROBE_PATH_MAX];
int status = 1;
int euid;
struct stat file_status;
pid_t pid;
const char * const argv[] = { "modprobe", module_name, NULL };
Expand Down Expand Up @@ -217,11 +218,15 @@ static int modprobe_helper(const int print_errors, const char *module_name,

/* Only attempt to load the kernel module if root. */

if (geteuid() != 0)
if ((euid = geteuid()) != 0)
{
return 0;
fprintf(stderr, "euid (%d) not root\n", euid);
return 0;
}

/* Modprobe might call shell scripts and shells revert to real uid */
setuid(euid); /* Set ruid = euid */

/*
* Before attempting to load the module, look for any NVIDIA PCI devices.
* If none exist, exit instead of attempting the modprobe, because doing so
Expand Down Expand Up @@ -300,7 +305,8 @@ static int modprobe_helper(const int print_errors, const char *module_name,

/* Fork and exec modprobe from the child process. */

file_actions = silence_process_actions();
/* file_actions = silence_process_actions(); */
file_actions = NULL; /* Warnings, if they occur, are helpful! */

/*
* POSIX specifies that the argv and envp arguments are arrays of non-const
Expand Down