]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't change ownership/group/permissions on run directory, if it already exists.
authorTilghman Lesher <tilghman@meg.abyt.es>
Mon, 28 Jun 2010 21:50:02 +0000 (21:50 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Mon, 28 Jun 2010 21:50:02 +0000 (21:50 +0000)
(closes issue #17076)
 Reported by: stuarth
 Patches:
       20100324__issue17076.diff.txt uploaded by tilghman (license 14)
 Tested by: stuarth

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@272925 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/asterisk.c

index 1a8ddebd061cd8e512f329fa1ff1079f3df4d12d..33aaaf2fcdf71a1462c70a43af72b7169e63a06b 100644 (file)
@@ -2724,7 +2724,7 @@ int main(int argc, char *argv[])
        FILE *f;
        sigset_t sigs;
        int num;
-       int isroot = 1;
+       int isroot = 1, rundir_exists = 0;
        char *buf;
        char *runuser = NULL, *rungroup = NULL;
 
@@ -2891,8 +2891,12 @@ int main(int argc, char *argv[])
 
        /* It's common on some platforms to clear /var/run at boot.  Create the
         * socket file directory before we drop privileges. */
-       if (mkdir(ast_config_AST_RUN_DIR, 0755) && errno != EEXIST) {
-               ast_log(LOG_WARNING, "Unable to create socket file directory.  Remote consoles will not be able to connect! (%s)\n", strerror(x));
+       if (mkdir(ast_config_AST_RUN_DIR, 0755)) {
+               if (errno == EEXIST) {
+                       rundir_exists = 1;
+               } else {
+                       ast_log(LOG_WARNING, "Unable to create socket file directory.  Remote consoles will not be able to connect! (%s)\n", strerror(x));
+               }
        }
 
 #ifndef __CYGWIN__
@@ -2907,7 +2911,7 @@ int main(int argc, char *argv[])
                        ast_log(LOG_WARNING, "No such group '%s'!\n", rungroup);
                        exit(1);
                }
-               if (chown(ast_config_AST_RUN_DIR, -1, gr->gr_gid)) {
+               if (!rundir_exists && chown(ast_config_AST_RUN_DIR, -1, gr->gr_gid)) {
                        ast_log(LOG_WARNING, "Unable to chgrp run directory to %d (%s)\n", (int) gr->gr_gid, rungroup);
                }
                if (setgid(gr->gr_gid)) {