Re: How to launch a bhyve vm as normal user,without being root

From: Mario Marietto <marietto2008_at_gmail.com>
Date: Mon, 17 Jun 2024 23:26:32 UTC
I want to keep the bhyve scripts in /bhyve and I've added the path /bhyve
to /home/marietto/.zshrc and on /root/.zshrc like this :

# sudo nano /home/marietto/.zshrc

export PATH=/bhyve:$PATH
# zsh autocompletion for sudo and doas
zstyle ":completion:*:(sudo|su|doas):*" command-path /usr/local/bin
/usr/local/sbin /usr/sbin /usr/bin /bin /sbin /bhyve


and in /root/.zshrc :

# sudo nano /root/.zshrc

export PATH=/bhyve:$PATH
# zsh autocompletion for sudo and doas
zstyle ":completion:*:(sudo|su|doas):*" command-path /usr/local/bin
/usr/local/sbin /usr/sbin /usr/bin /bin /sbin /bhyve


with :

nano /usr/local/etc/doas.conf :

permit nopass :wheel as root cmd bhyve-win
permit nopass :wheel as root cmd bhyve-lin
permit nopass :wheel as root cmd /bhyve/12-Win-11-vm12


but when I try to run the vm like this :

[marietto@marietto /bhyve]==> doas 10-Debian-Now_wine-tkg-vm10


it says :

doas: Operation not permitted


even if /bhyve is in $PATH :

[marietto@marietto /bhyve]==> echo $PATH
/bhyve:/home/marietto/bin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin


and it is also on :

zstyle ":completion:*:(sudo|su|doas):*" command-path


If I keep the bhyve scripts in /usr/sbin,it works. But I want to keep the
bhyve scripts in /bhyve.

I found how it works :

[marietto@marietto /bhyve]==> doas /bhyve/12-Win-11-vm12

I expect that this :

[marietto@marietto /bhyve]==> doas 12-Win-11-vm12

works. And I would like to use it instead of doing : doas
/bhyve/12-Win-11-vm12.



On Tue, Jun 18, 2024 at 12:36 AM Dave Cottlehuber <dch@skunkwerks.at> wrote:

> On Mon, 17 Jun 2024, at 17:39, Mario Marietto wrote:
> > [marietto@marietto /bhyve]==> sudo cp 12-Win-11-vm12 /usr/sbin
>
> this filepath is /usr/sbin/12-Win-11-vm12
>
> > permit nopass :wheel as root cmd /usr/sbin/bhyve-win
>
> this file path is /usr/sbin/bhyve-win
>
> these things need to be identical, like in the hallo example.
>
> > permit nopass :wheel as root cmd /usr/sbin/bhyve-win
>
> should be
>
> permit nopass :wheel as root cmd /usr/sbin/12-Win-11-vm12
>
> A+
> Dave
>


-- 
Mario.