-
Notifications
You must be signed in to change notification settings - Fork 18
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
.target.tmpdir - honor the target root (bsc#1199840) #159
base: master
Are you sure you want to change the base?
Conversation
- Create the temporary directory in the target root, not in the system root. Allow using it from other .target paths (like .bash or .string) - The temporary directory is now created only when needed. - 4.5.3
@@ -332,7 +359,8 @@ SystemAgent::Read (const YCPPath& path, const YCPValue& arg, const YCPValue&) | |||
* @example Read (.target.tmpdir) -> "/some/temp/dir" | |||
*/ | |||
|
|||
return YCPString (tempdir); | |||
// skip the chroot prefix, return the location relative to the current root | |||
return YCPString (tempdir().substr(strlen(root()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is wrong :)
It is fine when tempdir
is /mnt/tmp
and root
is /mnt
It is fine when tempdir
is /tmp
and root
is empty
But what if root
is /
?
AFAIK SCRAgent::root is not clear about "" vs "/"
Yet your test shows it works... ... ah, because tempdir()
will return two leading slashes. I think it deserves a comment in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for safety I would also change code to something like (pseudocode) YCPString ((root() == "/" || root() == "") ? tempdir() : tempdir().substr(strlen(root())))
* Returns the temporary directory path, it creates the directory at the first | ||
* call. The directory is automatically deleted in the destructor. | ||
* | ||
* @return string The returned path includes the current root (chroot) prefix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return string The returned path includes the current root (chroot) prefix. | |
* @return string The returned path includes the current root (chroot) prefix. | |
For example "//tmp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with mvidner to be on safe side with having always absolute root
Problem
The
.target.tmpdir
agent creates the temporary directory in the current system root.That makes troubles when the SCR is chrooted. In that case the other agents (
.target.string
ortarget.bash
) use the chroot and the temporary directory is not reachable from there as it is outside the chroot.This causes problems when running YaST in a container.
Solution
The solution required to move the code from the constructor and create the temporary directory at the first access. The reason is that the
root()
call returns the/
path in the constructor, the correct target root is set later.Notes
/tmp
directory exists in the target root, this might be useful in testing when you use an empty chroot.Testing
Tested manually with this small testing Ruby script:
This code checks the behavior in both cases, running in standard root and running in a chroot.
Results
With the original code it failed when running in a container with this error:
After fixing
.target.tmpdir
it works as expected:GitHub Action
The GitHub Action is failing because of missing
glibc-locale
package in the image. Fixed with yast/ci-ruby-container#20.