Vagrant 同步文件夹权限 [英] Vagrant synced folder permissions

查看:48
本文介绍了Vagrant 同步文件夹权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Vagrant 中设置了一个同步文件夹,从我的 Windows 主机到来宾.最初对文件的权限太开放,所以我添加了以下挂载选项:

I have set up a synced folder in Vagrant, from my Windows host to the guest. Initially the permissions on the files were too open so I added the following mount options:

config.vm.synced_folder "../my-folder", "/home/vagrant/my-folder",
    mount_options: ["dmode=775,fmode=664"]

但是,我需要为此文件夹中的单个文件添加执行权限.chmod +x file 无效.有没有办法允许共享文件夹中的单个项目可执行/对文件夹中的其余项目具有不同的权限?

However, I need to add execute permissions on a single file within this folder. chmod +x file has no effect. Is there a way to allow a single item in a shared folder to be executable/have different permissions to the rest of the items in the folder?

推荐答案

最后想出了两个解决方案:

In the end, I came up with two solutions:

1) 接受所有可执行的文件

1) Accept all the files being executable

config.vm.synced_folder "../my-folder", "/home/vagrant/my-folder",
    mount_options: ["dmode=775,fmode=777"]

2) 使用 rsync 方法同步文件夹

2) Use the rsync method to synchronise the folders

config.vm.synced_folder "../ansible-provision", "/home/vagrant/ansible", type: "rsync",
    rsync__exclude: ".git/"

每种方法都有其自身的缺点,但第一种方法实现最快且对我的用例来说是可以接受的,所以我采用了它.

Each method has its own drawbacks, but the first was quickest to implement and acceptable for my use case, so I went with that.

这篇关于Vagrant 同步文件夹权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆