diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2009-02-28 04:33:51 +0300 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2009-02-28 04:33:51 +0300 |
commit | 796afe0536255a0f274431ee376b0d3deaf5dd96 (patch) | |
tree | 093715b40fbf45f5a57f61a190475143e4ddb0c4 | |
parent | 608a90cbceadcb9a62a001a51175ddcde4a7a715 (diff) |
Avoid messing with ulimits in murmurd, and first part of updated init script to use privileged capabilities
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@1600 05730e5d-ab1b-0410-a4ac-84af385074fa
-rwxr-xr-x | scripts/murmur.init | 19 | ||||
-rw-r--r-- | src/murmur/UnixMurmur.cpp | 11 | ||||
-rw-r--r-- | src/murmur/murmur_pch.h | 2 |
3 files changed, 18 insertions, 14 deletions
diff --git a/scripts/murmur.init b/scripts/murmur.init index bc6e5c160..3dd75a52a 100755 --- a/scripts/murmur.init +++ b/scripts/murmur.init @@ -25,6 +25,7 @@ test -x $DAEMON || exit 0 INIFILE=/etc/mumble-server.ini DAEMON_OPTS="-ini $INIFILE" MURMUR_DAEMON_START=0 +MURMUR_USE_CAPABILITIES=0 # Include murmur defaults if available if [ -f /etc/default/$NAME ] ; then @@ -42,11 +43,18 @@ case "$1" in fi [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" [ -d $PIDDIR ] || install -o $USER -d $PIDDIR - start-stop-daemon --start --quiet \ + if [ "$MURMUR_USE_CAPABILITIES" != "1" ] ; then + start-stop-daemon --start --quiet \ --pidfile $PIDFILE \ --chuid $USER:$GROUP \ --exec $DAEMON \ -- $DAEMON_OPTS + else + start-stop-daemon --start --quiet \ + --pidfile $PIDFILE \ + --exec $DAEMON \ + -- $DAEMON_OPTS + fi case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; @@ -84,11 +92,18 @@ case "$1" in 0|1) [ -d $PIDDIR ] || install -o $USER -d $PIDDIR rm -f $PIDFILE - start-stop-daemon --start --quiet \ + if [ "$MURMUR_USE_CAPABILITIES" != "1" ] ; then + start-stop-daemon --start --quiet \ --pidfile $PIDFILE \ --chuid $USER:$GROUP \ --exec $DAEMON \ -- $DAEMON_OPTS + else + start-stop-daemon --start --quiet \ + --pidfile $PIDFILE \ + --exec $DAEMON \ + -- $DAEMON_OPTS + fi case "$?" in 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;; *) [ "$VERBOSE" != no ] && log_end_msg 1 ;; diff --git a/src/murmur/UnixMurmur.cpp b/src/murmur/UnixMurmur.cpp index 393b103c6..530d0ab5b 100644 --- a/src/murmur/UnixMurmur.cpp +++ b/src/murmur/UnixMurmur.cpp @@ -227,7 +227,7 @@ void UnixMurmur::setuid() { void UnixMurmur::initialcap() { #ifdef Q_OS_LINUX - cap_value_t caps[] = {CAP_SYS_NICE, CAP_SYS_RESOURCE, CAP_NET_ADMIN, CAP_SETUID, CAP_SETGID, CAP_DAC_OVERRIDE }; + cap_value_t caps[] = {CAP_SYS_NICE, CAP_NET_ADMIN, CAP_SETUID, CAP_SETGID, CAP_DAC_OVERRIDE }; if (! bRoot) return; @@ -258,15 +258,6 @@ void UnixMurmur::finalcap() { if (! bRoot) return; - struct rlimit r; - getrlimit(RLIMIT_NOFILE, &r); - if (r.rlim_cur < 65536) { - r.rlim_max = (r.rlim_max > 65536) ? r.rlim_max : 65536; - r.rlim_cur = r.rlim_max; - qWarning("Increasing descriptor limit to %d.", static_cast<int>(r.rlim_cur)); - setrlimit(RLIMIT_NOFILE, &r); - } - int ncap = sizeof(caps)/sizeof(cap_value_t); cap_t c = cap_init(); diff --git a/src/murmur/murmur_pch.h b/src/murmur/murmur_pch.h index 02b874bbf..2e3f1d5ba 100644 --- a/src/murmur/murmur_pch.h +++ b/src/murmur/murmur_pch.h @@ -44,8 +44,6 @@ #include <sys/capability.h> #include <sys/prctl.h> #endif -#include <sys/time.h> -#include <sys/resource.h> #include <pwd.h> #ifdef __FreeBSD__ #include <netinet/in_systm.h> |