• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2
3#  Copyright (c) International Business Machines  Corp., 2002
4#
5#  This program is free software;  you can redistribute it and/or modify
6#  it under the terms of the GNU General Public License as published by
7#  the Free Software Foundation; either version 2 of the License, or
8#  (at your option) any later version.
9#
10#  This program is distributed in the hope that it will be useful,
11#  but WITHOUT ANY WARRANTY;  without even the implied warranty of
12#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13#  the GNU General Public License for more details.
14#
15#  You should have received a copy of the GNU General Public License
16#  along with this program;  if not, write to the Free Software
17#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19# 12/05/02  Port to bash -Robbie Williamson <robbiew@us.ibm.com>
20# 02/05/03  Modified - Manoj Iyer <manjo@mail.utexas.edu> use USCTEST macros
21#			fixed bugs.
22# 07/27/05  Michael Reed  <mreedltp@vnet.ibm.com>
23#		Made changes to account for the replacement of syslogd
24#		with syslog-ng on SLES
25#
26##################################################################
27# case 3: Do openlog(), log the messages and see whether			#
28# ident string is prepended to the message.			 #
29#								 #
30# syslog.conf should contain:					 #
31# *.crit		/usr/adm/critical			 #
32# daemon.info		/usr/spool/adm/syslog			 #
33##################################################################
34
35. syslog-lib.sh || exit 1
36
37syslog_case3()
38{
39	# Create the configuration file specific to this test case.
40	case "$CONFIG_FILE" in
41	/etc/syslog.conf|/etc/rsyslog.conf)
42		echo "$RSYSLOG_CONFIG" > $CONFIG_FILE
43		echo "daemon.info	/var/log/messages" >> $CONFIG_FILE
44		;;
45
46	/etc/syslog-ng/syslog-ng.conf)
47		echo "source src{ internal(); unix-dgram(\"/dev/log\"); udp(ip(\"0.0.0.0\") port(514)); };" > $CONFIG_FILE
48		echo " " >> $CONFIG_FILE
49		echo "# Added for syslog testcase"  >> $CONFIG_FILE
50		echo "filter f_syslog_daemon { level(info) and facility(daemon); }; " >> $CONFIG_FILE
51		echo "destination syslog-messages { file(\"/var/log/messages\");};" >> $CONFIG_FILE
52		echo "log { source(src); filter(f_syslog_daemon); destination(syslog-messages);};"  >> $CONFIG_FILE
53		;;
54	esac
55
56	restart_syslog_daemon
57
58	# Grep for the ident prefix: SYSLOG_CASE3 in the log file.
59	if [ -e /var/log/messages ]; then
60		oldvalue4=`grep -c "SYSLOG_CASE3" /var/log/messages`
61	else
62		oldvalue4=0
63	fi
64
65	if ! syslogtst 3 2>/dev/null; then
66		cleanup 1
67	fi
68	sleep 2
69
70	# check if /var/log/messages exists
71	if [ ! -e /var/log/messages ]; then
72		tst_resm TBROK "/var/log/messages no such log file"
73		cleanup 1
74	fi
75
76	newvalue4=`grep -c "SYSLOG_CASE3" /var/log/messages`
77	if [ "x$(( $newvalue4 - $oldvalue4 ))" != x1 ]; then
78		status_flag=1
79	fi
80}
81
82tst_resm TINFO "Do openlog(), log the messages and see whether"
83tst_resm TINFO "ident string is prepended to the message."
84
85setup
86syslog_case3
87cleanup ${status_flag:=0}
88