mini.c: The main implementationmini: The compiled executable/.mini.d/: Directory containing executable files to be scanned and executed (default directory, can be overridden with MINI_DIR environment variable)The program uses opendir() and readdir() functions to iterate through all files in the /.mini.d/ directory (or the directory specified by the MINI_DIR environment variable).
The is_executable() function checks if a file is executable by:
stat() to get file informationS_ISREG)S_IXUSR)For each executable file found, the program:
fork() to create a child processexecl() to replace the process with the executable filewaitpid() to wait for the child process to completeThree sample files are included in /.mini.d/:
script1.sh: A bash script that prints its argumentsscript2.sh: A bash script that lists the root directoryprogram: A compiled C program that prints a message and its process IDprogram.c: The source code for the C program (not executable)Checks if a file is executable.
filepath - Path to the fileExecutes a file using fork & exec.
filepath - Path to the executable fileScans a directory for executable files and executes them.
dir_path - Path to the directory to scanSpecifies the directory to scan for executable files. If not set, the program defaults to /.mini.d/.
Example:
# Use custom directory
MINI_DIR=./scripts ./mini
# Use default directory (/.mini.d/)
./mini
# Compile the scanner
gcc -o mini mini.c
# Run the scanner (uses /.mini.d/ by default)
./mini
# Run the scanner with custom directory
MINI_DIR=./my_scripts ./mini
docker build -o type=local,dest=dist -f Dockerfile.build .