ANDROID: umh: Enable usermode helper for required use cases

For disabling usermode helper programs config STATIC_USERMODEHELPER_PATH
was set to NULL string. There are few use cases where usermode helper
programs support is needed, such as reboot, poweroff use cases.
So for these supported use cases, dont set the sub_info->path
to null to get usermode helper program support.

Bug: 202192667
Change-Id: I3e4cec94d091b23eda9d2be839cc8f960127575f
Signed-off-by: Prasad Sodagudi <quic_psodagud@quicinc.com>
This commit is contained in:
Prasad Sodagudi 2022-05-31 15:54:09 -07:00 committed by Todd Kjos
parent 50a2b178c5
commit c555553a40
1 changed files with 30 additions and 0 deletions

View File

@ -332,6 +332,33 @@ static void helper_unlock(void)
wake_up(&running_helpers_waitq);
}
/**
* Android supported usermode helper executables.
*
*/
static const char * const usermode_executable_path[] = {
"/sbin/reboot",
"/sbin/poweroff"
};
static bool check_usermodehelper_supported_commands(const char *path)
{
int i;
if (!strlen(path))
return false;
/*
* Check path is part of ANDROID supported usermode helper executables or not.
* Googlge and OEMs can add supported executables to usermode_executable_path.
*/
for (i = 0; i < ARRAY_SIZE(usermode_executable_path); i++)
if (!strcmp(path, usermode_executable_path[i]))
return true;
return false;
}
/**
* call_usermodehelper_setup - prepare to call a usermode helper
* @path: path to usermode executable
@ -373,6 +400,9 @@ struct subprocess_info *call_usermodehelper_setup(const char *path, char **argv,
#else
sub_info->path = path;
#endif
if (check_usermodehelper_supported_commands(path))
sub_info->path = path;
sub_info->argv = argv;
sub_info->envp = envp;