aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-25 21:21:05 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-25 21:21:05 +0000
commitd3fe19b246d934e263fe45466e48fc7d5cd1938d (patch)
tree156bfd2667472e618fc8dd3bb632c5c68b54ea88
parent6cf5cf38aeb4f42e0e54e3c535b8174fa0d99853 (diff)
Some platforms clear /var/run at boot, which makes connecting a remote console... difficult.
Previously, we only created the default /var/run/asterisk directory at install time. While we could create it in the init script, that would not work for those who start asterisk manually from the command line. So the safest thing to do is to create it as part of the Asterisk boot process. This also changes the ownership of the directory, because the pid and ctl files are created after we setuid/setgid. (closes issue #16802) Reported by: Brian Patches: 20100224__issue16802.diff.txt uploaded by tilghman (license 14) Tested by: tzafrir git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@248859 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/asterisk.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index dc763388d..5730bc6fe 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2868,6 +2868,12 @@ int main(int argc, char *argv[])
if ((!runuser) && !ast_strlen_zero(ast_config_AST_RUN_USER))
runuser = ast_config_AST_RUN_USER;
+ /* 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)
@@ -2880,6 +2886,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);
@@ -2902,6 +2911,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");