Linux kernel that runs python file for init

Would it be possible and not incredibly difficult to build a Linux kernel using a python interpreter built-in or accessible from the kernel that could run the python file as it runs?

+3
source share
2 answers

Can't you just replace /sbin/initor provide a parameter to the init=...loader? Just make sure you put python + libs in the root file system.

edit I did not want to beat the system, so it was not tested, but looked at linux/init/main.c:

static void run_init_process(char *init_filename)
{
    argv_init[0] = init_filename;
    kernel_execve(init_filename, argv_init, envp_init);
}

, (python) script init; execve - , . , stdin stdout /dev/console, init=/bin/sh . ( ?)

+6

, init C-; script #! ; , python .

, inittab, init ( ).

, , , - , python (, mount), , , busybox () ; "init" busybox .

+2

Source: https://habr.com/ru/post/1757742/


All Articles