Module: kamailio
Branch: 4.3
Commit: efb2a06b5f6d4278bda6dec63af8e685a559fd73
URL: 
https://github.com/kamailio/kamailio/commit/efb2a06b5f6d4278bda6dec63af8e685a559fd73

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2015-09-28T23:04:32+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

(cherry picked from commit b151e9d6071b1affe814f4edf2e87b132f0accb8)

---

Modified: main.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/efb2a06b5f6d4278bda6dec63af8e685a559fd73.diff
Patch: 
https://github.com/kamailio/kamailio/commit/efb2a06b5f6d4278bda6dec63af8e685a559fd73.patch

---

diff --git a/main.c b/main.c
index 1ff7f6a..acb8ce4 100644
--- a/main.c
+++ b/main.c
@@ -1793,6 +1793,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);
@@ -2312,6 +2313,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;


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to