-
Notifications
You must be signed in to change notification settings - Fork 31
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
Use *at functions for directory creation #124
base: master
Are you sure you want to change the base?
Conversation
Perform path traversal manually and do not follow symlinks.
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.
Thanks for the changes. Since the path sources come from trusted system data that seems good enough. I added two suggestions
char *saveptr = NULL; | ||
const char *component = strtok_r(local_path, "/", &saveptr); | ||
while (component) { | ||
int nextdirfd = openat(dirfd, component, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); |
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 would move the error check for this right here to keep it together
} | ||
node_basename = node_basename + 1; // Skip / | ||
|
||
// Ok to assign mode before chown? |
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.
yes
fprintf(stderr, "Failed to create directory '%s': %m\n", node->dirname); | ||
rc = 1; | ||
continue; | ||
} | ||
|
||
if (chown(node->dirname, node->user_id, node->group_id) < 0) { | ||
// Ok to assign ownership before se labels? |
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, it would be better to first change the labels, then set the owner
Perform path traversal manually and do not follow symlinks.
Draft because some TODOs still open. Also absolutely untested.