aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Osipov <michaelo@FreeBSD.org>2023-11-24 09:26:41 +0000
committerMichael Osipov <michaelo@FreeBSD.org>2023-12-31 10:22:19 +0000
commit15e35d058cff847d1a7bc671fcf48b99f5d2f73b (patch)
tree181a93ca8b75a25b5449aa178d8bea80f3198037
parent3aa71ea7c231a4e60a7e1b9b677e379e17432fc8 (diff)
downloadsrc-15e35d058cff847d1a7bc671fcf48b99f5d2f73b.tar.gz
src-15e35d058cff847d1a7bc671fcf48b99f5d2f73b.zip
periodic: Make daily diff(1) flags configurable with daily_diff_flags
PR: 270266 Approved by: jrm (mentor), karels MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D42900
-rw-r--r--share/man/man5/periodic.conf.55
-rwxr-xr-xusr.sbin/periodic/etc/daily/200.backup-passwd4
-rwxr-xr-xusr.sbin/periodic/etc/daily/210.backup-aliases2
-rwxr-xr-xusr.sbin/periodic/etc/daily/221.backup-gpart2
-rwxr-xr-xusr.sbin/periodic/etc/daily/222.backup-gmirror2
-rwxr-xr-xusr.sbin/periodic/etc/daily/223.backup-zfs2
-rw-r--r--usr.sbin/periodic/periodic.conf1
7 files changed, 12 insertions, 6 deletions
diff --git a/share/man/man5/periodic.conf.5 b/share/man/man5/periodic.conf.5
index f434069bc96e..da1eb355d7db 100644
--- a/share/man/man5/periodic.conf.5
+++ b/share/man/man5/periodic.conf.5
@@ -639,6 +639,11 @@ but specific to the pool
Set to a list of extra scripts that should be run after all other
daily scripts.
All scripts must be absolute path names.
+.It Va daily_diff_flags
+.Pq Vt str
+Set to the arguments to pass to the
+.Xr diff 1
+utility when generating differences.
.El
.Pp
The following variables are used by the standard scripts that reside in
diff --git a/usr.sbin/periodic/etc/daily/200.backup-passwd b/usr.sbin/periodic/etc/daily/200.backup-passwd
index 44da5993a3a6..e165e7f0f0ed 100755
--- a/usr.sbin/periodic/etc/daily/200.backup-passwd
+++ b/usr.sbin/periodic/etc/daily/200.backup-passwd
@@ -40,7 +40,7 @@ case "$daily_backup_passwd_enable" in
then
[ $rc -lt 1 ] && rc=1
echo "$host passwd diffs:"
- diff -uI '^#' $bak/master.passwd.bak /etc/master.passwd |\
+ diff ${daily_diff_flags:--u} -I '^#' $bak/master.passwd.bak /etc/master.passwd |\
sed 's/^\([-+ ][^:]*\):[^:]*:/\1:(password):/'
mv $bak/master.passwd.bak $bak/master.passwd.bak2
cp -p /etc/master.passwd $bak/master.passwd.bak || rc=3
@@ -57,7 +57,7 @@ case "$daily_backup_passwd_enable" in
then
[ $rc -lt 1 ] && rc=1
echo "$host group diffs:"
- diff -u $bak/group.bak /etc/group
+ diff ${daily_diff_flags:--u} $bak/group.bak /etc/group
mv $bak/group.bak $bak/group.bak2
cp -p /etc/group $bak/group.bak || rc=3
fi
diff --git a/usr.sbin/periodic/etc/daily/210.backup-aliases b/usr.sbin/periodic/etc/daily/210.backup-aliases
index 3b689e3eaa1b..25e2bd021a84 100755
--- a/usr.sbin/periodic/etc/daily/210.backup-aliases
+++ b/usr.sbin/periodic/etc/daily/210.backup-aliases
@@ -34,7 +34,7 @@ case "$daily_backup_aliases_enable" in
then
[ $rc -lt 1 ] && rc=1
echo "$host aliases diffs:"
- diff -u $bak/aliases.bak /etc/mail/aliases
+ diff ${daily_diff_flags:--u} $bak/aliases.bak /etc/mail/aliases
mv $bak/aliases.bak $bak/aliases.bak2
cp -p /etc/mail/aliases $bak/aliases.bak || rc=3
fi
diff --git a/usr.sbin/periodic/etc/daily/221.backup-gpart b/usr.sbin/periodic/etc/daily/221.backup-gpart
index da59a6d5d724..50096e38f118 100755
--- a/usr.sbin/periodic/etc/daily/221.backup-gpart
+++ b/usr.sbin/periodic/etc/daily/221.backup-gpart
@@ -27,7 +27,7 @@ rotate() {
rm "${file}.tmp"
else
rc=1
- [ -n "$show_diff" ] && diff "${file}.bak" "${file}.tmp"
+ [ -n "$show_diff" ] && diff ${daily_diff_flags} "${file}.bak" "${file}.tmp"
mv "${file}.bak" "${file}.bak2" || rc=3
mv "${file}.tmp" "${file}.bak" || rc=3
fi
diff --git a/usr.sbin/periodic/etc/daily/222.backup-gmirror b/usr.sbin/periodic/etc/daily/222.backup-gmirror
index 866a00497759..45c656dc4f41 100755
--- a/usr.sbin/periodic/etc/daily/222.backup-gmirror
+++ b/usr.sbin/periodic/etc/daily/222.backup-gmirror
@@ -25,7 +25,7 @@ rotate() {
rm "${file}.tmp"
else
rc=1
- [ -n "$show_diff" ] && diff "${file}.bak" "${file}.tmp"
+ [ -n "$show_diff" ] && diff ${daily_diff_flags} "${file}.bak" "${file}.tmp"
mv "${file}.bak" "${file}.bak2" || rc=3
mv "${file}.tmp" "${file}.bak" || rc=3
fi
diff --git a/usr.sbin/periodic/etc/daily/223.backup-zfs b/usr.sbin/periodic/etc/daily/223.backup-zfs
index 03876df53f13..a49bbb2eaa04 100755
--- a/usr.sbin/periodic/etc/daily/223.backup-zfs
+++ b/usr.sbin/periodic/etc/daily/223.backup-zfs
@@ -25,7 +25,7 @@ rotate() {
rm "${file}.tmp"
else
rc=1
- [ -n "$show_diff" ] && diff "${file}.bak" "${file}.tmp"
+ [ -n "$show_diff" ] && diff ${daily_diff_flags} "${file}.bak" "${file}.tmp"
mv "${file}.bak" "${file}.bak2" || rc=3
mv "${file}.tmp" "${file}.bak" || rc=3
fi
diff --git a/usr.sbin/periodic/periodic.conf b/usr.sbin/periodic/periodic.conf
index 0c35d33b63aa..0a8f7961c2f9 100644
--- a/usr.sbin/periodic/periodic.conf
+++ b/usr.sbin/periodic/periodic.conf
@@ -31,6 +31,7 @@ anticongestion_sleeptime=3600
# that output. $daily_output might be set to /var/log/daily.log if you
# wish to log the daily output and have the files rotated by newsyslog(8)
#
+daily_diff_flags="" # flags for diff output
daily_output="root" # user or /file
daily_show_success="YES" # scripts returning 0
daily_show_info="YES" # scripts returning 1