Closed mathiasaerts closed 1 year ago
You are right, I hadn't considered this case (and it turns out the unsigned integer parsing function strtoul
silently casts negative numbers instead of erroring :unamused: )
Shouldn't be a difficult fix. I'll see if I can get it done today or tomorrow.
Should be fixed now with 1.17.5.
Note that with uid-offset=-100000
, operations on any source files with uid/gid below -100000 (e.g. owned by root) will fail with EIO
. Is this acceptable in your case? If not, do you have a suggestion for how it should work (or be workaroundable)?
Amazing, thanks! :star_struck: First tests look very promising!
I don't think this would be an issue for my current use case. I'm wondering if as a workaround you could set lower uids / gids to 0, so all files with a uid below 100000 would become root in the mounted dir. I'm guessing this could be a problem to 'unapply' the offset though?
Instead of making the files root
, it could also be nobody
(uid/gid 65534), which is also how LXC handles files owned by a uid < 100000 on the host in an unprivileged container. In LXC, this allows files to be readonly in the container, so they cannot be modified or chowned. I guess you would have to handle each of those operations separately (if this is not already the case) to implement a similar approach?
I'm trying to use bindfs to 'unshift' an existing directory that has a uid and gid shift of 100000 applied (actual file ownership, not using bindfs). When using a negative offset of
-100000
(using mount optionscreate-as-user,uid-offset=-100000,gid-offset=-100000
), it seems that the mounted directory indeed shows the expected unshifted file ownership. However, when trying to create a file, it doesn't work, and it appears that file operations do not take the actual user performing the operation into account, resulting in errors such astouch: setting times of ‘filename’: Permission denied
and both file owner and group being set to4294867296
, while on the source directory, the owner appears asroot
instead.When trying the same thing with a positive offset, everything appears to be working as expected, and the uid and gid of the user performing the file operation are preserved. Therefore, I was wondering if negative offsets are actually supported. In any case, it could be a very nice feature, but it doesn't seem to work as expected now.