summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
dbd75de)
Set the mode when creating the personal socket directory,
this way all app sockets are private.
Signed-off-by: Nils Carlson <nils.carlson@ericsson.com>
- result = ensure_dir_exists(dir_name);
+ result = ensure_dir_exists(dir_name, S_IRWXU);
if (result == -1) {
ERR("Unable to create socket directory %s, UST thread bailing",
dir_name);
if (result == -1) {
ERR("Unable to create socket directory %s, UST thread bailing",
dir_name);
-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;
return -1;
result = stat(dir, &st);
return -1;
result = stat(dir, &st);
- if(result == -1 && errno != ENOENT) {
+ if (result < 0 && errno != ENOENT) {
- }
- else if(result == -1) {
+ } else if (result < 0) {
- /* 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;
+ }
+ }
};
/* Ensure directory existence, usefull for unix sockets */
};
/* Ensure directory existence, usefull for unix sockets */
-extern int ensure_dir_exists(const char *dir);
+extern int ensure_dir_exists(const char *dir, mode_t mode);
/* Create and delete sockets */
extern struct ustcomm_sock * ustcomm_init_sock(int fd, int epoll_fd,
/* Create and delete sockets */
extern struct ustcomm_sock * ustcomm_init_sock(int fd, int epoll_fd,
int result;
/* Only check if socket dir exists if we are using the default directory */
int result;
/* Only check if socket dir exists if we are using the default directory */
- result = ensure_dir_exists(SOCK_DIR);
+ result = ensure_dir_exists(SOCK_DIR, S_IRWXU | S_IRWXG | S_IRWXO);
if (result == -1) {
ERR("Unable to create socket directory %s", SOCK_DIR);
return -1;
if (result == -1) {
ERR("Unable to create socket directory %s", SOCK_DIR);
return -1;