Development notes #1

Open
opened 2025-02-10 13:40:40 +00:00 by Sirherobrine23 · 0 comments

Write proot directly in Golang

Features

  • Chroot
  • Binding
  • Qemu
  • Kernel Release string
  • Exec
    • Syscall's

Dev Notes

  1. in proot, this code start proot tracee with pid current process pid:

    src/cli/cli.c Lines 466 to 470 in 5f780cba57
    /* Pre-create the first tracee (pid == 0). */
    tracee = get_tracee(NULL, 0, true);
    if (tracee == NULL)
    goto error;
    tracee->pid = getpid();

  2. Parse cli options:

    src/cli/cli.c Lines 473 to 475 in 5f780cba57
    status = parse_config(tracee, argc, argv);
    if (status < 0)
    goto error;

  3. Fork process and add child fork to root tracee:

    src/cli/cli.c Lines 478 to 482 in 5f780cba57
    status = launch_process(tracee, &argv[status]);
    if (status < 0) {
    print_execve_help(tracee, tracee->exe, status);
    goto error;
    }

  4. Watcher process child and process fakeroot and another callsystem's:

    exit(event_loop());

Notes

  • Vpids translate all systemcall's file open (read, write, stats, etc...) from file requested => rootfs path + file requested (creating fakeroot)

launch_process

  1. Start file path fd capture and resolve to Rootfs
  2. Fork process
  3. add pid to root tracee tracee->pid
Write proot directly in Golang # Features - [ ] Chroot - [ ] Binding - [ ] Qemu - [ ] Kernel Release string - [ ] Exec - [x] Syscall's # Dev Notes 1. in proot, this code start `proot tracee` with pid current process pid: https://sirherobrine23.com.br/proot-me/proot/src/commit/5f780cba57ce7ce557a389e1572e0d30026fcbca/src/cli/cli.c#L466-L470 1. Parse cli options: https://sirherobrine23.com.br/proot-me/proot/src/commit/5f780cba57ce7ce557a389e1572e0d30026fcbca/src/cli/cli.c#L473-L475 1. Fork process and add child fork to root tracee: https://sirherobrine23.com.br/proot-me/proot/src/commit/5f780cba57ce7ce557a389e1572e0d30026fcbca/src/cli/cli.c#L478-L482 1. Watcher process child and process `fakeroot` and another callsystem's: https://sirherobrine23.com.br/proot-me/proot/src/commit/5f780cba57ce7ce557a389e1572e0d30026fcbca/src/cli/cli.c#L485 ## Notes - Vpids translate all systemcall's file open (read, write, stats, etc...) from `file requested` => `rootfs path` + `file requested` (creating fakeroot) ### launch_process 1. ~~Start file path fd capture and resolve to Rootfs~~ 2. Fork process 4. add pid to root tracee `tracee->pid`
Sirherobrine23 added the
Kind/Documentation
label 2025-02-10 13:40:40 +00:00
Sign in to join this conversation.
No description provided.