-
Notifications
You must be signed in to change notification settings - Fork 267
Fix cross compilation code for other platforms #306
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
Conversation
utils.go
Outdated
| st, err := os.Stat(tmpDir) | ||
| if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Getuid() && st.Mode().Perm() == 0700 { | ||
| st, err := system.Stat(tmpDir) | ||
| if err == nil && int(st.UID()) == os.Getuid() && st.Mode() == 0700 { |
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.
This should compile, which is good, but st.UID() is hardwired to always return 0, while os.Getuid() is documented to always return -1, so our attempt to create this directory ends up either failing and producing an error, or succeeding and then being ignored.
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.
My preference is to avoid creating a directory that we're just going to ignore.
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.
Why would stating of the directory return UID==0?
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.
pkg/system's Stat() returns a pointer to a StatT, which on Windows systems only ever returns 0 from its UID() method.
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.
Do you want to make this OS Specific then?
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.
we end up using this code only when os.Geteuid() != 0, on Windows it returns always -1. Could we just check os.Geteuid() value and treat -1 differently?
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 removed the checks altogether, if the directory gets created with from podman, then we need to believe it got created with the correct ownership and permissions.
|
Do you know if containers/storage has consumers on Windows? If it's for historical reasons, we may have the chance to ditch the windows builds. |
When trying to vendor into containers/image we found issues with cross platform compilation. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
rhatdan
left a comment
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.
No consumers that we know of, but we wanted to make sure it compiles on other platforms.
utils.go
Outdated
| st, err := os.Stat(tmpDir) | ||
| if err == nil && int(st.Sys().(*syscall.Stat_t).Uid) == os.Getuid() && st.Mode().Perm() == 0700 { | ||
| st, err := system.Stat(tmpDir) | ||
| if err == nil && int(st.UID()) == os.Getuid() && st.Mode() == 0700 { |
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 removed the checks altogether, if the directory gets created with from podman, then we need to believe it got created with the correct ownership and permissions.
|
I don't expect |
When trying to vendor into containers/image we found issues
with cross platform compilation.
Signed-off-by: Daniel J Walsh dwalsh@redhat.com