-
Notifications
You must be signed in to change notification settings - Fork 181
Shared folders permission problem #151
Comments
Same here. Output looks like this:
More:
|
yeah, that also happened to me while using vagrant-cachier =/ I did some research last night and it seems that it is not possible to bind mount the folders using a different uid / gid. |
For the record, I'm planning to add support for NFS on the next release of vagrant-lxc. I've been taking a break from it over the past month but I plan to release one more version before the end of the year. |
Hi @fgrehm I was just wondering... are you still planning on releasing that new version (with NFS support) soon? Kind regards |
@Restless-ET hopefully yes, I'm going on vacations starting on Jan 4th and if all goes well I'll be able to cut a new release with NFS in place before heading out :-) |
Glad to ear that, I'm really looking forward to the NFS support. Regards |
For the record, vagrant 1.5 will ship with rsync support as well and we'll be able to use as a workaround for this as well ;-) |
The next major version of the plugin will drop support for vagrant < 1.4 and will have support for NFS and rsync out of the box. I'm closing it in favor of GH-191 |
I'm not sure about other users but I am considering using As an alternative, I wrote a script to update the # Repair Vagrant UID/GID to match our current user
uid = `id -u`.strip()
gid = `id -g`.strip()
config.vm.provision "shell", inline: <<-EOF
# Exit on first error
set -e
# Resolve our UID and GID
src_uid="$(id -u vagrant)"
target_uid="#{uid}"
src_gid="$(id -g vagrant)"
target_gid="#{gid}"
# If the user and group ids are aligned, then exit early
if test "$src_uid" = "$target_uid" && test "$src_gid" = "$target_gid"; then
exit 0
fi
# Otherwise, update our user id and group id
# DEV: We cannot use \`usermod\` as it complains about \`vagrant\` having a process
# Example: UID=100; GID=101
# /etc/shadow: libuuid:x:100:101::/var/lib/libuuid:
# /etc/group: libuuid:x:101:
sed -E "s/(vagrant:.:)$src_uid:$src_gid:/\\1$target_uid:$target_gid:/g" --in-place /etc/passwd
sed -E "s/(vagrant:.:)$src_gid:/\\1$target_gid:/g" --in-place /etc/group
# Update all files to the proper user and group
find / -uid "$src_uid" -print0 2> /dev/null | grep --invert-match -E "^(/sys|/proc)" | xargs -0 chown "$target_uid"
find / -gid "$src_gid" -print0 2> /dev/null | grep --invert-match -E "^(/sys|/proc)" | xargs -0 chgrp "$target_gid"
EOF Edit: Added |
@twolfson I know it's been a while but you can also create a base box with the proper GID / UID 😄 |
@fgrehm I think that would work for a single user but what if your team has multiple machines with different GID/UID =/ |
oh yeah, that sucks. its been a while since I last done any LXC work but last time I looked into this NFS was the only way I could get it working |
After some searching, it looks like there's a https://linuxcontainers.org/lxc/manpages/man5/lxc.container.conf.5.html#lbBB config.vm.provider "lxc" do |lxc|
config.vm.box = "fgrehm/trusty64-lxc"
lxc.customize("id_map", "u 1000 1001 1")
lxc.customize("id_map", "g 1000 1001 1")
# Later on, use #{uid} with uid = `id -u`.strip() from previous iteration
end I tried to get it working but couldn't. Unfortunately, I'm out of time to explore it but thankfully the script I posted has been working well for me =) |
@twolfson, your script appears to be working great for me. I had to add a '-print0' to the find script and use '-0' to xargs because we have some filenames with spaces. Thanks! |
Ah, null delimiter. Nice catch, I'll update the comment 👍 |
While trying out this Ubuntu Raring Vagrant VBox VM, I stumbled across a pretty bad issue that messes up with shared folders permissions. The problem is that the
vagrant
user on that VBox VM has anuid
of900
, but the base boxes containers ship with thevagrant
user with theuid
of1000
.The reason why things works fine for most cases is that Debian-like distros uses 1000 as the initial user id which usually maps to the same user id on the host machine.
Unfortunately I have no idea how to mount the shared folder on the guest container with a different
uid
/gid
, a solution might be to implement support for NFS Shared folders to work around that for those who face this problem but I'd need to double check that. If you are experiencing this, please raise your hand :)The text was updated successfully, but these errors were encountered: