Module: kamailio
Branch: master
Commit: b151e9d6071b1affe814f4edf2e87b132f0accb8
URL:
https://github.com/kamailio/kamailio/commit/b151e9d6071b1affe814f4edf2e87b1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-09-28T23:02:27+02:00
core: create runtime dir if doesn't exist
- test and create runtime dir (default /var/run/kamailio)
- do chown of runtime dir if user/group parameters are set for kamailio
---
Modified: main.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b151e9d6071b1affe814f4edf2e87b1…
Patch:
https://github.com/kamailio/kamailio/commit/b151e9d6071b1affe814f4edf2e87b1…
---
diff --git a/main.c b/main.c
index 4fd168d..1eae997 100644
--- a/main.c
+++ b/main.c
@@ -1799,6 +1799,7 @@ int main(int argc, char** argv)
int dont_fork_cnt;
struct name_lst* n_lst;
char *p;
+ struct stat st = {0};
/*init*/
time(&up_since);
@@ -2343,6 +2344,19 @@ int main(int argc, char** argv)
}
sock_gid = gid;
}
+ /* create runtime dir if doesn't exist */
+ if (stat(runtime_dir, &st) == -1) {
+ if(mkdir(runtime_dir, 0700) == -1) {
+ fprintf(stderr, "failed to create runtime dir\n");
+ goto error;
+ }
+ if(sock_uid!=-1 || sock_gid!=-1) {
+ if(chown(runtime_dir, sock_uid, sock_gid) == -1) {
+ fprintf(stderr, "failed to change owner of runtime dir\n");
+ goto error;
+ }
+ }
+ }
if (fix_all_socket_lists()!=0){
fprintf(stderr, "failed to initialize list addresses\n");
goto error;