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

fixing mkstemp without securely setting mask/unmask #106

Merged
merged 2 commits into from
Aug 12, 2019

Conversation

danielwangksu
Copy link

fix #101

In newer glibc's (versions > 2.06) reasonably secure permissions of 0600 are used when creating a temporary file with mkstemp(). But for older glibc and other platform this is not guaranteed.

Signed-off-by: Daniel Wang daniel.wang@canonical.com

Signed-off-by: Daniel Wang <daniel.wang@canonical.com>
src/rospack.cpp Outdated
@@ -2061,7 +2061,9 @@ Rosstackage::writeCache()
{
FILE *cache = fopen(tmp_cache_path, "w");
#else
mode_t mask = umask(S_IRUSR | S_IWUSR| S_IXUSR | S_IRWXG);
Copy link
Member

Choose a reason for hiding this comment

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

Your description mentioned 0600. Is that not a desired mask? Why also add read, write, execute/search for the group?

Is there a reason not to use S_IRWXU as a shortcut for the first three flags?

Copy link
Author

Choose a reason for hiding this comment

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

Good point I will change it to S_IRWXU, I think default 0600 should be sufficient, but I'm not sure if any process requires read, write, execute group permission for concurrency. If not I will remove it. Thank you for your response

Signed-off-by: Daniel Wang <daniel.wang@canonical.com>
@kyrofa
Copy link

kyrofa commented Jul 31, 2019

@dirk-thomas this is ready for another pass when you're able.

@dirk-thomas dirk-thomas changed the base branch from lunar-devel to melodic-devel August 12, 2019 18:55
@dirk-thomas
Copy link
Member

Thanks for the patch.

@dirk-thomas dirk-thomas merged commit 947ada5 into ros:melodic-devel Aug 12, 2019
@dirk-thomas
Copy link
Member

This patch broke the behavior since new cache files are currently created with a mask of 0 and are therefore not readable. See #117 for the bug report.

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.

Calling "mkstemp" without securely setting umask first
3 participants