Skip to content
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

Inherit uds permissions when unlinking #113

Merged
merged 10 commits into from
Aug 3, 2018
Merged

Inherit uds permissions when unlinking #113

merged 10 commits into from
Aug 3, 2018

Conversation

myagley
Copy link
Contributor

@myagley myagley commented Aug 2, 2018

In the edgelet, when unlinking an existing unix domain socket, we use the umask of the process to create the new socket. This doesn't work well for the edgelet, because we need different permissions for the workload and mgmt sockets.

This PR updates the flow for the unix scheme to use the previous socket's mode when unlinking and creating the new socket.

@myagley myagley requested a review from avranju August 2, 2018 17:44
avranju
avranju previously approved these changes Aug 2, 2018

debug!("settings permissions {:#o} for {}...", mode, path.as_ref().display());
let prev = umask(mask);
defer! {{ umask(prev); }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing this restores the current process's umask when this function returns? Nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's similar to go's defer. The macro creates a struct and implements Drop and calls the block given to the macro in the drop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!

avranju
avranju previously approved these changes Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants