aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/asterisk.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index 085b9b598..e27f685c5 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -3301,6 +3301,12 @@ int main(int argc, char *argv[])
*/
signal(SIGCHLD, child_handler);
+ /* 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));
+ }
+
#ifndef __CYGWIN__
if (isroot) {
@@ -3314,6 +3320,9 @@ 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)) {
+ ast_log(LOG_WARNING, "Unable to chgrp run directory to %d (%s)\n", (int) gr->gr_gid, rungroup);
+ }
if (setgid(gr->gr_gid)) {
ast_log(LOG_WARNING, "Unable to setgid to %d (%s)\n", (int)gr->gr_gid, rungroup);
exit(1);
@@ -3336,6 +3345,9 @@ int main(int argc, char *argv[])
ast_log(LOG_WARNING, "No such user '%s'!\n", runuser);
exit(1);
}
+ if (chown(ast_config_AST_RUN_DIR, pw->pw_uid, -1)) {
+ ast_log(LOG_WARNING, "Unable to chown run directory to %d (%s)\n", (int) pw->pw_uid, runuser);
+ }
#ifdef HAVE_CAP
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
ast_log(LOG_WARNING, "Unable to keep capabilities.\n");