-
Notifications
You must be signed in to change notification settings - Fork 347
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
libsemanage: use mv instead of rename for container compat #342
Conversation
Signed-off-by: Joseph Marrero <jmarrero@redhat.com>
This should probably implemented in C instead of spawning a new shell. Untested draft:
|
Thanks @cgzones I will give this a try and report back. |
Before you send it to the review on selinux@vger.kernel.org could you please add provide more information in the commit message about the problem this tries to fix? Especially about the filesystem layout and why /etc/selinux/targeted/active is on a different filesystem than /etc/selinux/targeted/previous. What would be the impact on the filesystem layout when /etc/selinux/targeted/active is copied into /etc/selinux/targeted/previous and /etc/selinux/targeted/tmp, unlink()'ed and then created again with a copy of /etc/selinux/targeted/tmp? |
@bachradsusi They are not on different filesystems - the problem is that overlayfs doesn't support Anyway, I don't think @cgzones's solution will work in this case, since we are renaming a directory, not a single file. Also, I believe we expect the rename here to be atomic, so we need to ensure that whatever fallback we use for EXDEV is still atomic (at least to the same extent as rename(2) is). |
thanks @WOnder93 this was the information I was missing. Btw libsemanage already implements copying directories see https://github.com/SELinuxProject/selinux/blob/master/libsemanage/src/semanage_store.c#L773 |
Sorry for the week delay, went on PTO just after my update here. @cgzones using your draft I get:
Which is what @WOnder93 suggested. As for using @bachradsusi suggestion, I get:
Also I tried a combination of both suggestions by replacing the rename on: https://github.com/SELinuxProject/selinux/blob/master/libsemanage/src/semanage_store.c#L763 with cgzones's |
@jmarrero Please try the bachradsusi@03db464 It implements fallback to semanage_copy_dir() and semanage_remove_dir() if rename() failed on EXDEV. Even though it's not an atomic operation, it should happen just once (based on my observation). If it works for you, we should move this to selinux@vger.kernel.org |
It works on my end. Thank you! |
Initial good path for: #343 but I am sure it needs input validation and/or error handling.