commit a5d12e37c717bb8f1f52b2c0076882b1caf4d9d4 Author: Kevin Bowling Date: Fri Mar 11 01:11:24 2016 -0700 Fix zabbix rc.d scripts to not leak SysV IPC or race on restart diff --git a/net-mgmt/zabbix2-server/files/zabbix_agentd.in b/net-mgmt/zabbix2-server/files/zabbix_agentd.in index 4af7fa7..ddff711 100644 --- a/net-mgmt/zabbix2-server/files/zabbix_agentd.in +++ b/net-mgmt/zabbix2-server/files/zabbix_agentd.in @@ -9,6 +9,10 @@ # # zabbix_agentd_enable (bool): Set to NO by default. Set it to YES to # enable zabbix_agentd. +# zabbix_agentd_paths (string): Set to standard path by default. Set a search +# if you have custom userparams that need binaries elsewhere. +# zabbix_agentd_config (string): Set to the standard config file path by +# default. # . /etc/rc.subr @@ -16,11 +20,33 @@ name="zabbix_agentd" rcvar=zabbix_agentd_enable -command="%%PREFIX%%/sbin/${name}" -required_files="%%ETCDIR%%/${name}.conf" - load_rc_config $name : ${zabbix_agentd_enable="NO"} +: ${zabbix_agentd_paths=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin} +: ${zabbix_agentd_config="%%ETCDIR%%/${name}.conf"} + +command="%%PREFIX%%/sbin/${name}" +required_files="${zabbix_agentd_config}" +start_precmd="find_pidfile" +status_precmd="find_pidfile" +stop_precmd="find_pidfile" + +find_pidfile() +{ + if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then + pidfile="$_pidfile_from_conf" + else + pidfile="/tmp/${name}.pid" + fi + + # This shouldn't be necessary with pidfile, but empirically it was the + # only way to reap the parent PID instead of all PIDs from + # check_process, which may leak SysV IPC objects and prevent restart + # and/or race condition on restart. + rc_pid=$(check_pidfile ${pidfile} ${command}) +} + +export PATH="${zabbix_agentd_paths}" run_rc_command "$1" diff --git a/net-mgmt/zabbix2-server/files/zabbix_proxy.in b/net-mgmt/zabbix2-server/files/zabbix_proxy.in index 58898c6..407c731 100644 --- a/net-mgmt/zabbix2-server/files/zabbix_proxy.in +++ b/net-mgmt/zabbix2-server/files/zabbix_proxy.in @@ -9,6 +9,10 @@ # # zabbix_proxy_enable (bool): Set to NO by default. Set it to YES to # enable zabbix_proxy. +# zabbix_proxy_paths (string): Set to standard path by default. Set a search +# if you have custom externals that need binaries elsewhere. +# zabbix_proxy_config (string): Set to the standard config file path by +# default. # . /etc/rc.subr @@ -16,11 +20,34 @@ name="zabbix_proxy" rcvar=zabbix_proxy_enable -command="%%PREFIX%%/sbin/${name}" -required_files="%%ETCDIR%%/${name}.conf" - load_rc_config $name : ${zabbix_proxy_enable="NO"} +: ${zabbix_proxy_paths=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin} +: ${zabbix_proxy_config="%%ETCDIR%%/${name}.conf"} + +command="%%PREFIX%%/sbin/${name}" +required_files="${zabbix_proxy_config}" +start_precmd="find_pidfile" +status_precmd="find_pidfile" +stop_precmd="find_pidfile" + + +find_pidfile() +{ + if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then + pidfile="$_pidfile_from_conf" + else + pidfile="/tmp/${name}.pid" + fi + + # This shouldn't be necessary with pidfile, but empirically it was the + # only way to reap the parent PID instead of all PIDs from + # check_process, which may leak SysV IPC objects and prevent restart + # and/or race condition on restart. + rc_pid=$(check_pidfile ${pidfile} ${command}) +} + +export PATH="${zabbix_proxy_paths}" run_rc_command "$1" diff --git a/net-mgmt/zabbix2-server/files/zabbix_server.in b/net-mgmt/zabbix2-server/files/zabbix_server.in index 4e381a6..50cfe3f 100644 --- a/net-mgmt/zabbix2-server/files/zabbix_server.in +++ b/net-mgmt/zabbix2-server/files/zabbix_server.in @@ -9,6 +9,10 @@ # # zabbix_server_enable (bool): Set to NO by default. Set it to YES to # enable zabbix_server. +# zabbix_server_paths (string): Set to standard path by default. Set a search +# if you have custom externals that need binaries elsewhere. +# zabbix_server_config (string): Set to the standard config file path by +# default. # . /etc/rc.subr @@ -16,11 +20,33 @@ name="zabbix_server" rcvar=zabbix_server_enable -command="%%PREFIX%%/sbin/${name}" -required_files="%%ETCDIR%%/${name}.conf" - load_rc_config $name : ${zabbix_server_enable="NO"} +: ${zabbix_server_paths=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin} +: ${zabbix_server_config="%%ETCDIR%%/${name}.conf"} + +command="%%PREFIX%%/sbin/${name}" +required_files="${zabbix_server_config}" +start_precmd="find_pidfile" +status_precmd="find_pidfile" +stop_precmd="find_pidfile" + +find_pidfile() +{ + if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then + pidfile="$_pidfile_from_conf" + else + pidfile="/tmp/${name}.pid" + fi + + # This shouldn't be necessary with pidfile, but empirically it was the + # only way to reap the parent PID instead of all PIDs from + # check_process, which may leak SysV IPC objects and prevent restart + # and/or race condition on restart. + rc_pid=$(check_pidfile ${pidfile} ${command}) +} + +export PATH="${zabbix_server_paths}" run_rc_command "$1" diff --git a/net-mgmt/zabbix22-server/files/zabbix_agentd.in b/net-mgmt/zabbix22-server/files/zabbix_agentd.in index 4af7fa7..ddff711 100644 --- a/net-mgmt/zabbix22-server/files/zabbix_agentd.in +++ b/net-mgmt/zabbix22-server/files/zabbix_agentd.in @@ -9,6 +9,10 @@ # # zabbix_agentd_enable (bool): Set to NO by default. Set it to YES to # enable zabbix_agentd. +# zabbix_agentd_paths (string): Set to standard path by default. Set a search +# if you have custom userparams that need binaries elsewhere. +# zabbix_agentd_config (string): Set to the standard config file path by +# default. # . /etc/rc.subr @@ -16,11 +20,33 @@ name="zabbix_agentd" rcvar=zabbix_agentd_enable -command="%%PREFIX%%/sbin/${name}" -required_files="%%ETCDIR%%/${name}.conf" - load_rc_config $name : ${zabbix_agentd_enable="NO"} +: ${zabbix_agentd_paths=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin} +: ${zabbix_agentd_config="%%ETCDIR%%/${name}.conf"} + +command="%%PREFIX%%/sbin/${name}" +required_files="${zabbix_agentd_config}" +start_precmd="find_pidfile" +status_precmd="find_pidfile" +stop_precmd="find_pidfile" + +find_pidfile() +{ + if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then + pidfile="$_pidfile_from_conf" + else + pidfile="/tmp/${name}.pid" + fi + + # This shouldn't be necessary with pidfile, but empirically it was the + # only way to reap the parent PID instead of all PIDs from + # check_process, which may leak SysV IPC objects and prevent restart + # and/or race condition on restart. + rc_pid=$(check_pidfile ${pidfile} ${command}) +} + +export PATH="${zabbix_agentd_paths}" run_rc_command "$1" diff --git a/net-mgmt/zabbix22-server/files/zabbix_proxy.in b/net-mgmt/zabbix22-server/files/zabbix_proxy.in index 2d4024f..324e7ce 100644 --- a/net-mgmt/zabbix22-server/files/zabbix_proxy.in +++ b/net-mgmt/zabbix22-server/files/zabbix_proxy.in @@ -11,6 +11,10 @@ # # zabbix_proxy_enable (bool): Set to NO by default. Set it to YES to # enable zabbix_proxy. +# zabbix_proxy_paths (string): Set to standard path by default. Set a search +# if you have custom externals that need binaries elsewhere. +# zabbix_proxy_config (string): Set to the standard config file path by +# default. # . /etc/rc.subr @@ -18,11 +22,33 @@ name="zabbix_proxy" rcvar=zabbix_proxy_enable -command="%%PREFIX%%/sbin/${name}" -required_files="%%ETCDIR%%/${name}.conf" - load_rc_config $name : ${zabbix_proxy_enable="NO"} +: ${zabbix_proxy_paths=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin} +: ${zabbix_proxy_config="%%ETCDIR%%/${name}.conf"} + +command="%%PREFIX%%/sbin/${name}" +required_files="${zabbix_proxy_config}" +start_precmd="find_pidfile" +status_precmd="find_pidfile" +stop_precmd="find_pidfile" + +find_pidfile() +{ + if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then + pidfile="$_pidfile_from_conf" + else + pidfile="/tmp/${name}.pid" + fi + + # This shouldn't be necessary with pidfile, but empirically it was the + # only way to reap the parent PID instead of all PIDs from + # check_process, which may leak SysV IPC objects and prevent restart + # and/or race condition on restart. + rc_pid=$(check_pidfile ${pidfile} ${command}) +} + +export PATH="${zabbix_proxy_paths}" run_rc_command "$1" diff --git a/net-mgmt/zabbix22-server/files/zabbix_server.in b/net-mgmt/zabbix22-server/files/zabbix_server.in index 2ecccd0..18908e7 100644 --- a/net-mgmt/zabbix22-server/files/zabbix_server.in +++ b/net-mgmt/zabbix22-server/files/zabbix_server.in @@ -11,6 +11,10 @@ # # zabbix_server_enable (bool): Set to NO by default. Set it to YES to # enable zabbix_server. +# zabbix_server_paths (string): Set to standard path by default. Set a search +# if you have custom externals that need binaries elsewhere. +# zabbix_server_config (string): Set to the standard config file path by +# default. # . /etc/rc.subr @@ -18,11 +22,33 @@ name="zabbix_server" rcvar=zabbix_server_enable -command="%%PREFIX%%/sbin/${name}" -required_files="%%ETCDIR%%/${name}.conf" - load_rc_config $name : ${zabbix_server_enable="NO"} +: ${zabbix_server_paths=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin} +: ${zabbix_server_config="%%ETCDIR%%/${name}.conf"} + +command="%%PREFIX%%/sbin/${name}" +required_files="${zabbix_server_config}" +start_precmd="find_pidfile" +status_precmd="find_pidfile" +stop_precmd="find_pidfile" + +find_pidfile() +{ + if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then + pidfile="$_pidfile_from_conf" + else + pidfile="/tmp/${name}.pid" + fi + + # This shouldn't be necessary with pidfile, but empirically it was the + # only way to reap the parent PID instead of all PIDs from + # check_process, which may leak SysV IPC objects and prevent restart + # and/or race condition on restart. + rc_pid=$(check_pidfile ${pidfile} ${command}) +} + +export PATH="${zabbix_server_paths}" run_rc_command "$1" diff --git a/net-mgmt/zabbix24-server/files/zabbix_agentd.in b/net-mgmt/zabbix24-server/files/zabbix_agentd.in index 4af7fa7..ddff711 100644 --- a/net-mgmt/zabbix24-server/files/zabbix_agentd.in +++ b/net-mgmt/zabbix24-server/files/zabbix_agentd.in @@ -9,6 +9,10 @@ # # zabbix_agentd_enable (bool): Set to NO by default. Set it to YES to # enable zabbix_agentd. +# zabbix_agentd_paths (string): Set to standard path by default. Set a search +# if you have custom userparams that need binaries elsewhere. +# zabbix_agentd_config (string): Set to the standard config file path by +# default. # . /etc/rc.subr @@ -16,11 +20,33 @@ name="zabbix_agentd" rcvar=zabbix_agentd_enable -command="%%PREFIX%%/sbin/${name}" -required_files="%%ETCDIR%%/${name}.conf" - load_rc_config $name : ${zabbix_agentd_enable="NO"} +: ${zabbix_agentd_paths=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin} +: ${zabbix_agentd_config="%%ETCDIR%%/${name}.conf"} + +command="%%PREFIX%%/sbin/${name}" +required_files="${zabbix_agentd_config}" +start_precmd="find_pidfile" +status_precmd="find_pidfile" +stop_precmd="find_pidfile" + +find_pidfile() +{ + if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then + pidfile="$_pidfile_from_conf" + else + pidfile="/tmp/${name}.pid" + fi + + # This shouldn't be necessary with pidfile, but empirically it was the + # only way to reap the parent PID instead of all PIDs from + # check_process, which may leak SysV IPC objects and prevent restart + # and/or race condition on restart. + rc_pid=$(check_pidfile ${pidfile} ${command}) +} + +export PATH="${zabbix_agentd_paths}" run_rc_command "$1" diff --git a/net-mgmt/zabbix24-server/files/zabbix_proxy.in b/net-mgmt/zabbix24-server/files/zabbix_proxy.in index 2d4024f..324e7ce 100644 --- a/net-mgmt/zabbix24-server/files/zabbix_proxy.in +++ b/net-mgmt/zabbix24-server/files/zabbix_proxy.in @@ -11,6 +11,10 @@ # # zabbix_proxy_enable (bool): Set to NO by default. Set it to YES to # enable zabbix_proxy. +# zabbix_proxy_paths (string): Set to standard path by default. Set a search +# if you have custom externals that need binaries elsewhere. +# zabbix_proxy_config (string): Set to the standard config file path by +# default. # . /etc/rc.subr @@ -18,11 +22,33 @@ name="zabbix_proxy" rcvar=zabbix_proxy_enable -command="%%PREFIX%%/sbin/${name}" -required_files="%%ETCDIR%%/${name}.conf" - load_rc_config $name : ${zabbix_proxy_enable="NO"} +: ${zabbix_proxy_paths=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin} +: ${zabbix_proxy_config="%%ETCDIR%%/${name}.conf"} + +command="%%PREFIX%%/sbin/${name}" +required_files="${zabbix_proxy_config}" +start_precmd="find_pidfile" +status_precmd="find_pidfile" +stop_precmd="find_pidfile" + +find_pidfile() +{ + if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then + pidfile="$_pidfile_from_conf" + else + pidfile="/tmp/${name}.pid" + fi + + # This shouldn't be necessary with pidfile, but empirically it was the + # only way to reap the parent PID instead of all PIDs from + # check_process, which may leak SysV IPC objects and prevent restart + # and/or race condition on restart. + rc_pid=$(check_pidfile ${pidfile} ${command}) +} + +export PATH="${zabbix_proxy_paths}" run_rc_command "$1" diff --git a/net-mgmt/zabbix24-server/files/zabbix_server.in b/net-mgmt/zabbix24-server/files/zabbix_server.in index 2ecccd0..18908e7 100644 --- a/net-mgmt/zabbix24-server/files/zabbix_server.in +++ b/net-mgmt/zabbix24-server/files/zabbix_server.in @@ -11,6 +11,10 @@ # # zabbix_server_enable (bool): Set to NO by default. Set it to YES to # enable zabbix_server. +# zabbix_server_paths (string): Set to standard path by default. Set a search +# if you have custom externals that need binaries elsewhere. +# zabbix_server_config (string): Set to the standard config file path by +# default. # . /etc/rc.subr @@ -18,11 +22,33 @@ name="zabbix_server" rcvar=zabbix_server_enable -command="%%PREFIX%%/sbin/${name}" -required_files="%%ETCDIR%%/${name}.conf" - load_rc_config $name : ${zabbix_server_enable="NO"} +: ${zabbix_server_paths=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin} +: ${zabbix_server_config="%%ETCDIR%%/${name}.conf"} + +command="%%PREFIX%%/sbin/${name}" +required_files="${zabbix_server_config}" +start_precmd="find_pidfile" +status_precmd="find_pidfile" +stop_precmd="find_pidfile" + +find_pidfile() +{ + if get_pidfile_from_conf PidFile ${zabbix_agentd_config}; then + pidfile="$_pidfile_from_conf" + else + pidfile="/tmp/${name}.pid" + fi + + # This shouldn't be necessary with pidfile, but empirically it was the + # only way to reap the parent PID instead of all PIDs from + # check_process, which may leak SysV IPC objects and prevent restart + # and/or race condition on restart. + rc_pid=$(check_pidfile ${pidfile} ${command}) +} + +export PATH="${zabbix_server_paths}" run_rc_command "$1"