#! /bin/sh # # Copyright (c) Linux Test Project, 2010 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ################################################################## readonly MAILLOG=/var/log/maillog # Signals to trap. readonly TRAP_SIGS="1 2 3 6 11 15" # configuration file for syslog or syslog-ng CONFIG_FILE="" # rsyslogd .conf specific args. RSYSLOG_CONFIG= # number of seconds to wait for another syslog test to complete WAIT_COUNT=60 cleanup() { # Reentrant cleanup -> bad. Especially since rsyslogd on Fedora 13 # seems to get stuck FOREVER when not running as root. Lame... disable_traps exit_code=$1 # Restore the previous syslog daemon state. if [ -f "$CONFIG_FILE.ltpback" ]; then if mv "$CONFIG_FILE.ltpback" "$CONFIG_FILE"; then # Make sure that restart_syslog_daemon doesn't loop # back to cleanup again. restart_syslog_daemon "return 1" # Maintain any nonzero exit codes if [ $exit_code -ne $? ]; then exit_code=1 fi else exit_code=1 fi fi exit $exit_code } setup() { tst_require_root trap ' disable_traps tst_resm TBROK "Testing is terminating due to a signal" cleanup 1' $TRAP_SIGS || exit 1 if [ "$SYSLOG_DAEMON" = "syslog" ]; then CONFIG_FILE="/etc/syslog.conf" elif [ "$SYSLOG_DAEMON" = "syslog-ng" ]; then CONFIG_FILE="/etc/syslog-ng/syslog-ng.conf" elif [ "$SYSLOG_DAEMON" = "rsyslog" ]; then CONFIG_FILE="/etc/rsyslog.conf" if grep -q -r '^\$ModLoad[[:space:]]*imjournal' /etc/rsyslog.conf /etc/rsyslog.d/ ; then systemd_journal=$(grep -Ehoi "^[^#].*(imjournal|workdirectory).*" -r /etc/rsyslog.conf /etc/rsyslog.d/) RSYSLOG_CONFIG=$(cat <