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 (at] us.ibm.com> 20 # 02/05/03 Modified - Manoj Iyer <manjo (at] mail.utexas.edu> use USCTEST macros 21 # fixed bugs. 22 # 07/27/05 Michael Reed <mreedltp (at] vnet.ibm.com> 23 # Made changes to account for the replacement of syslogd 24 # with syslog-ng 25 # 26 ################################################################## 27 # case5: Test the logging option: LOG_CONS # 28 # o Do openlog() with LOG_CONS option. # 29 # o Disable /dev/syslog by moving it to a temporary file # 30 # name. # 31 # o Send the syslog message. # 32 # o Check whether this is written to the console i.e to # 33 # the file /usr/adm/ktlog/<this year>/<this month>/ # 34 # <to_day> # 35 ################################################################## 36 37 . syslog-lib.sh || exit 1 38 39 syslog_case5() 40 { 41 tst_resm TINFO "syslog: Testing the log option: LOG_CONS..." 42 43 # Create the configuration file specific to this test case. 44 45 case "$CONFIG_FILE" in 46 /etc/syslog.conf|/etc/rsyslog.conf) 47 echo "$RSYSLOG_CONFIG" > $CONFIG_FILE 48 echo "user.info /var/log/messages" >> $CONFIG_FILE 49 ;; 50 51 /etc/syslog-ng/syslog-ng.conf) 52 echo "source src{ internal(); unix-dgram(\"/dev/log\"); udp(ip(\"0.0.0.0\") port(514)); };" > $CONFIG_FILE 53 echo "filter f_syslog_user { level(info) and facility(user); };" >> $CONFIG_FILE 54 echo "destination syslog-messages { file(\"/var/log/messages\");};" >> $CONFIG_FILE 55 echo "log { source(src); filter(f_syslog_user); destination(syslog-messages);};" >> $CONFIG_FILE 56 ;; 57 esac 58 59 restart_syslog_daemon 60 61 # check if /var/log/messages script exists 62 if [ -e /var/log/messages ]; then 63 oldvalue=`grep -c "syslogtst: info to console test." /var/log/messages` 64 else 65 oldvalue=0 66 fi 67 68 # syslogtst does the disabling of /dev/syslog, sends the message and 69 # enables /dev/syslog. 70 if ! syslogtst 5 2>/dev/null; then 71 cleanup 1 72 fi 73 sleep 2 74 75 # check if /var/log/messages script exists 76 if [ ! -e /var/log/messages ]; then 77 tst_resm TBROK "/var/log/messages no such log file" 78 cleanup 1 79 fi 80 newvalue=`grep -c "syslogtst: info to console test." /var/log/messages` 81 82 if [ "x$(( $newvalue - $oldvalue ))" != "x1" ]; then 83 status_flag=1 84 fi 85 } 86 87 tst_resm TINFO " case5: Test the logging option: LOG_CONS" 88 tst_resm TINFO " o Do openlog() with LOG_CONS option." 89 tst_resm TINFO " o Disable /dev/syslog by moving it to a temporary file name." 90 tst_resm TINFO " o Send the syslog message." 91 tst_resm TINFO " o Check whether this is written to the console i.e to" 92 tst_resm TINFO " the file /usr/adm/ktlog/<this year>/<this month>/<to_day>" 93 94 setup 95 syslog_case5 96 cleanup ${status_flag:=0} 97