Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mount host directories with given user permissions #2246

Open
habibifa opened this issue Mar 13, 2024 · 6 comments
Open

mount host directories with given user permissions #2246

habibifa opened this issue Mar 13, 2024 · 6 comments
Labels
component/qemu/9p question Further information is requested

Comments

@habibifa
Copy link

Description

In my ubuntu vm which is created by limactl I have shared the /var/www directory of my host as writable. Now on my ubuntu vm I have installed the apache2 which runs under group www-data. so to sum it up the content of my website is located under
/var/www on my host-pc and the apache2 runs inside of vm. My website creates other websites that are also in the /var/www/[WEBSITE]. everything sofar is good. Except the files of the new generated website have root permissions for the group and the owner. This should not be the case, because of the www-data user of apache creating or cloning those files via git. Is this a bug or can I pass the owner and group in the .yaml file of my vm

I hope to hear from you soon.
Thanks in advance.

@AkihiroSuda
Copy link
Member

Please try this

mounts:
- location: "..."
  9p:
    securityModel: "mapped-xattr"
mountType: "9p"

9p:
# Supported security models are "passthrough", "mapped-xattr", "mapped-file" and "none".
# "mapped-xattr" and "mapped-file" are useful for persistent chown but incompatible with symlinks.
# 🟢 Builtin default: "none" (since Lima v0.13)
securityModel: null

@AkihiroSuda AkihiroSuda added question Further information is requested component/qemu/9p labels Mar 13, 2024
@habibifa
Copy link
Author

Thank you for your prompt answer,

i tried the snipped you posted. unfortunately it does not work for sumlinks which are crucial in my project.
mounts:

  • location: "~/lima/default"
    writable: true
  • location: "/var/www"
    writable: true
    9p:
    securityModel: "mapped-xattr"
  • location: "/etc/cner20"
    writable: true
    mountType: "9p"

Some how as i used this method my apache web server got very slow.

thanks in advance:)

@afbjorklund
Copy link
Contributor

afbjorklund commented Mar 14, 2024

I think it would be possible to add a similar feature to the sshfs mount, if needed.

       -o idmap=TYPE
              user/group ID mapping (default: "none")

               none   no translation of the ID space

               user   only translate UID/GID of connecting user

               file   translate UIDs/GIDs based upon the contents of uidfile  and gidfile

       -o uidfile=FILE
              file containing username:uid mappings for idmap=file

       -o gidfile=FILE
              file containing groupname:gid mappings for idmap=file

       -o nomap=TYPE
              with idmap=file, how to handle missing mappings

               ignore don't do any re-mapping

               error  return an error (default)

@afbjorklund
Copy link
Contributor

afbjorklund commented Mar 14, 2024

Some how as i used this method my apache web server got very slow.

It is better to serve the files from a local filesystem, but you need to set up some method to sync the contents.

That is, to copy the files from the host to the instance. The file ownership could be changed during that process.

@habibifa
Copy link
Author

I am not sure if I understand the snippet you have just posted. Would you mind make those changes to my snippet so i can understand where to put the options?

@afbjorklund
Copy link
Contributor

I am not sure if I understand the snippet you have just posted.

It would require code changes to lima, so is a separate feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/qemu/9p question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants