Merged revisions 172441 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

................
  r172441 | tilghman | 2009-01-29 17:15:40 -0600 (Thu, 29 Jan 2009) | 16 lines
  
  Merged revisions 172438 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r172438 | tilghman | 2009-01-29 16:54:29 -0600 (Thu, 29 Jan 2009) | 9 lines
    
    Lose the CAP_NET_ADMIN at every fork, instead of at startup.  Otherwise, if
    Asterisk runs as a non-root user and the administrator does a 'restart now',
    Asterisk loses the ability to set QOS on packets.
    (closes issue #14004)
     Reported by: nemo
     Patches: 
           20090105__bug14004.diff.txt uploaded by Corydon76 (license 14)
     Tested by: Corydon76
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@172504 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.1
Tilghman Lesher 17 years ago
parent a057dcb747
commit 95c892e3f9

@ -359,6 +359,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/cdr.h" #include "asterisk/cdr.h"
#include "asterisk/options.h" #include "asterisk/options.h"
#include "asterisk/manager.h" #include "asterisk/manager.h"
#include "asterisk/app.h"
#include <termios.h> #include <termios.h>
#ifdef NEW_ASTERISK #ifdef NEW_ASTERISK
@ -1966,7 +1968,7 @@ unsigned int seq;
sprintf(str,"%s?node=%s&time=%u&seqno=%u",myrpt->p.statpost_url, sprintf(str,"%s?node=%s&time=%u&seqno=%u",myrpt->p.statpost_url,
myrpt->name,(unsigned int) now,seq); myrpt->name,(unsigned int) now,seq);
if (pairs) sprintf(str + strlen(str),"&%s",pairs); if (pairs) sprintf(str + strlen(str),"&%s",pairs);
if (!(pid = fork())) if (!(pid = ast_safe_fork(0)))
{ {
execv(astrs[0],astrs); execv(astrs[0],astrs);
ast_log(LOG_ERROR, "exec of %s failed.\n", astrs[0]); ast_log(LOG_ERROR, "exec of %s failed.\n", astrs[0]);

@ -39,6 +39,8 @@ else
fi fi
if test "x$ac_cv_func_fork_works" = xyes; then if test "x$ac_cv_func_fork_works" = xyes; then
AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.]) AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
PBX_WORKING_FORK=1
AC_SUBST(PBX_WORKING_FORK)
fi fi
])# AST_FUNC_FORK ])# AST_FUNC_FORK

8
configure vendored

@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# From configure.ac Revision: 163170 . # From configure.ac Revision: 164266 .
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.6. # Generated by GNU Autoconf 2.61 for asterisk 1.6.
# #
@ -959,6 +959,7 @@ ZLIB_DIR
PBX_ZLIB PBX_ZLIB
ALLOCA ALLOCA
LIBOBJS LIBOBJS
PBX_WORKING_FORK
POW_LIB POW_LIB
HAS_POLL HAS_POLL
PBX_PTHREAD_RWLOCK_INITIALIZER PBX_PTHREAD_RWLOCK_INITIALIZER
@ -12973,6 +12974,8 @@ cat >>confdefs.h <<\_ACEOF
#define HAVE_WORKING_FORK 1 #define HAVE_WORKING_FORK 1
_ACEOF _ACEOF
PBX_WORKING_FORK=1
fi fi
{ echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5 { echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5
@ -51485,6 +51488,7 @@ ZLIB_DIR!$ZLIB_DIR$ac_delim
PBX_ZLIB!$PBX_ZLIB$ac_delim PBX_ZLIB!$PBX_ZLIB$ac_delim
ALLOCA!$ALLOCA$ac_delim ALLOCA!$ALLOCA$ac_delim
LIBOBJS!$LIBOBJS$ac_delim LIBOBJS!$LIBOBJS$ac_delim
PBX_WORKING_FORK!$PBX_WORKING_FORK$ac_delim
POW_LIB!$POW_LIB$ac_delim POW_LIB!$POW_LIB$ac_delim
HAS_POLL!$HAS_POLL$ac_delim HAS_POLL!$HAS_POLL$ac_delim
PBX_PTHREAD_RWLOCK_INITIALIZER!$PBX_PTHREAD_RWLOCK_INITIALIZER$ac_delim PBX_PTHREAD_RWLOCK_INITIALIZER!$PBX_PTHREAD_RWLOCK_INITIALIZER$ac_delim
@ -51526,7 +51530,7 @@ CURL_CONFIG!$CURL_CONFIG$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF _ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 88; then if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 89; then
break break
elif $ac_last_try; then elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

@ -33,6 +33,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <regex.h> #include <regex.h>
#include <sys/file.h> /* added this to allow to compile, sorry! */ #include <sys/file.h> /* added this to allow to compile, sorry! */
#include <signal.h> #include <signal.h>
#ifdef HAVE_CAP
#include <sys/capability.h>
#endif /* HAVE_CAP */
#include "asterisk/paths.h" /* use ast_config_AST_DATA_DIR */ #include "asterisk/paths.h" /* use ast_config_AST_DATA_DIR */
#include "asterisk/channel.h" #include "asterisk/channel.h"
@ -1870,6 +1873,14 @@ int ast_safe_fork(int stop_reaper)
return pid; return pid;
} else { } else {
/* Child */ /* Child */
#ifdef HAVE_CAP
cap_t cap = cap_from_text("cap_net_admin-eip");
if (cap_set_proc(cap)) {
ast_log(LOG_WARNING, "Unable to remove capabilities.\n");
}
cap_free(cap);
#endif
/* Before we unblock our signals, return our trapped signals back to the defaults */ /* Before we unblock our signals, return our trapped signals back to the defaults */
signal(SIGHUP, SIG_DFL); signal(SIGHUP, SIG_DFL);

@ -873,6 +873,15 @@ int ast_safe_system(const char *s)
#endif #endif
if (pid == 0) { if (pid == 0) {
#ifdef HAVE_CAP
cap_t cap = cap_from_text("cap_net_admin-eip");
if (cap_set_proc(cap)) {
/* Careful with order! Logging cannot happen after we close FDs */
ast_log(LOG_WARNING, "Unable to remove capabilities.\n");
}
cap_free(cap);
#endif
#ifdef HAVE_WORKING_FORK #ifdef HAVE_WORKING_FORK
if (ast_opt_high_priority) if (ast_opt_high_priority)
ast_set_priority(0); ast_set_priority(0);
@ -896,7 +905,7 @@ int ast_safe_system(const char *s)
} }
ast_unreplace_sigchld(); ast_unreplace_sigchld();
#else #else /* !defined(HAVE_WORKING_FORK) && !defined(HAVE_WORKING_VFORK) */
res = -1; res = -1;
#endif #endif
@ -3223,7 +3232,7 @@ int main(int argc, char *argv[])
if (has_cap) { if (has_cap) {
cap_t cap; cap_t cap;
cap = cap_from_text("cap_net_admin=ep"); cap = cap_from_text("cap_net_admin=eip");
if (cap_set_proc(cap)) if (cap_set_proc(cap))
ast_log(LOG_WARNING, "Unable to install capabilities.\n"); ast_log(LOG_WARNING, "Unable to install capabilities.\n");

Loading…
Cancel
Save