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

Create directory for socket (only the last directory) #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gytamon
Copy link

@Gytamon Gytamon commented Feb 11, 2022

I hope that could be a good fix and the good way to proceed , it's first time I write C

Copy link
Contributor

@ericonr ericonr left a comment

Choose a reason for hiding this comment

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

I will make a new revision of this patch.

@@ -17,6 +17,7 @@
#include "modules.h"
#include "parse.h"
#include "util.h"
#include "libgen.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be in the first list of includes, as #include <libgen.h>, since it is a system header.

Comment on lines +218 to +222
// create only the last directory not recursive mode
struct stat st = {0};
if (stat(dirname(socket_path), &st) == -1) {
mkdir(dirname(socket_path), 0755);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't in the right place, directory creation should happen before the bind() attempt. We should also consider only doing it in case bind returns an error indicating the directory doesn't exist, instead of using stat to check for directory existence (access or readlink would be lighterweight options, btw).

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.

2 participants