Skip to content

Comments

muvm-guest: Support root and user init scripts#87

Closed
hoshinolina wants to merge 1 commit intoAsahiLinux:mainfrom
hoshinolina:initscript
Closed

muvm-guest: Support root and user init scripts#87
hoshinolina wants to merge 1 commit intoAsahiLinux:mainfrom
hoshinolina:initscript

Conversation

@hoshinolina
Copy link
Contributor

Introduce two scripts that can be placed in ~/.local/share/muvm

  • init.sh: Executed as root, before dropping privileges
  • user.sh: Executed as the user, after dropping privileges

If the files are also present in lower-priority XDG dirs (systemwide), those are executed first.

This makes it possible to add custom VM configuration and setup or debugging scripts without having to hack on the muvm code.

Introduce two scripts that can be placed in ~/.local/share/muvm

- init.sh: Executed as root, before dropping privileges
- user.sh: Executed as the user, after dropping privileges

If the files are also present in lower-priority XDG dirs (systemwide),
those are executed first.

This makes it possible to add custom VM configuration and setup or
debugging scripts without having to hack on the muvm code.

Signed-off-by: Asahi Lina <lina@asahilina.net>
// See https://doc.rust-lang.org/std/env/fn.set_var.html#safety
env::set_var("HOME", user.dir);
let xdg_dirs = xdg::BaseDirectories::with_prefix("muvm")?;
// SAFETY: Safe if and only if `muvm-guest` program is not multithreaded.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @slp for #64 interaction

@slp
Copy link
Collaborator

slp commented Oct 16, 2024

I think I understand the motivation, but I'm afraid this may open the floods to users implementing all shorts of hacks behind muvm-guest's back. If it's intended just for developing purposes, the role of user.sh could be achieved by calling it as the first program in the guest, and for the role of root.sh, #89 will allow launching programs as root in the guest (and, combined with #48, it'll also be possible to have a root shell).

Beyond developing purposes, I think the configuration to the VM should be applied by muvm-guest itself.

@hoshinolina
Copy link
Contributor Author

Closing in favor of #89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants