Home folder changes ownership on adding devices


(Gabriel Baims) #1

I don’t know if this is a bug or intended behavior.

If you add a device to ubuntu’s home folder, like:
lxc config device add test-container app disk source=/home/gabriel/myapp/ path=/home/ubuntu/myapp

The folder /home/ubuntu ownerships changes to root:root, instead of ubuntu:ubuntu.

Is that correct?


(Stéphane Graber) #2

It should change to whatever the owner of the source path is, so if /home/gabriel/myapp is owned by root:root on the host, it would show up at root:root in the container.

But on top of that, you have to consider uid/gid maps that can also shift those bits around a bit, at least if your container is unprivileged.

Can you show:

lxc config show --expanded test-container

(Gabriel Baims) #3

Hi @stgraber,

let me try to explain another way. The mounted device ownership is ok. The issue is on the parent folder. For instance, let’s say I’m adding the following device:

lxc config device add test-container app disk source=/home/gabriel/a/b/c/d path=/home/ubuntu/a/b/c/d

d/ folder ownership is ok. (nobody:nogroup)

But ubuntu/, a/, b/ and c/ are now owned by root:root, when it would be ubuntu:ubuntu.

Actually, I don’t know about a/, b/ and c/. But ubuntu/ definitely should be owned by ubuntu:ubuntu, right?


(Stéphane Graber) #4

Ah, I see, and did /home/ubuntu already exist back when you first added that disk entry?

If not, then LXD would have been the one creating it so that the mountpoint exists and as that’s done by a root process in the container, root:root is what you’re getting.


(Gabriel Baims) #5

It’s true. The folder didn’t exist yet when I added the disk.

Thanks.