![]() |
EpiRootkit
By STDBOOL
|
#include <linux/kmod.h>#include <linux/slab.h>#include <linux/string.h>#include <linux/types.h>#include "epirootkit.h"Go to the source code of this file.
Functions | |
| static char * | trim_leading_whitespace (char *str) |
| static void | detect_redirections (const char *cmd, bool *redirect_stdout, bool *redirect_stderr) |
| static char * | build_timeout_prefix (int timeout) |
| static int | build_full_command (char *buffer, size_t buffer_size, const char *timeout_cmd, const char *user_cmd, bool redirect_stdout, bool redirect_stderr, bool catch_stds, const char *stdout_file, const char *stderr_file) |
| static int | execute_command (const char *cmd_str, char *envp[]) |
| int | exec_str_as_command_with_timeout (char *user_cmd, bool catch_stds, int timeout) |
|
static |
build_full_command - Constructs the full shell command with redirections and timeout
| buffer | Destination buffer to store the final command string |
| buffer_size | Size of the destination buffer |
| timeout_cmd | Timeout prefix command |
| user_cmd | User-supplied command |
| redirect_stdout | True if stdout is redirected |
| redirect_stderr | True if stderr is redirected |
| catch_stds | True if we need to redirect output ourselves |
| stdout_file | File to redirect stdout to (if needed) |
| stderr_file | File to redirect stderr to (if needed) Return: 0 on success, -EINVAL if the resulting command exceeds buffer size. |
Definition at line 71 of file userland.c.
|
static |
build_timeout_prefix - Constructs a timeout command prefix
| timeout | Timeout duration in seconds |
If timeout is greater than 0, constructs a timeout command with signal and status options.
Return: Dynamically allocated string with the timeout prefix or an empty string. Caller must kfree() the returned string.
Definition at line 44 of file userland.c.
|
static |
detect_redirections - Detects stdout and stderr redirection in a command string
| cmd | Command string to parse |
| redirect_stdout | Set to true if stdout is redirected |
| redirect_stderr | Set to true if stderr is redirected |
Definition at line 25 of file userland.c.
| int exec_str_as_command_with_timeout | ( | char * | user_cmd, |
| bool | catch_stds, | ||
| int | timeout | ||
| ) |
exec_str_as_command_with_timeout - Executes a user command with optional timeout and output redirection
| user_cmd | Command string to execute |
| catch_stds | Whether to redirect stdout and stderr to predefined files |
| timeout | Timeout in seconds for the command; 0 means no timeout |
Constructs the final command string with timeout and redirection logic, then executes it in usermode using the kernel's usermodehelper API.
Return: Exit status of the command, or negative error code on failure.
Definition at line 139 of file userland.c.
|
static |
execute_command - Executes a shell command in usermode
| cmd_str | Full shell command string to execute |
| envp | Array of environment variables Return: Exit status of the command, or error code on failure. |
Definition at line 116 of file userland.c.
|
static |
trim_leading_whitespace - Remove leading whitespace from a string
| str | Input string Return: Pointer to the first non-whitespace character. |
Definition at line 13 of file userland.c.