diff options
author | Stefan Knoblich <stkn@gentoo.org> | 2005-05-15 21:46:23 +0000 |
---|---|---|
committer | Stefan Knoblich <stkn@gentoo.org> | 2005-05-15 21:46:23 +0000 |
commit | 2e86aa946cc5280cb85ec2e22cc3b5d2be3e608d (patch) | |
tree | 3a471019d3d86a260fcb7863e1eea83bb751604f /net-misc/asterisk/files | |
parent | gcc -> toolchain-funcs conversion (diff) | |
download | gentoo-2-2e86aa946cc5280cb85ec2e22cc3b5d2be3e608d.tar.gz gentoo-2-2e86aa946cc5280cb85ec2e22cc3b5d2be3e608d.tar.bz2 gentoo-2-2e86aa946cc5280cb85ec2e22cc3b5d2be3e608d.zip |
Added initgroups support to asterisk, this fixes realtime priority support (-p). Fixed the init script, users will have to run ebuild config to change permissions on the filesystem, warning messages have been added.
(Portage version: 2.0.51.19)
Diffstat (limited to 'net-misc/asterisk/files')
-rw-r--r-- | net-misc/asterisk/files/1.0.0/asterisk-1.0.7-initgroups.diff | 64 | ||||
-rw-r--r-- | net-misc/asterisk/files/1.0.0/asterisk.confd.sec | 12 | ||||
-rw-r--r-- | net-misc/asterisk/files/1.0.0/asterisk.rc6.sec | 30 |
3 files changed, 98 insertions, 8 deletions
diff --git a/net-misc/asterisk/files/1.0.0/asterisk-1.0.7-initgroups.diff b/net-misc/asterisk/files/1.0.0/asterisk-1.0.7-initgroups.diff new file mode 100644 index 000000000000..98ae11aa180c --- /dev/null +++ b/net-misc/asterisk/files/1.0.0/asterisk-1.0.7-initgroups.diff @@ -0,0 +1,64 @@ +--- asterisk-1.0.7/asterisk.c.orig 2005-05-12 21:33:21.000000000 +0200 ++++ asterisk-1.0.7/asterisk.c 2005-05-12 21:38:33.000000000 +0200 +@@ -1581,7 +1581,9 @@ int main(int argc, char *argv[]) + int num; + char *buf; + char *runuser=NULL, *rungroup=NULL; +- struct pollfd silly_macos[1]; ++ struct pollfd silly_macos[1]; ++ gid_t runasgid = 0; ++ uid_t runasuid = 0; + + /* Remember original args for restart */ + if (argc > sizeof(_argv) / sizeof(_argv[0]) - 1) { +@@ -1701,17 +1703,9 @@ int main(int argc, char *argv[]) + ast_log(LOG_WARNING, "No such group '%s'!\n", rungroup); + exit(1); + } +- if (setgid(gr->gr_gid)) { +- ast_log(LOG_WARNING, "Unable to setgid to %d (%s)\n", gr->gr_gid, rungroup); +- exit(1); +- } +- if (option_verbose) +- ast_verbose("Running as group '%s'\n", rungroup); ++ runasgid = gr->gr_gid; + } + +- if (set_priority(option_highpriority)) { +- exit(1); +- } + if (runuser) { + struct passwd *pw; + pw = getpwnam(runuser); +@@ -1719,8 +1713,29 @@ int main(int argc, char *argv[]) + ast_log(LOG_WARNING, "No such user '%s'!\n", runuser); + exit(1); + } +- if (setuid(pw->pw_uid)) { +- ast_log(LOG_WARNING, "Unable to setuid to %d (%s)\n", pw->pw_uid, runuser); ++ runasuid = pw->pw_uid; ++ } ++ ++ if (set_priority(option_highpriority)) { ++ exit(1); ++ } ++ ++ if (runasgid) { ++ if (setgid(runasgid)) { ++ ast_log(LOG_WARNING, "Unable to setgid to %d (%s)\n", runasgid, rungroup); ++ exit(1); ++ } ++ if (option_verbose) ++ ast_verbose("Running as group '%s'\n", rungroup); ++ } ++ ++ if (runasuid) { ++ if(initgroups(runuser, runasgid) < 0) { ++ ast_log(LOG_WARNING, "Unable to set supplemental groups for %s\n", runuser); ++ exit(1); ++ } ++ if (setuid(runasuid)) { ++ ast_log(LOG_WARNING, "Unable to setuid to %d (%s)\n", runasuid, runuser); + exit(1); + } + if (option_verbose) diff --git a/net-misc/asterisk/files/1.0.0/asterisk.confd.sec b/net-misc/asterisk/files/1.0.0/asterisk.confd.sec index 1c678d8346b9..780903613d2a 100644 --- a/net-misc/asterisk/files/1.0.0/asterisk.confd.sec +++ b/net-misc/asterisk/files/1.0.0/asterisk.confd.sec @@ -1,6 +1,6 @@ # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/files/1.0.0/asterisk.confd.sec,v 1.2 2005/05/11 12:47:06 stkn Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/files/1.0.0/asterisk.confd.sec,v 1.3 2005/05/15 21:46:23 stkn Exp $ # # see "asterisk -h" for a list of options @@ -13,6 +13,14 @@ ASTERISK_OPTS="" # Examples: # "user:group" # "user" -# "" for root +# "" or unset = root:root # ASTERISK_USER="asterisk:asterisk" + +# +# Nicelevel +# +# Set the priority of the asterisk process +# +# Range: 20 +#ASTERISK_NICE="-20" diff --git a/net-misc/asterisk/files/1.0.0/asterisk.rc6.sec b/net-misc/asterisk/files/1.0.0/asterisk.rc6.sec index 6ab451443ac9..5d2b14b28082 100644 --- a/net-misc/asterisk/files/1.0.0/asterisk.rc6.sec +++ b/net-misc/asterisk/files/1.0.0/asterisk.rc6.sec @@ -1,7 +1,7 @@ #!/sbin/runscript # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/files/1.0.0/asterisk.rc6.sec,v 1.1 2005/05/07 18:35:35 stkn Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/files/1.0.0/asterisk.rc6.sec,v 1.2 2005/05/15 21:46:23 stkn Exp $ depend() { need net logger @@ -9,15 +9,33 @@ depend() { } start() { + local OPTS USER GROUP + + if [[ -n "${ASTERISK_NICE}" ]]; then + if [[ ${ASTERISK_NICE} -ge -20 ]] && \ + [[ ${ASTERISK_NICE} -le 19 ]]; then + OPTS="--nicelevel ${ASTERISK_NICE}" + else + eerror "Nice value must be between -20 and 19" + fi + fi + if [[ -n "${ASTERISK_USER}" ]]; then - ebegin "Starting asterisk PBX (as ${ASTERISK_USER})" - start-stop-daemon --start --exec /usr/sbin/asterisk \ - --chuid ${ASTERISK_USER} -- ${ASTERISK_OPTS} + USER=${ASTERISK_USER/:*/} + GROUP=$(echo $ASTERISK_USER | awk -F: '/.*:.*/ { print $2 }') + if [[ -n "${USER}" ]]; then + ASTERISK_OPTS="${ASTERISK_OPTS} -U ${USER}" + fi + if [[ -n "${GROUP}" ]]; then + ASTERISK_OPTS="${ASTERISK_OPTS} -G ${GROUP}" + GROUP=":${GROUP}" # make it look nice... + fi + ebegin "Starting asterisk PBX (as ${USER}${GROUP})" else ebegin "Starting asterisk PBX (as root)" - start-stop-daemon --start --exec /usr/sbin/asterisk -- \ - ${ASTERISK_OPTS} fi + start-stop-daemon --start --exec /usr/sbin/asterisk \ + ${OPTS} -- ${ASTERISK_OPTS} eend $? } |