aboutsummaryrefslogtreecommitdiffstats
path: root/del-syslog
diff options
context:
space:
mode:
authorHerton Ronaldo Krzesinski <herton@mandriva.com.br>2005-08-19 19:06:06 +0000
committerHerton Ronaldo Krzesinski <herton@mandriva.com.br>2005-08-19 19:06:06 +0000
commit96169347eca3efb7b4770d9790449405a8c1432c (patch)
tree3ef782f34142c78c89e4cb4e1ce3c53ef19caae7 /del-syslog
parent417615d96d52b8e011d5efbdff69f7216a53e194 (diff)
downloadrpm-helper-96169347eca3efb7b4770d9790449405a8c1432c.tar
rpm-helper-96169347eca3efb7b4770d9790449405a8c1432c.tar.gz
rpm-helper-96169347eca3efb7b4770d9790449405a8c1432c.tar.bz2
rpm-helper-96169347eca3efb7b4770d9790449405a8c1432c.tar.xz
rpm-helper-96169347eca3efb7b4770d9790449405a8c1432c.zip
- Fix bug when handling log entries comprised of all levels at syslog-ng
configuration file. - Correctly handle '*' character inside names of configuration tokes, not make it be interpreted like a shell wildcard or sed regular expression. - Fix bug when get source name inside add-syslog, in the case there isn't a different source, instead the default source /dev/log is used (the case where $source variable is empty).
Diffstat (limited to 'del-syslog')
-rwxr-xr-xdel-syslog44
1 files changed, 29 insertions, 15 deletions
diff --git a/del-syslog b/del-syslog
index 441a8f2..79d2fff 100755
--- a/del-syslog
+++ b/del-syslog
@@ -66,9 +66,14 @@ EOF
}
+# Below there are replacements on the form:
+# `echo "$1" | sed "s/\\\*/\\\\\*/g"`
+# They escape '*' because they are used inside the sed scripts and must not be
+# interpreted as a regular expression/wildcard, as part of literal names.
+
delete_destination() {
-local name=$1
+local name=`echo "$1" | sed "s/\\\*/\\\\\*/g"`
local file=$2
_del_destination_sed $name $file | sed -i -f - /etc/syslog-ng.conf
@@ -93,9 +98,9 @@ EOF
delete_filter() {
-local name=$1
+local name=`echo "$1" | sed "s/\\\*/\\\\\*/g"`
local facility=$2
-local level=$3
+local level=`echo "$3" | sed "s/\\\*/\\\\\*/g"`
_del_filter_sed $name $facility $level | sed -i -f - /etc/syslog-ng.conf
}
@@ -122,8 +127,8 @@ EOF
delete_log() {
local source=$1
-local filter=$2
-local destination=$3
+local filter=`echo "$2" | sed "s/\\\*/\\\\\*/g"`
+local destination=`echo "$3" | sed "s/\\\*/\\\\\*/g"`
_del_log_sed $source $filter $destination | sed -i -f - /etc/syslog-ng.conf
}
@@ -150,7 +155,7 @@ fi
if [ -z "$level_begin" -a -n "$level_end" ]; then
level_begin=`echo $priority_order | cut -d " " -f 1`
elif [ -n "$level_begin" -a -z "$level_end" ]; then
- level_end=$level_begin
+ level_end="$level_begin"
fi
if [ "$level_begin" = "debug" -a "$level_end" = "*" -o "$level_begin" = "*" -a "$level_end" = "emerg" ]; then
level_begin="*"
@@ -174,14 +179,14 @@ if [ -f /etc/syslog.conf ]; then
/etc/sysconfig/syslog
fi
if [ -n "$facility" -a -n "$level_begin" -a -n "$logfile" ]; then
- lvl_begin=$level_begin
- lvl_end=$level_end
+ lvl_begin="$level_begin"
+ lvl_end="$level_end"
if [ "$level_begin" = "*" -a "$level_end" = "*" -o \
"$level_begin" = "debug" -a "$level_end" = "emerge" -o "$level_end" = "panic" ]; then
lnum=`grep -n "$logfile" /etc/syslog.conf | sed "s/#.*$//g" | grep "$facility\.\*" | cut -d ":" -f 1`;
[ -n "$lnum" ] && sed -i "${lnum}d;" /etc/syslog.conf || :
- lvl_begin=debug
- lvl_end=emerg
+ lvl_begin="debug"
+ lvl_end="emerg"
fi
levels=`echo $priority_order | sed -n "s:\([^[:space:]]*$lvl_begin.*\):\1:p"`
levels=`echo $levels | sed -n "s:\(.*$lvl_end[^[:space:]]*\):\1:p"`
@@ -218,21 +223,21 @@ if [ -f /etc/syslog-ng.conf ]; then
for level in $priority_order; do
if [ -n "$level_begin" ]; then
- if echo $level | grep -q $level_begin; then
+ if echo $level | grep -q "$level_begin"; then
lvl=`echo $level | sed "s:,: :"`
c=0
for depr in $lvl; do
- lvl_start[$c]=$depr
+ lvl_start[$c]="$depr"
let c=c+1
done
fi
fi
if [ -n "$level_end" ]; then
- if echo $level | grep -q $level_end; then
+ if echo $level | grep -q "$level_end"; then
lvl=`echo $level | sed "s:,: :"`
c=0
for depr in $lvl; do
- lvl_end[$c]=$depr
+ lvl_end[$c]="$depr"
let c=c+1
done
fi
@@ -241,7 +246,16 @@ if [ -f /etc/syslog-ng.conf ]; then
# We must test all possibilities for the given range, as also
# test for deprecated name levels.
- if [ "${lvl_start[0]}" = "${lvl_end[0]}" -o "${lvl_start[0]}" = "${lvl_end[1]}" ]; then
+ if [ "$level_begin" = "*" -a "$level_end" = "*" -o \
+ "$level_begin" = "debug" -a "$level_end" = "emerg" -o "$level_end" = "panic" ]; then
+ lvl_range[0]="*"
+ lvl_range[1]="debug..emerg"
+ lvl_range[2]="debug..panic"
+ lvl_label[0]="*"
+ lvl_label[1]="*_*"
+ lvl_label[2]="debug_emerg"
+ lvl_label[3]="debug_panic"
+ elif [ "${lvl_start[0]}" = "${lvl_end[0]}" -o "${lvl_start[0]}" = "${lvl_end[1]}" ]; then
lvl_range[0]="${lvl_start[0]}"
lvl_range[1]="${lvl_end[0]}"
lvl_label[0]="${lvl_start[0]}"