[asterisk-commits] tilghman: branch 1.6.2 r248864 - in /branches/1.6.2: ./ main/asterisk.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Feb 25 15:25:09 CST 2010


Author: tilghman
Date: Thu Feb 25 15:25:05 2010
New Revision: 248864

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=248864
Log:
Merged revisions 248861 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r248861 | tilghman | 2010-02-25 15:22:39 -0600 (Thu, 25 Feb 2010) | 22 lines
  
  Merged revisions 248859 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r248859 | tilghman | 2010-02-25 15:21:05 -0600 (Thu, 25 Feb 2010) | 15 lines
    
    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
  ........
................

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/main/asterisk.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/main/asterisk.c?view=diff&rev=248864&r1=248863&r2=248864
==============================================================================
--- branches/1.6.2/main/asterisk.c (original)
+++ branches/1.6.2/main/asterisk.c Thu Feb 25 15:25:05 2010
@@ -3301,6 +3301,12 @@
 	 */
 	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) {
@@ -3313,6 +3319,9 @@
 		if (!gr) {
 			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);
@@ -3335,6 +3344,9 @@
 		if (!pw) {
 			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)) {




More information about the asterisk-commits mailing list