PKG_NAME:=asterisk15
PKG_VERSION:=15.6.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=asterisk-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.asterisk.org/pub/telephony/asterisk/releases
--- /dev/null
+From ae857488d97f94535d7c4dbe6049ddcc211bcf32 Mon Sep 17 00:00:00 2001
+From: George Joseph <gjoseph@digium.com>
+Date: Thu, 25 Oct 2018 09:25:58 -0600
+Subject: [PATCH] AST-2018-010: Fix length of buffer needed for SRV and NAPTR results
+
+When dn_expand was being called on SRV and NAPTR results, the
+return value was being used to calculate the size of the buffer
+needed to store the host names. Since dn_expand returns the
+length of the COMPRESSED name the buffer could be too short
+to hold the EXPANDED name. The expanded name is NULL terminated
+so using strlen() is the correct way to determine the length
+actually needed for the buffer.
+
+ASTERISK-28127
+Reported by: Jan Hoffmann
+
+patches:
+ patch.diff submitted by janhoffmann (license 6986)
+
+Change-Id: I4d35d6c431c6c6836cb61d37b1378cc47f0b414d
+---
+
+diff --git a/main/dns_naptr.c b/main/dns_naptr.c
+index 5490b55..4d67816 100644
+--- a/main/dns_naptr.c
++++ b/main/dns_naptr.c
+@@ -393,6 +393,7 @@
+ int replacement_size;
+ const char *end_of_record;
+ enum flags_result flags_res;
++ size_t naptr_len;
+
+ ptr = dns_find_record(data, size, query->result->answer, query->result->answer_size);
+ ast_assert(ptr != NULL);
+@@ -435,7 +436,14 @@
+ return NULL;
+ }
+
+- replacement_size = dn_expand((unsigned char *)query->result->answer, (unsigned char *) end_of_record, (unsigned char *) ptr, replacement, sizeof(replacement) - 1);
++ /*
++ * The return value from dn_expand represents the size of the replacement
++ * in the buffer which MAY be compressed. Since the expanded replacement
++ * is NULL terminated, you can use strlen() to get the expanded size.
++ */
++ replacement_size = dn_expand((unsigned char *)query->result->answer,
++ (unsigned char *) end_of_record, (unsigned char *) ptr,
++ replacement, sizeof(replacement) - 1);
+ if (replacement_size < 0) {
+ ast_log(LOG_ERROR, "Failed to expand domain name: %s\n", strerror(errno));
+ return NULL;
+@@ -475,7 +483,9 @@
+ return NULL;
+ }
+
+- naptr = ast_calloc(1, sizeof(*naptr) + size + flags_size + 1 + services_size + 1 + regexp_size + 1 + replacement_size + 1);
++ naptr_len = sizeof(*naptr) + size + flags_size + 1 + services_size + 1
++ + regexp_size + 1 + strlen(replacement) + 1;
++ naptr = ast_calloc(1, naptr_len);
+ if (!naptr) {
+ return NULL;
+ }
+diff --git a/main/dns_srv.c b/main/dns_srv.c
+index b562e32..e11c84e 100644
+--- a/main/dns_srv.c
++++ b/main/dns_srv.c
+@@ -73,7 +73,13 @@
+ return NULL;
+ }
+
+- host_size = dn_expand((unsigned char *)query->result->answer, (unsigned char *) end_of_record, (unsigned char *) ptr, host, sizeof(host) - 1);
++ /*
++ * The return value from dn_expand represents the size of the replacement
++ * in the buffer which MAY be compressed. Since the expanded replacement
++ * is NULL terminated, you can use strlen() to get the expanded size.
++ */
++ host_size = dn_expand((unsigned char *)query->result->answer,
++ (unsigned char *) end_of_record, (unsigned char *) ptr, host, sizeof(host) - 1);
+ if (host_size < 0) {
+ ast_log(LOG_ERROR, "Failed to expand domain name: %s\n", strerror(errno));
+ return NULL;
+@@ -83,7 +89,7 @@
+ return NULL;
+ }
+
+- srv = ast_calloc(1, sizeof(*srv) + size + host_size + 1);
++ srv = ast_calloc(1, sizeof(*srv) + size + strlen(host) + 1);
+ if (!srv) {
+ return NULL;
+ }
+@@ -94,8 +100,6 @@
+
+ srv->host = srv->data + size;
+ strcpy((char *)srv->host, host); /* SAFE */
+- ((char *)srv->host)[host_size] = '\0';
+-
+ srv->generic.data_ptr = srv->data;
+
+ return (struct ast_dns_record *)srv;
PKG_NAME:=baresip
PKG_VERSION:=0.5.9
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.creytiv.com/pub
EXTRA_MODULES="dtmfio" \
$(foreach m,$(baresip-mods),$(baresip-mod-$(m))=$(if $(CONFIG_PACKAGE_baresip-mod-$(subst _,-,$(m))),1))
+# According to upstream baresip can use x264 directly or through ffmpeg. ffmpeg
+# is preferred. The possibility to use it directly might even go away in the
+# future. So prevent baresip from linking directly to x264.
MAKE_FLAGS+= \
CROSS_COMPILE="$(TARGET_CROSS)" \
EXTRA_LFLAGS="$(TARGET_LDFLAGS)" \
RELEASE=1 \
SYSROOT="$(shell $(FIND) $(TOOLCHAIN_DIR) -path '*/include/pthread.h' | sed -ne '1s|/include/pthread.h||p')" \
SYSROOT_ALT="$(STAGING_DIR)/usr" \
- $(BARESIP_MOD_OPTIONS)
+ $(BARESIP_MOD_OPTIONS) \
+ USE_X264=
TARGET_CFLAGS+=-D_GNU_SOURCE
$(eval $(call BuildPlugin,alsa,ALSA audio driver,alsa,+alsa-lib))
$(eval $(call BuildPlugin,aubridge,Audio bridge module,aubridge,))
$(eval $(call BuildPlugin,aufile,Audio module for using a WAV-file as audio input,aufile,))
-$(eval $(call BuildPlugin,avcodec,Video codec using FFmpeg,avcodec,@BARESIP_WITH_FFMPEG +libffmpeg-full +libx264))
+$(eval $(call BuildPlugin,avcodec,Video codec using FFmpeg,avcodec,@BARESIP_WITH_FFMPEG +libffmpeg-full))
$(eval $(call BuildPlugin,avformat,Video source using FFmpeg,avformat,baresip-mod-avcodec))
$(eval $(call BuildPlugin,cons,UDP/TCP console UI driver,cons,))
$(eval $(call BuildPlugin,ctrl_tcp,TCP control interface,ctrl_tcp,))
PRG_NAME:=freeswitch
PKG_NAME:=$(PRG_NAME)-stable
PKG_VERSION:=1.8.2
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_MAINTAINER:=Sebastian Kemper <sebastian_ml@gmx.net>
PKG_SOURCE:=$(PRG_NAME)-$(PKG_VERSION).tar.xz
$(INSTALL_DIR) $(1)$(FS_STABLE_SCRIPTS_DIR)
$(INSTALL_DIR) $(1)$(FS_STABLE_SOUNDS_DIR)
$(INSTALL_DIR) $(1)$(FS_STABLE_SYSCONF_DIR)/config
+ $(INSTALL_DIR) $(1)$(FS_STABLE_SYSCONF_DIR)/hotplug.d/iface
$(INSTALL_DIR) $(1)$(FS_STABLE_SYSCONF_DIR)/init.d
$(INSTALL_DIR) $(1)$(FS_STABLE_TLS_DIR)
$(INSTALL_BIN) ./files/$(PRG_NAME).init \
$(1)$(FS_STABLE_SYSCONF_DIR)/init.d/$(PRG_NAME)
+ $(INSTALL_BIN) ./files/$(PRG_NAME).hotplug \
+ $(1)$(FS_STABLE_SYSCONF_DIR)/hotplug.d/iface/90-$(PRG_NAME)
$(INSTALL_CONF) ./files/$(PRG_NAME).config \
$(1)$(FS_STABLE_SYSCONF_DIR)/config/$(PRG_NAME)
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
- # Prevent $(PRG_NAME) from auto-starting after an upgrade. The modules may
- # not be upgraded yet and the user configuration may need a revision.
- uci set freeswitch.general.enabled=0
- uci commit freeswitch
-
echo
echo "o-------------------------------------------------------------------o"
echo "| FreeSWITCH note |"
echo "o-------------------------------------------------------------------o"
echo "| Edit /etc/config/freeswitch to change basic init configuration. |"
+ echo "| |"
+ echo "| Also visit the Wiki at: |"
+ echo "| https://openwrt.org/docs/guide-user/services/voip/freeswitch |"
echo "o-------------------------------------------------------------=^_^=-o"
echo
-fi
-exit 0
-endef
-
-define Package/$(PKG_NAME)-misc-hotplug
-$(call Package/$(PKG_NAME)/Default)
- TITLE:=Hotplug script
- DEPENDS:=$(PKG_NAME)
- PKGARCH:=all
-endef
-
-define Package/$(PKG_NAME)-misc-hotplug/description
-This package includes a hotplug script for FreeSWITCH.
-endef
-
-define Package/$(PKG_NAME)-misc-hotplug/install
- $(INSTALL_DIR) $(1)$(FS_STABLE_SYSCONF_DIR)/hotplug.d/iface
- $(INSTALL_BIN) ./files/$(PRG_NAME).hotplug \
- $(1)$(FS_STABLE_SYSCONF_DIR)/hotplug.d/iface/99-$(PRG_NAME)
-endef
-
-define Package/$(PKG_NAME)-misc-hotplug/postinst
-#!/bin/sh
-if [ -z "$${IPKG_INSTROOT}" ]; then
- echo
- echo "o-------------------------------------------------------------------o"
- echo "| FreeSWITCH hotplug note |"
- echo "o-------------------------------------------------------------------o"
- echo "| See /etc/config/freeswitch for hotplug hints. |"
- echo "o-------------------------------------------------------------=^_^=-o"
- echo
+ [ -f /etc/hotplug.d/iface/99-freeswitch ] && {
+ echo "o-------------------------------------------------------------------o"
+ echo "| WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING |"
+ echo "o-------------------------------------------------------------------o"
+ echo "| Please remove freeswitch-stable-misc-hotplug. The hotplug script |"
+ echo "| is now part of the main freeswitch-stable package. Please run: |"
+ echo "| |"
+ echo "| opkg remove freeswitch-stable-misc-hotplug |"
+ echo "o-------------------------------------------------------------=^_^=-o"
+ echo
+ }
fi
exit 0
endef
$(eval $(call BuildPackage,$(PKG_LIBFTDM)))
$(eval $(call BuildPackage,$(PKG_NAME)))
-$(eval $(call BuildPackage,$(PKG_NAME)-misc-hotplug))
$(eval $(call BuildPackage,$(PKG_NAME)-misc-perl-esl))
$(eval $(call BuildPackage,$(PKG_NAME)-misc-python-esl))
$(eval $(call BuildPackage,$(PKG_NAME)-misc-timezones))
option enabled '0'
option user 'freeswitch'
option group 'freeswitch'
+ option log_stderr '1'
+ option log_stdout '1'
option options '-nonat -np'
- option change_perm '0'
config freeswitch 'directories'
option cache '/tmp/freeswitch/cache'
#!/bin/sh
-FS=freeswitch
-LOGGER="/usr/bin/logger -t ${FS}-hotplug"
+NAME=freeswitch
+COMMAND=/etc/init.d/$NAME
+
+LOGGER="/usr/bin/logger -t $NAME-hotplug"
LOG_ERR="$LOGGER -p user.err --"
LOG_NOTICE="$LOGGER -p user.notice --"
-LOG_WARN="$LOGGER -p user.warn --"
[ "$ACTION" = ifup ] || exit 0
. /lib/functions.sh
-config_load $FS
-
-config_get FS_HOTPLUG_INTERFACE hotplug interface
+config_load $NAME
-[ -n "$FS_HOTPLUG_INTERFACE" ] || exit 0
+config_get interface hotplug interface
-[ "$INTERFACE" = "$FS_HOTPLUG_INTERFACE" ] || exit 0
+[ "$INTERFACE" = "$interface" ] || exit 0
-pgrep $FS &> /dev/null
+pidof $NAME &> /dev/null
if [ $? -eq 0 ]; then
- $LOG_NOTICE stopping $FS
- /etc/init.d/$FS stop &> /dev/null
- pgrep $FS &> /dev/null
- if [ $? -eq 0 ]; then
- $LOG_ERR failed to stop $FS
- exit 1
- else
- $LOG_NOTICE $FS stopped
- fi
+ $LOG_NOTICE stopping $NAME
+ $COMMAND stop &> /dev/null
fi
-config_get FS_HOTPLUG_TIMEOUT hotplug timeout
+config_get timeout hotplug timeout 60
-[ "$FS_HOTPLUG_TIMEOUT" -gt 0 ] 2> /dev/null || unset FS_HOTPLUG_TIMEOUT
-TIMEOUT="${FS_HOTPLUG_TIMEOUT:-60}"
+[ "$timeout" -gt 0 ] 2> /dev/null || unset timeout
+timeout="${timeout:-60}"
-config_get FS_HOTPLUG_MOUNTPOINT hotplug mount_point
+config_get mount_point hotplug mount_point
-# Mount condition, idea lifted from OpenWrt wiki
-[ -n "$FS_HOTPLUG_MOUNTPOINT" ] && {
+# Mount condition, idea lifted from OpenWrt Wiki
+[ -n "$mount_point" ] && {
- if ! [ -d "$FS_HOTPLUG_MOUNTPOINT" ]; then
- $LOG_ERR "$FS_HOTPLUG_MOUNTPOINT" not a valid mount point
+ if ! [ -d "$mount_point" ]; then
+ $LOG_ERR "$mount_point" not a valid mount point
exit 1
fi
- mnt="$FS_HOTPLUG_MOUNTPOINT"
+ mnt="$mount_point"
notReady=start
- timeout=$TIMEOUT
+ tmp_timeout=$timeout
- while [ -n "$notReady" -a $timeout -gt 0 ]; do
+ while [ -n "$notReady" -a $tmp_timeout -gt 0 ]; do
if [ "$notReady" != start ]; then
- $LOG_NOTICE "$mnt" not yet mounted, timeout in $timeout s
+ $LOG_NOTICE "$mnt" not yet mounted, timeout in $tmp_timeout s
sleep 5
- timeout=$(($timeout-5))
+ tmp_timeout=$(($tmp_timeout-5))
fi
notReady=
if [ -n "$notReady" ]; then
$LOG_ERR "$mnt" still not mounted
- $LOG_ERR not starting $FS
+ $LOG_ERR not starting $NAME
exit 1
else
$LOG_NOTICE "$mnt" mounted
}
-config_get_bool FS_HOTPLUG_NTPD hotplug ntpd 0
+config_get_bool ntpd hotplug ntpd 0
# ntpd condition
-[ $FS_HOTPLUG_NTPD -eq 1 ] && {
+[ $ntpd -eq 1 ] && {
type ntpq &> /dev/null
[ $? -eq 0 ] || {
exit 1
}
- pgrep ntpd &> /dev/null || {
+ pidof ntpd &> /dev/null || {
$LOG_ERR ntpd not running
exit 1
}
notReady=start
- timeout=$TIMEOUT
+ tmp_timeout=$timeout
- while [ -n "$notReady" -a $timeout -gt 0 ]; do
+ while [ -n "$notReady" -a $tmp_timeout -gt 0 ]; do
if [ "$notReady" != start ]; then
- $LOG_NOTICE system time not in sync yet, timeout in $timeout s
+ $LOG_NOTICE system time not in sync yet, timeout in $tmp_timeout s
sleep 5
- timeout=$(($timeout-5))
+ tmp_timeout=$(($tmp_timeout-5))
fi
notReady=
result=$(ntpq -c 'timeout 300' -c 'rv 0 stratum' 2> /dev/null | \
awk -F '=' '{print $2}' | grep -o -E '^[0-9]+')
if [ -z $result ]; then
- $LOG_WARN failed to extract stratum from ntpd
+ $LOG_ERR failed to extract stratum from ntpd
notReady="unable to extract stratum"
else
$LOG_NOTICE ntpd stratum $result
result=$(ntpq -c 'timeout 300' -c 'rv 0 offset' 2> /dev/null \
| awk -F '=' '{print $2}' | grep -o -E '^-?[0-9]+')
if [ -z $result ]; then
- $LOG_WARN failed to extract offset from ntpd
+ $LOG_ERR failed to extract offset from ntpd
notReady="unable to extract offset"
else
# "-0" looks stupid, so remove "-"
if [ -n "$notReady" ]; then
$LOG_ERR system time still not in sync
- $LOG_ERR not starting $FS
+ $LOG_ERR not starting $NAME
exit 1
else
$LOG_NOTICE system time in sync
}
-/etc/init.d/$FS start &> /dev/null
-# Wait a bit in order for pgrep to be able to find the new process
+$COMMAND start &> /dev/null
sleep 1
-pgrep $FS &>/dev/null
+pidof $NAME &>/dev/null
if [ $? -eq 0 ]; then
- $LOG_NOTICE started $FS due to \"ifup "$INTERFACE"\" event
+ $LOG_NOTICE started $NAME due to \"ifup "$INTERFACE"\" event
else
- $LOG_ERR start of $FS due to \"ifup "$INTERFACE"\" event failed
+ $LOG_ERR start of $NAME due to \"ifup "$INTERFACE"\" event failed
exit 1
fi
#PROCD_DEBUG=1
-FS=freeswitch
-LOGGER="/usr/bin/logger -p user.err -s -t $FS"
+NAME=freeswitch
+COMMAND=/usr/bin/$NAME
-# used in both start_service() and stop_service()
-fs_dir_run=/var/run/$FS
+LOGGER="/usr/bin/logger -p user.err -s -t $NAME"
start_service() {
- local change_perm
local dir
local enabled
- local fs_user
- local fs_group
+ local user
+ local group
- local fs_dir_cache
- local fs_dir_db
- local fs_dir_etc=/etc/$FS
- local fs_dir_localstate=/var/lib/$FS
- local fs_dir_log
- local fs_dir_recordings
- local fs_dir_storage
- local fs_dir_temp
+ local log_stderr
+ local log_stdout
- local OPTIONS
+ local dir_cache
+ local dir_db
+ local dir_etc=/etc/$NAME
+ local dir_localstate=/var/lib/$NAME
+ local dir_log
+ local dir_recordings
+ local dir_run=/var/run/$NAME
+ local dir_storage
+ local dir_temp
- local PROG=/usr/bin/$FS
+ local options
- config_load $FS
+ config_load $NAME
config_get_bool enabled general enabled 0
if [ $enabled -eq 0 ]; then
- $LOGGER service not enabled in /etc/config/$FS
+ $LOGGER service not enabled in /etc/config/$NAME
exit 1
fi
- config_get fs_user general user $FS
- config_get fs_group general group $FS
+ config_get user general user $NAME
+ config_get group general group $NAME
- config_get fs_dir_cache directories cache /tmp/$FS/cache
- config_get fs_dir_db directories db /tmp/$FS/db
- config_get fs_dir_log directories log /tmp/$FS/log
- config_get fs_dir_recordings directories recordings /tmp/$FS/recordings
- config_get fs_dir_storage directories storage /tmp/$FS/storage
- config_get fs_dir_temp directories temp /tmp/$FS/temp
+ config_get_bool log_stderr general log_stderr 1
+ config_get_bool log_stdout general log_stdout 1
- for dir in "$fs_dir_cache" "$fs_dir_db" "$fs_dir_localstate" \
- "$fs_dir_log" "$fs_dir_recordings" "$fs_dir_run" "$fs_dir_storage" \
- "$fs_dir_temp"
+ config_get dir_cache directories cache /tmp/$NAME/cache
+ config_get dir_db directories db /tmp/$NAME/db
+ config_get dir_log directories log /tmp/$NAME/log
+ config_get dir_recordings directories recordings /tmp/$NAME/recordings
+ config_get dir_storage directories storage /tmp/$NAME/storage
+ config_get dir_temp directories temp /tmp/$NAME/temp
+
+ for dir in "$dir_cache" "$dir_db" "$dir_localstate" \
+ "$dir_log" "$dir_recordings" "$dir_run" "$dir_storage" \
+ "$dir_temp"
do
- [ -n "$dir" ] && {
+ [ ! -e "$dir" ] && {
mkdir -p "$dir"
- chown "$fs_user":"$fs_group" "$dir"
+ chown "$user":"$group" "$dir"
chmod 750 "$dir"
}
done
- config_get_bool change_perm general change_perm 0
- [ $change_perm -eq 1 ] && [ -d "$fs_dir_etc" ] && {
- find "$fs_dir_etc" -type f -exec chown root:"$fs_group" {} \;
- find "$fs_dir_etc" -type f -exec chmod 640 {} \;
- }
-
- config_get OPTIONS general options
+ config_get options general options
procd_open_instance
# starting with full path seems cleaner judging by 'ps' output
- procd_set_param command $PROG
+ procd_set_param command $COMMAND
# need to specify all or none of -conf, -log, and -db
procd_append_param command \
- -cache "$fs_dir_cache" \
- -conf "$fs_dir_etc" \
- -db "$fs_dir_db" \
- -g "$fs_group" \
- -log "$fs_dir_log" \
- -recordings "$fs_dir_recordings" \
- -run "$fs_dir_run" \
- -storage "$fs_dir_storage" \
- -temp "$fs_dir_temp" \
- -u "$fs_user" \
- $OPTIONS \
- -nc \
- -nf
+ -cache "$dir_cache" \
+ -conf "$dir_etc" \
+ -db "$dir_db" \
+ -g "$group" \
+ -log "$dir_log" \
+ -recordings "$dir_recordings" \
+ -run "$dir_run" \
+ -storage "$dir_storage" \
+ -temp "$dir_temp" \
+ -u "$user" \
+ $options \
+ -c
# forward stderr to logd
- procd_set_param stderr 1
+ procd_set_param stderr $log_stderr
+ # same for stdout
+ procd_set_param stdout $log_stdout
procd_close_instance
}
-stop_service() {
- local retval
- local mypid
- local TIMEOUT=30
- local timeout=$TIMEOUT
-
- pgrep $FS &> /dev/null
- [ $? -ne 0 ] && exit 0
-
- [ -f "$fs_dir_run"/${FS}.pid ]
- retval=$?
-
- # init script could find itself in a scenario where FS was started
- # very recently, so make it wait a while for a pid file to appear
- while [ $retval -ne 0 -a $timeout -gt 0 ]; do
- sleep 1
- [ -f "$fs_dir_run"/${FS}.pid ]
- retval=$?
- timeout=$(($timeout-1))
- done
-
- [ $retval -eq 0 ] || {
- $LOGGER PID file does not exist
- exit 1
- }
-
- mypid=$(cat "$fs_dir_run"/${FS}.pid)
-
- [ "$mypid" -gt 1 ] 2> /dev/null || {
- $LOGGER PID file contains garbage
- exit 1
- }
-
- timeout=$TIMEOUT
- kill $mypid 2>/dev/null
- pgrep $FS | grep -w $mypid &>/dev/null
- retval=$?
-
- while [ $retval -eq 0 -a $timeout -gt 0 ]; do
- sleep 10
- pgrep $FS | grep -w $mypid &>/dev/null
- retval=$?
- [ $retval -eq 0 ] && kill $mypid 2>/dev/null
- timeout=$(($timeout-10))
- done
-
- [ $retval -ne 1 ] && {
- $LOGGER application seems to hang
- $LOGGER sending SIGKILL
- kill -SIGKILL $mypid 2>/dev/null
- sleep 3
- pgrep $FS | grep -w $mypid &>/dev/null
- retval=$?
- }
-
- [ $retval -ne 1 ] && {
- $LOGGER failed to stop $FS
- exit 1
- }
-}
--- /dev/null
+--- a/src/switch_console.c
++++ b/src/switch_console.c
+@@ -1053,10 +1053,12 @@ static void *SWITCH_THREAD_FUNC console_
+ while (running) {
+ int32_t arg = 0;
+
+- if (getppid() == 1) {
+- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We've become an orphan, no more console for us.\n");
+- break;
+- }
++ // Parent PID is 1 when started by procd - so FS is not an orphan.
++ // Plus we still want the output.
++ //if (getppid() == 1) {
++ // switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We've become an orphan, no more console for us.\n");
++ // break;
++ //}
+
+ switch_core_session_ctl(SCSC_CHECK_RUNNING, &arg);
+ if (!arg) {
include $(TOPDIR)/rules.mk
PKG_NAME:=kamailio5
-PKG_VERSION:=5.1.3
-PKG_RELEASE:=4
+PKG_VERSION:=5.1.6
+PKG_RELEASE:=1
-PKG_SOURCE_URL:=https://www.kamailio.org/pub/kamailio/$(PKG_VERSION)/src
+PKG_SOURCE_URL := \
+ https://sources.openwrt.org \
+ https://www.kamailio.org/pub/kamailio/$(PKG_VERSION)/src
PKG_SOURCE:=kamailio-$(PKG_VERSION)$(PKG_VARIANT)_src.tar.gz
-PKG_HASH:=b2266e15ec8ffa62be66b44989155f26a31d137f06f81fb3841aad8315315a14
+PKG_HASH:=99880df20dd836e4d9ec03fe863f7a5fc77bb29e3d56f59ea92b8b986deb5186
PKG_USE_MIPS16:=0
PKG_LICENSE:=GPL-2.0+
PKG_LICENSE_FILES:=COPYING
PKG_MAINTAINER:=Jiri Slachta <jiri@slachta.eu>
-PKG_BUILD_PARALLEL:=1
+# Defining PKG_BUILD_PARALLEL to 1 would be a noop due to the way we call make
+#PKG_BUILD_PARALLEL:=1
MODULES_AVAILABLE:= \
acc \
define Package/kamailio5
$(call Package/kamailio5/Default)
TITLE:=Mature and flexible open source SIP server, v$(PKG_VERSION)
+ USERID:=kamailio=380:kamailio=380
MENU:=1
endef
define Package/kamailio5/conffiles
-/etc/default/kamailio
+/etc/config/kamailio
+/etc/init.d/kamailio
/etc/kamailio/kamailio.cfg
/etc/kamailio/kamctlrc
endef
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/kamailio/lib{srdb1,srdb2,srutils}.so* \
$(1)/usr/lib/kamailio/
- $(INSTALL_DIR) $(1)/etc/default
+ $(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) \
- ./files/kamailio.default \
- $(1)/etc/default/kamailio
+ ./files/kamailio.config \
+ $(1)/etc/config/kamailio
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) \
./files/kamailio.init \
$(1)/etc/init.d/kamailio
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_BIN) \
+ ./files/kamailio.hotplug \
+ $(1)/etc/hotplug.d/iface
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/kamailio/kamctl \
$(1)/usr/lib/kamailio/
endef
+define Package/kamailio5/postinst
+#!/bin/sh
+if [ -z "$${IPKG_INSTROOT}" ]; then
+ echo
+ echo "o-------------------------------------------------------------------o"
+ echo "| Kamailio note |"
+ echo "o-------------------------------------------------------------------o"
+ echo "| Edit /etc/config/kamailio to change basic init configuration. |"
+ echo "o-------------------------------------------------------------=^_^=-o"
+ echo
+fi
+exit 0
+endef
+
define Package/kamailio5/install/conffile
$(INSTALL_DIR) $(1)/etc/kamailio
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/kamailio/$(2) $(1)/etc/kamailio
#
# When CONFIG_CPU_TYPE matches one of the identifiers in the list below, set
# ARCH to "mips2" to get FAST_LOCK support.
+ifeq ($(call qstrip,$(CONFIG_ARCH)),mips)
CPU_MIPS2:=mips32 24kc 34kc 74kc
+endif
PKG_MAKE_ARGS:= \
prefix=/ \
DESTDIR=$(PKG_INSTALL_DIR) \
quiet=verbose
+define Build/Configure
+endef
+
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) $(PKG_MAKE_ARGS) cfg
$(MAKE) -C $(PKG_BUILD_DIR) quiet=verbose all
$(eval $(call BuildKamailio5Module,acc,Accounting,,+kamailio5-mod-tm))
$(eval $(call BuildKamailio5Module,acc_diameter,Accounting for DIAMETER backend,,+kamailio5-mod-acc))
-$(eval $(call BuildKamailio5Module,alias_db,Database-backend aliases,,+kamailio5-mod-db-sqlite))
+$(eval $(call BuildKamailio5Module,alias_db,Database-backend aliases,,))
$(eval $(call BuildKamailio5Module,app_jsdt,Execute JavaScript scripts,,))
$(eval $(call BuildKamailio5Module,app_lua,Execute embedded Lua scripts,,+liblua))
$(eval $(call BuildKamailio5Module,app_python,Execute Python scripts,,+python-light))
$(eval $(call BuildKamailio5Module,app_sqlang,Execute Squirrel language scripts,,+libstdcpp))
$(eval $(call BuildKamailio5Module,async,Asynchronous SIP handling functions,,+kamailio5-mod-tm +kamailio5-mod-tmx))
$(eval $(call BuildKamailio5Module,auth,Authentication Framework,,))
-$(eval $(call BuildKamailio5Module,auth_db,Database-backend authentication,,+kamailio5-mod-auth +kamailio5-mod-db-sqlite))
+$(eval $(call BuildKamailio5Module,auth_db,Database-backend authentication,,+kamailio5-mod-auth))
$(eval $(call BuildKamailio5Module,auth_diameter,Diameter authentication,,+kamailio5-mod-sl))
$(eval $(call BuildKamailio5Module,auth_ephemeral,Ephemeral credentials,,+libopenssl))
$(eval $(call BuildKamailio5Module,auth_identity,Identity authentication,,+libopenssl +libcurl))
$(eval $(call BuildKamailio5Module,cdp,C Diameter Peer,,))
$(eval $(call BuildKamailio5Module,cdp_avp,CDP AVP helper module,,+kamailio5-mod-cdp))
$(eval $(call BuildKamailio5Module,cfgutils,Config utilities,,))
-$(eval $(call BuildKamailio5Module,cfg_db,Load parameters from database,,+kamailio5-mod-db-sqlite))
+$(eval $(call BuildKamailio5Module,cfg_db,Load parameters from database,,))
$(eval $(call BuildKamailio5Module,cfg_rpc,Update parameters via RPC,,))
$(eval $(call BuildKamailio5Module,cfgt,Unit test reporting,,))
$(eval $(call BuildKamailio5Module,cnxcc,Limit call duration,,+kamailio5-mod-dialog +libhiredis +libevent2))
$(eval $(call BuildKamailio5Module,jansson,Access to JSON attributes,,+jansson))
$(eval $(call BuildKamailio5Module,janssonrpcc,Alternative JSONRPC server,,+kamailio5-mod-jansson +libevent2))
$(eval $(call BuildKamailio5Module,json,Access to JSON document attributes,,+libjson-c))
-$(eval $(call BuildKamailio5Module,jsonrpcs,JSONRPC server over HTTP,,+kamailio5-mod-json +libevent2))
+$(eval $(call BuildKamailio5Module,jsonrpcs,JSONRPC server over HTTP,,+libevent2))
$(eval $(call BuildKamailio5Module,keepalive,SIP keepalive monitoring,+kamailio5-mod-tm,))
$(eval $(call BuildKamailio5Module,kex,Core extensions,,))
$(eval $(call BuildKamailio5Module,lcr,Least Cost Routing,,+kamailio5-mod-tm +libpcre))
--- /dev/null
+
+config kamailio 'general'
+ option enabled 0
+ option user kamailio
+ option group kamailio
+ # Amount of shared and private memory to allocate in MByte:
+ option shm_memory 8
+ option pkg_memory 2
+ option cfg_file /etc/kamailio/kamailio.cfg
+ # The lists "listen" and "listen6" basically have the same
+ # effect - each list entry will be added to the Kamailio command
+ # line ("-l address"). However, the init script will try to
+ # resolve any interface specifier into an IPv4 ("listen") or
+ # IPv6 ("listen6") address before starting Kamailio. These lists
+ # may be helpful when using dynamic IPs.
+ #list listen udp:wan:5060
+ #list listen udp:192.168.1.1:5060
+ #list listen6 udp:wan:5060
+ # Any other option can be put between the quotes below:
+ #option options ""
+
+config kamailio 'hotplug'
+ # Uncomment to enable hotplug:
+ #option interface 'wan'
+
+++ /dev/null
-#
-# Kamailio startup options
-#
-
-# Set to yes to enable kamailio, once configured properly.
-#RUN_KAMAILIO=yes
-
-# Amount of shared and private memory to allocate
-# for the running Kamailio server (in Mb)
-#SHM_MEMORY=64
-#PKG_MEMORY=4
-
-# Config file
-#CFGFILE=/etc/kamailio/kamailio.cfg
--- /dev/null
+#!/bin/sh
+
+[ "$ACTION" = ifup ] || exit 0
+
+NAME=kamailio
+COMMAND=/etc/init.d/$NAME
+LOGGER="/usr/bin/logger -t hotplug"
+
+$COMMAND enabled || exit 0
+
+. /lib/functions.sh
+
+config_load $NAME
+
+config_get_bool enabled general enabled 0
+[ $enabled -eq 0 ] && exit 0
+
+config_get hotplug_iface hotplug interface
+
+[ "$INTERFACE" = "$hotplug_iface" ] && {
+ $LOGGER "Restarting $NAME due to \"$ACTION\" of \"$INTERFACE\""
+ $COMMAND restart
+}
+
#!/bin/sh /etc/rc.common
-# Copyright (C) 2014 OpenWrt.org
+# Copyright (C) 2014 - 2018 OpenWrt.org
START=99
-BINFILE=/usr/sbin/kamailio
-PIDFILE=/var/run/kamailio.pid
-DEFAULTS=/etc/default/kamailio
-CFGFILE=/etc/kamailio/kamailio.cfg
-SHM_MEMORY=8
-PKG_MEMORY=2
-RUN_KAMAILIO=no
-
-start() {
- # Load startup options if available
- if [ -f $DEFAULTS ]; then
- . $DEFAULTS
- fi
-
- if [ "$RUN_KAMAILIO" != "yes" ]; then
- echo "[WARNING] Kamailio not yet configured. Edit /etc/default/kamailio first."
- else
- start-stop-daemon -S -x $BINFILE -b -- -P $PIDFILE -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY
- echo "[INFO] Kamailio has succesfully started."
- fi
-}
+NAME=kamailio
+COMMAND=/usr/sbin/$NAME
+
+RUNDIR=/var/run/$NAME
+PIDFILE=$RUNDIR/$NAME.pid
+
+LOG_ERR="/usr/bin/logger -p user.err -s -t $NAME"
+
+USE_PROCD=1
+
+#PROCD_DEBUG=1
+
+check_listen() {
+ local value="$1"
+ local type="$2"
+
+ local address
+ local has_proto=0
+ local one two three
+ local tmp
+
+ [ -z "$value" ] && {
+ $LOG_ERR empty $type entry
+ exit 1
+ }
+
+ # IPv6 addresses need to be enclosed in square brackets. If there are
+ # square brackets in the listen entry, just copy it.
+ echo "$value" | grep "\[[0-9:A-Fa-f]*\]" &> /dev/null && {
+ options=$options" -l $value"
+ return
+ }
+
+ # Bail if more than 2 colons.
+ [ $(echo "$value" | awk -F ":" '{print NF-1}') -gt 2 ] && {
+ $LOG_ERR init script does not understand $type entry \""$value"\"
+ exit 1
+ }
+
+ IFS=":" read one two three << EOF
+$value
+EOF
+
+ case "$one" in
+ udp|tcp|tls|sctp)
+ tmp="$two"
+ has_proto=1
+ ;;
+ *)
+ tmp="$one"
+ ;;
+ esac
-stop() {
- start-stop-daemon -K -x $BINFILE -p $PIDFILE -q
- rm -rf $PID_FILE
+ if [ "$type" = "listen" ]; then
+ network_get_ipaddr address "$tmp" || address="$tmp"
+ else
+ network_get_ipaddr6 address "$tmp" && address="[$address]" || \
+ address="$tmp"
+ fi
+
+ if [ -n "$three" ]; then
+ tmp="$one:$address:$three"
+ elif [ -n "$two" ]; then
+ if [ $has_proto = 1 ]; then
+ tmp="$one:$address"
+ else
+ tmp="$address:$two"
+ fi
+ else
+ tmp="$address"
+ fi
+
+ options=$options" -l $tmp"
}
-restart(){
- echo "[INFO] Restarting kamailio. Waiting 5 seconds before start."
- stop
- sleep 5
- start
+start_service() {
+ local enabled
+ local user
+ local group
+ local shm_memory
+ local pkg_memory
+ local cfg_file
+ local options
+
+ config_load $NAME
+
+ config_get_bool enabled general enabled 0
+
+ if [ $enabled -eq 0 ]; then
+ $LOG_ERR service not enabled in /etc/config/$NAME
+ exit 1
+ fi
+
+ config_get user general user $NAME
+ config_get group general group $NAME
+ config_get shm_memory general shm_memory 8
+ config_get pkg_memory general pkg_memory 2
+ config_get cfg_file general cfg_file /etc/$NAME/$NAME.cfg
+ config_get options general options
+
+ . /lib/functions/network.sh
+
+ config_list_foreach general listen check_listen listen
+ config_list_foreach general listen6 check_listen listen6
+
+ if [ ! -d $RUNDIR ]; then
+ mkdir -p $RUNDIR
+ chown "$user":"$group" $RUNDIR
+ fi
+
+ procd_open_instance
+ procd_set_param command $COMMAND
+ procd_append_param command \
+ -P $PIDFILE \
+ -f "$cfg_file" \
+ -m "$shm_memory" \
+ -M "$pkg_memory" \
+ $options \
+ -u "$user" \
+ -g "$group" \
+ -DD -E
+ # forward stderr to logd
+ procd_set_param stderr 1
+ procd_close_instance
}
+
+++ /dev/null
-commit 281a6c6b6eaaf30058b603325e8ded20b99e1456
-Author: Henning Westerholt <hw@kamailio.org>
-Date: Mon May 7 09:36:53 2018 +0200
-
- core: improve to header check guards, str consists of length and pointer
-
-diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
-index 22122768a..4dd648e87 100644
---- a/src/core/msg_translator.c
-+++ b/src/core/msg_translator.c
-@@ -2369,7 +2369,7 @@ char * build_res_buf_from_sip_req( unsigned int code, str *text ,str *new_tag,
- case HDR_TO_T:
- if (new_tag && new_tag->len) {
- to_tag=get_to(msg)->tag_value;
-- if ( to_tag.len || to_tag.s )
-+ if ( to_tag.len && to_tag.s )
- len+=new_tag->len-to_tag.len;
- else
- len+=new_tag->len+TOTAG_TOKEN_LEN/*";tag="*/;
-@@ -2497,7 +2497,7 @@ char * build_res_buf_from_sip_req( unsigned int code, str *text ,str *new_tag,
- break;
- case HDR_TO_T:
- if (new_tag && new_tag->len){
-- if (to_tag.s ) { /* replacement */
-+ if (to_tag.len && to_tag.s) { /* replacement */
- /* before to-tag */
- append_str( p, hdr->name.s, to_tag.s-hdr->name.s);
- /* to tag replacement */
+++ /dev/null
-commit d67b2f9874ca23bd69f18df71b8f53b1b6151f6d
-Author: Henning Westerholt <hw@kamailio.org>
-Date: Sun Jun 3 20:59:32 2018 +0200
-
- core: improve header safe guards for Via handling
-
- (cherry picked from commit ad68e402ece8089f133c10de6ce319f9e28c0692)
-
-diff --git a/src/core/crc.c b/src/core/crc.c
-index 462846324..23b2876ec 100644
---- a/src/core/crc.c
-+++ b/src/core/crc.c
-@@ -231,6 +231,8 @@ void crcitt_string_array( char *dst, str src[], int size )
- ccitt = 0xFFFF;
- str_len=CRC16_LEN;
- for (i=0; i<size; i++ ) {
-+ /* invalid str with positive length and null char pointer */
-+ if( unlikely(src[i].s==NULL)) break;
- c=src[i].s;
- len=src[i].len;
- while(len) {
-diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
-index 201e3a5e1..58978f958 100644
---- a/src/core/msg_translator.c
-+++ b/src/core/msg_translator.c
-@@ -168,12 +168,17 @@ static int check_via_address(struct ip_addr* ip, str *name,
- (name->s[name->len-1]==']')&&
- (strncasecmp(name->s+1, s, len)==0))
- )
-- )
-+ ) {
- return 0;
-- else
--
-+ }
-+ else {
-+ if (unlikely(name->s==NULL)) {
-+ LM_CRIT("invalid Via host name\n");
-+ return -1;
-+ }
- if (strncmp(name->s, s, name->len)==0)
- return 0;
-+ }
- }else{
- LM_CRIT("could not convert ip address\n");
- return -1;
Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
-diff --git a/utils/kamctl/kamctl.base b/utils/kamctl/kamctl.base
-index adeceb77f..a776e10d8 100644
--- a/utils/kamctl/kamctl.base
+++ b/utils/kamctl/kamctl.base
-@@ -715,7 +715,7 @@ filter_json()
+@@ -699,7 +699,7 @@ filter_json()
$AWK 'function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
BEGIN { line=0; IGNORECASE=1; }
{ line++; }
--- /dev/null
+commit cbff35909edccffe778d04f3871d880195d82b7a
+Author: Sebastian Kemper <sebastian_ml@gmx.net>
+Date: Fri Nov 2 10:10:38 2018 +0100
+
+ dialplan: fix dp_replace() in cmd_export_t struct
+
+ In the struct 'int param_no' is set to '2'. But dp_replace() has actually three
+ parameters (dpid, inval, outvar), so kamailio's cfg parser fails when
+ dp_replace() is called:
+
+ yyparse(): cfg. parser: failed to find command dp_replace (params 3)
+ yyerror_at(): parse error in config file /etc/kamailio/kamailio.cfg, line 366, column 45: unknown command, missing loadmodule?
+
+ This commit fixes 'int param_no' to address this.
+
+ Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
+
+diff --git a/src/modules/dialplan/dialplan.c b/src/modules/dialplan/dialplan.c
+index 39ba1ceef..a96b246b7 100644
+--- a/src/modules/dialplan/dialplan.c
++++ b/src/modules/dialplan/dialplan.c
+@@ -115,7 +115,7 @@ static cmd_export_t cmds[]={
+ ANY_ROUTE},
+ {"dp_match",(cmd_function)w_dp_match, 2, fixup_igp_spve,
+ fixup_free_igp_spve, ANY_ROUTE},
+- {"dp_replace",(cmd_function)w_dp_replace, 2, dp_replace_fixup,
++ {"dp_replace",(cmd_function)w_dp_replace, 3, dp_replace_fixup,
+ dp_replace_fixup_free, ANY_ROUTE},
+ {0,0,0,0,0,0}
+ };