Implement Set_Kernelstub and attempt to elevate to sudo using STDIN and then attempt to remove the password from the program memory

This commit is contained in:
HikariKnight 2023-04-11 01:03:59 +02:00
parent ca992bf864
commit 7081bfa8d7
5 changed files with 81 additions and 13 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"strings"
"github.com/HikariKnight/quickpassthrough/internal/logger"
"github.com/HikariKnight/quickpassthrough/pkg/command"
"github.com/HikariKnight/quickpassthrough/pkg/fileio"
"github.com/klauspost/cpuid/v2"
@ -63,5 +64,15 @@ func Set_Cmdline(gpu_IDs []string) {
// TODO2: look into grubby
// TODO3: if unknown bootloader, tell user what to add a kernel arguments
func Set_KernelStub() {
// Get the config
config := GetConfig()
// Get the kernel args
kernel_args := fileio.ReadFile(config.Path.CMDLINE)
// Write to logger
logger.Printf("Running command:\nsudo kernelstub -a \"%s\"", kernel_args)
// Run the command
command.Run("sudo", "kernelstub", "-a", kernel_args)
}