projects
/
ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add mode setting to socket directory creation
[ust.git]
/
libustcomm
/
ustcomm.c
diff --git
a/libustcomm/ustcomm.c
b/libustcomm/ustcomm.c
index dce1e521c5b5c83714d439a00edf07ccb73253dc..e401c4256e6666292a3ea6b9f5dddd948d811b64 100644
(file)
--- a/
libustcomm/ustcomm.c
+++ b/
libustcomm/ustcomm.c
@@
-588,28
+588,34
@@
free_dir_name:
return retval;
}
return retval;
}
-int ensure_dir_exists(const char *dir)
+int ensure_dir_exists(const char *dir
, mode_t mode
)
{
struct stat st;
int result;
{
struct stat st;
int result;
- if(!strcmp(dir, ""))
+ if
(!strcmp(dir, ""))
return -1;
result = stat(dir, &st);
return -1;
result = stat(dir, &st);
- if
(result == -1
&& errno != ENOENT) {
+ if
(result < 0
&& errno != ENOENT) {
return -1;
return -1;
- }
- else if(result == -1) {
+ } else if (result < 0) {
/* ENOENT */
int result;
/* ENOENT */
int result;
- /* mkdir mode to 0777 */
- result = mkdir_p(dir, S_IRWXU | S_IRWXG | S_IRWXO);
+ result = mkdir_p(dir, mode);
if(result != 0) {
ERR("executing in recursive creation of directory %s", dir);
return -1;
}
if(result != 0) {
ERR("executing in recursive creation of directory %s", dir);
return -1;
}
+ } else {
+ if (st.st_mode != mode) {
+ result = chmod(dir, mode);
+ if (result < 0) {
+ ERR("couldn't set directory mode on %s", dir);
+ return -1;
+ }
+ }
}
return 0;
}
return 0;
This page took
0.022785 seconds
and
4
git commands to generate.