-
Notifications
You must be signed in to change notification settings - Fork 84
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
force_mask affects permissions inside container #407
Comments
@giuseppe PTAL |
Closes: containers#407 Signed-off-by: Giuseppe Scrivano <[email protected]>
opened a PR: #408 |
@giuseppe thx for providing the PR. It indeed fixes the described issue. But there seems to be more to it: TL;DR: syscall mkdir("/foobar", 0700) results in new directory with permissions 0755 which shouldn't be. I stumbled upon this issue while setting up a samba container (ghcr.io/servercontainers/samba:smbd-only-latest) using a network share as graphroot. Then I boiled it down to the described minimal reproducible example. This example is working now. But the issue with my samba container ist still there. To be clear: without Using
directory contents before starting smbd:
after trying to start smbd:
STRACE
It appears smbd tries to create So I did it the hard way:
#include <sys/stat.h>
void main() {
mkdir("/foobar", 0700);
}
The created directory should have permissions set to 0700. But it doesn't. ¯\(ツ)/¯ This is with using the fuse-overlayfs version from the PR (https://github.com/containers/fuse-overlayfs/actions/runs/6689710902#artifacts). And some bonus info:#include <sys/stat.h>
#include <fcntl.h>
void main() {
mkdir("/foobar", 0777);
open("/foobar.txt", O_CLOEXEC|O_CREAT, 0600);
}
So it seams to work for files. At least with open() |
thanks for the extra information. Could you check if #409 solves the problem with directories? |
EDIT: I messed something up in an earlier version of this comment. Just re-read it. The problem regarding creating new directories described above is now solved. But there is more: no force_mask, works as is should:
with foce_mask=0700 (fuse-overlayfs from #409)
What's difference? The directory I was able to reproduce it by doing this: #include <fcntl.h>
void main() {
open("/var/lib/samba/private/foobar.txt", O_RDWR|O_CREAT|O_LARGEFILE|O_CLOEXEC, 0600);
}
Creating a new file under |
@rhatdan Would it make sense to re-open this issue as it is clearly not solved yet? |
when a directory is copied up, propagate its mode if using xattrs permissions. Closes: containers#407 Signed-off-by: Giuseppe Scrivano <[email protected]>
thanks for the additional feedback. Opened a new PR: #410 |
It's still not working: with out force_mask
with force_mask=0700
smbd creates |
I was able to reproduce this: #include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
void main() {
struct stat sb;
mkdir("/var/run/samba/ncalrpc/foobar", 0700);
lstat("/var/run/samba/ncalrpc/foobar", &sb);
printf("Mode: %lo (octal)\n", (unsigned long) sb.st_mode);
}
what is even more interresting:
Now foobar is 0755 and 0700 at the same time. As it turns out
|
thanks, added a new patch to the open PR. I've tried running your container image and it seems to work fine now:
What other tests can I do to make sure it will fix your use case? |
Thank you very much @giuseppe my samba container ist working now. This whole issue got me thinking... I went ahead and looked for some filesystem testsuit and found this: musikid/pjd Running it on my underlying cephfs results in no errors. Running it on fuse-overlayfs backed by cephfs shows some issues:
Maybe you wanna look into it and include it in your build pipeline. I can't really judge which of those test cases are even relevant. |
Issue Description
Setting
storage.options.overlay.force_mask=0700
changes the permissions of files newly created inside a running container. The actualumask
is ignored. This is when usingfuse-overlayfs
. So the issue could be rooted there.This is only for freshly created files. Thereafter the permissions (inside the container) can be changed using
chmod
and will be represented accordingly. Outside the container the permission stays as set inforce_mask
. And the in-container permissions are stored in a xattr.I stumbled over this, when trying to move my graphroot to a network share (cephfs) when the
force_mask
is forced to 0700. After some poking around I boiled it down to the example below. So it's not related to moving the graphroot to a network share.Steps to reproduce the issue
1. storage.conf
~/.config/containers/storage.conf
2. for good meassure
$ podman system reset
3. try it out
$ podman run --rm -it ubuntu /bin/bash
root@02c8ed39eaf8:/# touch foobar
root@02c8ed39eaf8:/# ls -l foobar
additional info:
umask
inside container was left at default:Describe the results you received
Permissions of file
foobar
:-rwxr-xr-x. 1 root root 0 Oct 29 09:02 foobar
Describe the results you expected
Expected permissions (as without using
force_mask
):-rw-r--r--. 1 root root 0 Oct 29 09:03 foobar
podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
No
Additional environment details
Additional environment details
Additional information
Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting
The text was updated successfully, but these errors were encountered: