Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check multiple paths for modprobe #390

Merged
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
47 changes: 45 additions & 2 deletions src/nwipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ int main( int argc, char** argv )
pthread_t nwipe_gui_thread = 0; // The thread ID of the GUI thread.
pthread_t nwipe_sigint_thread; // The thread ID of the sigint handler.

char modprobe_command[] = "modprobe %s";
char modprobe_command2[] = "modprobe %s";
char modprobe_command3[] = "modprobe %s";
char module_shortform[50];
char final_cmd_modprobe[sizeof( modprobe_command ) + sizeof( module_shortform )];

/* The entropy source file handle. */
int nwipe_entropy;

Expand Down Expand Up @@ -204,9 +210,46 @@ int main( int argc, char** argv )
}

/* Makesure the drivetemp module is loaded, else drives hwmon entries won't appear in /sys/class/hwmon */
if( system( "modprobe drivetemp" ) != 0 )
final_cmd_modprobe[0] = 0;

/* The kernel module we are going to load */
strcpy( module_shortform, "drivetemp" );

/* Determine whether we can access modprobe, required if the PATH environment is not setup ! (Debian sid 'su' as
* opposed to 'su -' */

if( system( "which modprobe > /dev/null 2>&1" ) )
{
if( system( "which /sbin/modprobe > /dev/null 2>&1" ) )
{
if( system( "which /usr/sbin/modprobe > /dev/null 2>&1" ) )
{
nwipe_log( NWIPE_LOG_WARNING, "modprobe command not found. Install kmod package (modprobe)) !" );
nwipe_log( NWIPE_LOG_WARNING, "Most temperature monitoring may be unavailable as module drivetemp" );
nwipe_log( NWIPE_LOG_WARNING, "could not be loaded. drivetemp is not available on kernels < v5.5" );
}
else
{
sprintf( final_cmd_modprobe, modprobe_command3, module_shortform );
}
}
else
{
sprintf( final_cmd_modprobe, modprobe_command2, module_shortform );
}
}
else
{
sprintf( final_cmd_modprobe, modprobe_command, module_shortform );
}

/* load the drivetemp module */
if( system( final_cmd_modprobe ) != 0 )
{
nwipe_log( NWIPE_LOG_WARNING, "hwmon: Unable to load module drivetemp, drivetemp may be build into kernel?" );
nwipe_log( NWIPE_LOG_WARNING, "hwmon: Unable to load module drivetemp, temperatures may be unavilable." );
nwipe_log( NWIPE_LOG_WARNING, "hwmon: It's possible the drivetemp software isn't modular but built-in" );
nwipe_log( NWIPE_LOG_WARNING, "hwmon: to the kernel, as is the case with ShredOS.x86_64 in which case" );
nwipe_log( NWIPE_LOG_WARNING, "hwmon: the temperatures will actually be available despite this issue." );
}
else
{
Expand Down