/usr/sbin
NameSizeModeActions
accessdb157920755editdlrm
addgnupghome30790755editdlrm
addpart155200755editdlrm
adduser1411440755editdlrm
agetty580720755editdlrm
alternatives405440755editdlrm
anacron404640755editdlrm
apachectl48080755editdlrm
applygnupgdefaults22210755editdlrm
arp647280755editdlrm
arping279040755editdlrm
arptables2369600755editdlrm
arptables-nft2369600755editdlrm
arptables-nft-restore2369600755editdlrm
arptables-nft-save2369600755editdlrm
arptables-restore2369600755editdlrm
arptables-save2369600755editdlrm
atd320080755editdlrm
atrun700755editdlrm
auditctl528240755editdlrm
auditd1403360755editdlrm
augenrules41460755editdlrm
aureport1231920755editdlrm
ausearch1231600755editdlrm
autrace196320750editdlrm
avcstat157200755editdlrm
badblocks362000755editdlrm
blkdeactivate163550555editdlrm
blkdiscard237600755editdlrm
blkid528480755editdlrm
blkmapd403600755editdlrm
blkzone363040755editdlrm
blockdev321680755editdlrm
bridge1340880755editdlrm
cache_check30462960755editdlrm
cache_dump30462960755editdlrm
cache_metadata_size30462960755editdlrm
cache_repair30462960755editdlrm
cache_restore30462960755editdlrm
cache_writeback30462960755editdlrm
capsh319600755editdlrm
cfdisk986560755editdlrm
chcpu321760755editdlrm
chgpasswd612000755editdlrm
chkconfig448320755editdlrm
chpasswd569680755editdlrm
chronyd3825440755editdlrm
chroot405040755editdlrm
clock612000755editdlrm
consoletype156480755editdlrm
convertquota706640755editdlrm
cracklib-check154720755editdlrm
cracklib-format2550755editdlrm
cracklib-packer154720755editdlrm
cracklib-unpacker154640755editdlrm
create-cracklib-dict9940755editdlrm
crond779920755editdlrm
ctrlaltdel155520755editdlrm
ctstat241600755editdlrm
dcb969600755editdlrm
ddns-confgen279120755editdlrm
debugfs2386240755editdlrm
delpart154800755editdlrm
depmod1695440755editdlrm
devlink1698160755editdlrm
dmeventd530320555editdlrm
dmfilemapd238560555editdlrm
dmsetup1605360555editdlrm
dmstats1605360555editdlrm
dnssec-cds488160755editdlrm
dnssec-checkds9240755editdlrm
dnssec-coverage9260755editdlrm
dnssec-dsfromkey403840755editdlrm
dnssec-importkey362880755editdlrm
dnssec-keyfromlabel403680755editdlrm
dnssec-keygen485840755editdlrm
dnssec-keymgr9220755editdlrm
dnssec-revoke321680755editdlrm
dnssec-settime485760755editdlrm
dnssec-signzone981840755editdlrm
dnssec-verify322000755editdlrm
dosfsck865920755editdlrm
dosfslabel409760755editdlrm
dovecot1474800755editdlrm
dovecot_cpshutdown33440755editdlrm
dpll493120755editdlrm
dumpe2fs320400755editdlrm
e2freefrag155520755editdlrm
e2fsck3646320755editdlrm
e2image444560755editdlrm
e2label1069680755editdlrm
e2mmpstatus320400755editdlrm
e2undo237120755editdlrm
e4crypt320480755editdlrm
e4defrag320080755editdlrm
ebtables2369600755editdlrm
ebtables-nft2369600755editdlrm
ebtables-nft-restore2369600755editdlrm
ebtables-nft-save2369600755editdlrm
ebtables-restore2369600755editdlrm
ebtables-save2369600755editdlrm
ebtables-translate2369600755editdlrm
edquota916480755editdlrm
efibootdump244400755editdlrm
efibootmgr462640755editdlrm
era_check30462960755editdlrm
era_dump30462960755editdlrm
era_invalidate30462960755editdlrm
era_restore30462960755editdlrm
ether-wake514480755editdlrm
ethtool10126960755editdlrm
exicyclog113650755editdlrm
exigrep117100755editdlrm
exim17288484755editdlrm
eximstats1525460755editdlrm
exim_checkaccess49430755editdlrm
exim_dbmbuild230400755editdlrm
exim_dumpdb418720755editdlrm
exim_fixdb463600755editdlrm
exim_lock233280755editdlrm
exim_tidydb334720755editdlrm
exinext82170755editdlrm
exiqgrep67390755editdlrm
exiqsumm64430755editdlrm
exiwhat45240755editdlrm
exportfs701120755editdlrm
faillock237360755editdlrm
fatlabel409760755editdlrm
fcgistarter253040755editdlrm
fdformat237440755editdlrm
fdisk1147600755editdlrm
filefrag196800755editdlrm
findfs155200755editdlrm
firewalld99890755editdlrm
fix-info-dir80370755editdlrm
fixfiles123870755editdlrm
fsadm246020555editdlrm
fsck445920755editdlrm
fsck.cramfs321280755editdlrm
fsck.ext23646320755editdlrm
fsck.ext33646320755editdlrm
fsck.ext43646320755editdlrm
fsck.fat865920755editdlrm
fsck.minix570480755editdlrm
fsck.msdos865920755editdlrm
fsck.vfat865920755editdlrm
fsck.xfs25980755editdlrm
fsfreeze155120755editdlrm
fstrim445440755editdlrm
fuser420720755editdlrm
g13-syshelp907280755editdlrm
genhomedircon328080755editdlrm
genhostid156480755editdlrm
genl1332720755editdlrm
getcap154960755editdlrm
getenforce156400755editdlrm
getpcaps154880755editdlrm
getpidprevcon156560755editdlrm
getpolicyload156480755editdlrm
getsebool156640755editdlrm
groupadd704240755editdlrm
groupdel660800755editdlrm
groupmems571120755editdlrm
groupmod745040755editdlrm
grpck611920755editdlrm
grpconv528000755editdlrm
grpunconv527680755editdlrm
grub2-bios-setup17499040755editdlrm
grub2-get-kernel-settings27460755editdlrm
grub2-install20685200755editdlrm
grub2-macbless17288720755editdlrm
grub2-mkconfig94310755editdlrm
grub2-probe17459840755editdlrm
grub2-reboot48140755editdlrm
grub2-set-bootflag154564755editdlrm
grub2-set-default35380755editdlrm
grub2-set-password28090755editdlrm
grub2-setpassword28090755editdlrm
grub2-switch-to-blscfg90240755editdlrm
grubby2600755editdlrm
gssproxy1278880755editdlrm
halt3055760755editdlrm
htcacheclean540720755editdlrm
httpd11397200755editdlrm
hwclock612000755editdlrm
iconvconfig324320755editdlrm
ifconfig808800755editdlrm
ifdown10970755editdlrm
ifenslave243040755editdlrm
ifstat405520755editdlrm
ifup10660755editdlrm
imunify-notifier103256160755editdlrm
init980400755editdlrm
insmod1695440755editdlrm
install-info1092560755editdlrm
installkernel3230755editdlrm
intel_sdsi229680755editdlrm
ip7929040755editdlrm
ip6tables2369600755editdlrm
ip6tables-nft2369600755editdlrm
ip6tables-nft-restore2369600755editdlrm
ip6tables-nft-save2369600755editdlrm
ip6tables-restore2369600755editdlrm
ip6tables-restore-translate2369600755editdlrm
ip6tables-save2369600755editdlrm
ip6tables-translate2369600755editdlrm
ipmaddr199120755editdlrm
ipset156400755editdlrm
ipset-translate156400755editdlrm
iptables2369600755editdlrm
iptables-nft2369600755editdlrm
iptables-nft-restore2369600755editdlrm
iptables-nft-save2369600755editdlrm
iptables-restore2369600755editdlrm
iptables-restore-translate2369600755editdlrm
iptables-save2369600755editdlrm
iptables-translate2369600755editdlrm
iptunnel199680755editdlrm
irqbalance659920755editdlrm
irqbalance-ui405360755editdlrm
kexec1972160755editdlrm
key.dns_resolver321040755editdlrm
kpartx486640755editdlrm
lchage237200755editdlrm
ldattach278800755editdlrm
ldconfig11764640755editdlrm
lgroupadd154800755editdlrm
lgroupdel154720755editdlrm
lgroupmod236800755editdlrm
lid195920755editdlrm
lnewusers236800755editdlrm
lnstat241600755editdlrm
load_policy154800755editdlrm
logrotate979600755editdlrm
logsave155520755editdlrm
losetup738160755editdlrm
lpasswd236800755editdlrm
lshw8740640755editdlrm
lsmod1695440755editdlrm
lspci999120755editdlrm
luseradd236800755editdlrm
luserdel154800755editdlrm
lusermod236880755editdlrm
lvchange28310720555editdlrm
lvconvert28310720555editdlrm
lvcreate28310720555editdlrm
lvdisplay28310720555editdlrm
lvextend28310720555editdlrm
lvm28310720555editdlrm
lvmconfig28310720555editdlrm
lvmdevices28310720555editdlrm
lvmdiskscan28310720555editdlrm
lvmdump103780555editdlrm
lvmpolld2153440555editdlrm
lvmsadc28310720555editdlrm
lvmsar28310720555editdlrm
lvm_import_vdo237080555editdlrm
lvreduce28310720555editdlrm
lvremove28310720555editdlrm
lvrename28310720555editdlrm
lvresize28310720555editdlrm
lvs28310720555editdlrm
lvscan28310720555editdlrm
makedumpfile4422080755editdlrm
matchpathcon156800755editdlrm
mii-diag247760755editdlrm
mii-tool284480755editdlrm
mkdict2550755editdlrm
mkdosfs537680755editdlrm
mkdumprd124180755editdlrm
mke2fs1357120755editdlrm
mkfs155360755editdlrm
mkfs.cramfs362240755editdlrm
mkfs.ext21357120755editdlrm
mkfs.ext31357120755editdlrm
mkfs.ext41357120755editdlrm
mkfs.fat537680755editdlrm
mkfs.minix446000755editdlrm
mkfs.msdos537680755editdlrm
mkfs.vfat537680755editdlrm
mkfs.xfs4615920755editdlrm
mkhomedir_helper237680755editdlrm
mklost+found154800755editdlrm
mksquashfs2023600755editdlrm
mkswap486400755editdlrm
modinfo1695440755editdlrm
modprobe1695440755editdlrm
modsec-sdbm-util343680750editdlrm
mount.fuse157040755editdlrm
mount.fuse3198320755editdlrm
mount.nfs1029364755editdlrm
mount.nfs41029364755editdlrm
mountstats435190755editdlrm
mysqld566875760755editdlrm
named5581040755editdlrm
named-checkconf403440755editdlrm
named-checkzone402880755editdlrm
named-compilezone402880755editdlrm
named-journalprint154960755editdlrm
named-nzd2nzf154800755editdlrm
nameif159520755editdlrm
NetworkManager38939280755editdlrm
newusers908320755editdlrm
nfsconf408160755editdlrm
nfsdcld572080755editdlrm
nfsdclddb102300755editdlrm
nfsdclnts92710755editdlrm
nfsdcltrack408720755editdlrm
nfsidmap238560755editdlrm
nfsiostat239100755editdlrm
nfsref445600755editdlrm
nfsstat391920755editdlrm
nft278240755editdlrm
nologin155200755editdlrm
nscd1668560755editdlrm
nsec3hash155600755editdlrm
nstat320880755editdlrm
packer154720755editdlrm
pam_console_apply445520755editdlrm
pam_namespace_helper4710755editdlrm
pam_timestamp_check154964755editdlrm
paperconfig41730755editdlrm
parted987040755editdlrm
partprobe157040755editdlrm
partx612000755editdlrm
pdata_tools30462960755editdlrm
pdns_server61628000755editdlrm
pidof238880755editdlrm
ping914720755editdlrm
ping6914720755editdlrm
pivot_root155200755editdlrm
plipconfig157200755editdlrm
poweroff3055760755editdlrm
pure-authd235680755editdlrm
pure-certd234720755editdlrm
pure-config.pl47550755editdlrm
pure-ftpd1813760755editdlrm
pure-ftpwho272160755editdlrm
pure-mrtginfo148960755editdlrm
pure-quotacheck231040755editdlrm
pure-uploadscript233760755editdlrm
pvchange28310720555editdlrm
pvck28310720555editdlrm
pvcreate28310720555editdlrm
pvdisplay28310720555editdlrm
pvmove28310720555editdlrm
pvremove28310720555editdlrm
pvresize28310720555editdlrm
pvs28310720555editdlrm
pvscan28310720555editdlrm
pwck569360755editdlrm
pwconv485840755editdlrm
pwhistory_helper196560755editdlrm
pwunconv485440755editdlrm
quotacheck958640755editdlrm
quotaoff580320755editdlrm
quotaon580320755editdlrm
quotastats157040755editdlrm
rdisc321120755editdlrm
rdma1198720755editdlrm
readprofile238240755editdlrm
reboot3055760755editdlrm
repquota794160755editdlrm
request-key279440755editdlrm
resize2fs692640755editdlrm
resizepart239600755editdlrm
restorecon237440755editdlrm
restorecon_xattr154880755editdlrm
rfkill320960755editdlrm
rmmod1695440755editdlrm
rndc442880755editdlrm
rndc-confgen238160755editdlrm
rotatelogs390480755editdlrm
route673520755editdlrm
rpc.gssd902240755editdlrm
rpc.idmapd488800755editdlrm
rpc.mountd1357360755editdlrm
rpc.nfsd409600755editdlrm
rpc.statd827280755editdlrm
rpcbind613280755editdlrm
rpcctl96450755editdlrm
rpcdebug191040755editdlrm
rpcinfo364320755editdlrm
rsyslogd8262400755editdlrm
rtacct300480755editdlrm
rtcwake361040755editdlrm
rtkitctl156080755editdlrm
rtmon1290800755editdlrm
rtstat241600755editdlrm
runlevel3055760755editdlrm
runq17288484755editdlrm
runuser569440755editdlrm
sasldblistusers2156400755editdlrm
saslpasswd2156080755editdlrm
sefcontext_compile741200755editdlrm
selabel_digest156800755editdlrm
selabel_get_digests_all_partial_matches156960755editdlrm
selabel_lookup156720755editdlrm
selabel_lookup_best_match156800755editdlrm
selabel_partial_match156720755editdlrm
selinuxconlist156720755editdlrm
selinuxdefcon156720755editdlrm
selinuxenabled156400755editdlrm
selinuxexeccon156560755editdlrm
selinux_check_access156800755editdlrm
semanage416140755editdlrm
semodule328080755editdlrm
sendmail185122755editdlrm
service46230755editdlrm
sestatus236800755editdlrm
setcap154880755editdlrm
setenforce156640755editdlrm
setfiles237440755editdlrm
setpci321040755editdlrm
setquota835360755editdlrm
setsebool196080755editdlrm
sfdisk1064800755editdlrm
showmount158480755editdlrm
shutdown3055760755editdlrm
slattach384720755editdlrm
sm-notify530160755editdlrm
smartctl8743280755editdlrm
smartd6302400755editdlrm
ss1344720755editdlrm
sshd4166640755editdlrm
sssd733280755editdlrm
sss_cache360960755editdlrm
start-statd10270755editdlrm
start-stop-daemon498160755editdlrm
suexec385044755editdlrm
sulogin444400755editdlrm
sw-engine-fpm253146800755editdlrm
swaplabel196480755editdlrm
swapoff238240755editdlrm
swapon443520755editdlrm
switch_root237600755editdlrm
sysctl322480755editdlrm
tc6554560755editdlrm
tcpdump13402560755editdlrm
tcpslice280480755editdlrm
telinit3055760755editdlrm
thin_check30462960755editdlrm
thin_delta30462960755editdlrm
thin_dump30462960755editdlrm
thin_ls30462960755editdlrm
thin_metadata_pack30462960755editdlrm
thin_metadata_size30462960755editdlrm
thin_metadata_unpack30462960755editdlrm
thin_migrate30462960755editdlrm
thin_repair30462960755editdlrm
thin_restore30462960755editdlrm
thin_rmap30462960755editdlrm
thin_trim30462960755editdlrm
tipc950240755editdlrm
tmpwatch368960755editdlrm
tracepath196800755editdlrm
tracepath6196800755editdlrm
tsig-keygen279120755editdlrm
tune2fs1069680755editdlrm
udevadm6019600755editdlrm
umount.nfs1029364755editdlrm
umount.nfs41029364755editdlrm
unix_chkpwd238484755editdlrm
unix_update320800700editdlrm
unsquashfs1165360755editdlrm
update-alternatives405440755editdlrm
update-pciids17570755editdlrm
update-smart-drivedb238850755editdlrm
useradd1411440755editdlrm
userdel909680755editdlrm
usermod1327760755editdlrm
validatetrans156560755editdlrm
vdpa367360755editdlrm
vgcfgbackup28310720555editdlrm
vgcfgrestore28310720555editdlrm
vgchange28310720555editdlrm
vgck28310720555editdlrm
vgconvert28310720555editdlrm
vgcreate28310720555editdlrm
vgdisplay28310720555editdlrm
vgexport28310720555editdlrm
vgextend28310720555editdlrm
vgimport28310720555editdlrm
vgimportclone28310720555editdlrm
vgimportdevices28310720555editdlrm
vgmerge28310720555editdlrm
vgmknodes28310720555editdlrm
vgreduce28310720555editdlrm
vgremove28310720555editdlrm
vgrename28310720555editdlrm
vgs28310720555editdlrm
vgscan28310720555editdlrm
vgsplit28310720555editdlrm
vigr595520755editdlrm
vipw595520755editdlrm
visudo2736800755editdlrm
vmcore-dmesg279520755editdlrm
weak-modules343840755editdlrm
whmapi034781120755editdlrm
whmapi134781120755editdlrm
whmlogin23900755editdlrm
wipefs402240755editdlrm
xfs_admin21780755editdlrm
xfs_bmap6990755editdlrm
xfs_copy948400755editdlrm
xfs_db7250720755editdlrm
xfs_estimate155280755editdlrm
xfs_freeze8040755editdlrm
xfs_fsr445520755editdlrm
xfs_growfs446800755editdlrm
xfs_info12980755editdlrm
xfs_io2074560755editdlrm
xfs_logprint903760755editdlrm
xfs_mdrestore279360755editdlrm
xfs_metadump7860755editdlrm
xfs_mkfile10440755editdlrm
xfs_ncheck6890755editdlrm
xfs_quota943120755editdlrm
xfs_repair7027040755editdlrm
xfs_rtcp196000755editdlrm
xfs_spaceman448320755editdlrm
xqmstats156960755editdlrm
xtables-monitor2369600755editdlrm
xtables-nft-multi2369600755editdlrm
zic610560755editdlrm
zramctl572080755editdlrm
Edit: /usr/sbin/exigrep (11710B)
#! /usr/local/cpanel/3rdparty/perl/542/bin/perl # Copyright (c) The Exim Maintainers 2020 - 2025 # Copyright (c) 2007-2017 University of Cambridge. # See the file NOTICE for conditions of use and distribution. # SPDX-License-Identifier: GPL-2.0-or-later use warnings; use strict; BEGIN { pop @INC if $INC[-1] eq '.' }; use Pod::Usage; use Getopt::Long qw(:config no_ignore_case); use File::Basename; # Except when they appear in comments, the following placeholders in this # source are replaced when it is turned into a runnable script: # # PERL_COMMAND # ZCAT_COMMAND # COMPRESS_SUFFIX # MSGID_RE # This file has been so processed. # This is a perl script which extracts from an Exim log all entries # for all messages that have an entry that matches a given pattern. # If *any* entry for a particular message matches the pattern, *all* # entries for that message are displayed. # We buffer up information on a per-message basis. It is done this way rather # than reading the input twice so that the input can be a pipe. # There must be one argument, which is the pattern. Subsequent arguments # are the files to scan; if none, the standard input is read. If any file # appears to be compressed, it is passed through zcat. We can't just do this # for all files, because zcat chokes on non-compressed files. # Performance optimized in 02/02/2007 by Jori Hamalainen # Typical run time acceleration: 4 times use POSIX qw(mktime); # Insert MSGID_RE # Start msgid.frag # Copyright (c) The Exim Maintainers 2025 # SPDX-License-Identifier: GPL-2.0-or-later # # Regex patterns for exim message-id # Simple matching my $b62 = "[[:alnum:]]"; my $msgid_sec_re = "${b62}{6}"; my $msgid_pid_new_re = "${b62}{11}"; my $msgid_pid_old_re = "${b62}{6}"; my $msgid_frc_new_re = "${b62}{4}"; my $msgid_frc_old_re = "${b62}{2}"; my $msgid_new_re = "$msgid_sec_re-$msgid_pid_new_re-$msgid_frc_new_re"; my $msgid_old_re = "$msgid_sec_re-$msgid_pid_old_re-$msgid_frc_old_re"; my $msgid_re = "(?:$msgid_new_re|$msgid_old_re)"; # Match with content submatches # - requires variables seconds, pid, fractions my $msgid_sec_cap_re = "(?$msgid_sec_re)"; my $msgid_pid_cap_re = "(?(?:$msgid_pid_new_re|$msgid_pid_old_re))"; my $msgid_frc_cap_re = "(?(?:$msgid_frc_new_re|$msgid_frc_old_re))"; my $msgid_cap_re = "(?:$msgid_sec_cap_re-$msgid_pid_cap_re-$msgid_frc_cap_re)"; # End msgid.frag # This subroutine converts a time/date string from an Exim log line into # the number of seconds since the epoch. It handles optional timezone # information. sub seconds { my($year,$month,$day,$hour,$min,$sec,$tzs,$tzh,$tzm) = $_[0] =~ /^(\d{4})-(\d\d)-(\d\d)\s(\d\d):(\d\d):(\d\d)(?:.\d+)?(?>\s([+-])(\d\d)(\d\d))?/o; my $seconds = mktime $sec, $min, $hour, $day, $month - 1, $year - 1900; if (defined $tzs) { $seconds -= $tzh * 3600 + $tzm * 60 if $tzs eq "+"; $seconds += $tzh * 3600 + $tzm * 60 if $tzs eq "-"; } return $seconds; } # This subroutine processes a single line (in $_) from a log file. Program # defensively against short lines finding their way into the log. my (%saved, %id_list, $pattern); my $queue_time = -1; my $insensitive = 1; my $invert = 0; my $related = 0; my $use_pager = 1; my $literal = 0; # If using "related" option, have to track extra message IDs my $related_re=''; my @Mids = (); sub do_line { # Convert syslog lines to mainlog format, as in eximstats. if (!/^\d{4}-/o) { $_ =~ s/^.*? exim\b.*?: //o; } return unless my($date,$id) = /^(\d{4}-\d\d-\d\d \d\d:\d\d:\d\d(?:\.\d+)? (?:[+-]\d{4} )?)(?:\[\d+\] )?($msgid_re)?/o; # Handle the case when the log line belongs to a specific message. We save # lines for specific messages until the message is complete. Then either print # or discard. if (defined $id) { $saved{$id} = '' unless defined($saved{$id}); # Save up the data for this message in case it becomes interesting later. $saved{$id} .= $_; # Are we interested in this id ? Short circuit if we already were interested. if ($invert) { $id_list{$id} = 1 if (!defined($id_list{$id})); $id_list{$id} = 0 if (($insensitive && /$pattern/io) || /$pattern/o); } else { if (defined $id_list{$id} || ($insensitive && /$pattern/io) || /$pattern/o) { $id_list{$id} = 1; get_related_ids($id) if $related; } elsif ($related && $related_re) { grep_for_related($_, $id); } } # See if this is a completion for some message. If it is interesting, # print it, but in any event, throw away what was saved. if (index($_, 'Completed') != -1 || index($_, 'SMTP data timeout') != -1 || (index($_, 'rejected') != -1 && /^(\d{4}-\d\d-\d\d \d\d:\d\d:\d\d(?:\.\d+)? (?:[+-]\d{4} )?)(?:\[\d+\] )?$msgid_re rejected/o)) { if ($queue_time != -1 && $saved{$id} =~ /^(\d{4}-\d\d-\d\d \d\d:\d\d:\d\d ([+-]\d{4} )?)/o) { my $old_sec = &seconds($1); my $sec = &seconds($date); $id_list{$id} = 0 if $id_list{$id} && $sec - $old_sec <= $queue_time; } print "$saved{$id}\n" if ($id_list{$id}); delete $id_list{$id}; delete $saved{$id}; } } # Handle the case where the log line does not belong to a specific message. # Print it if it is interesting. elsif ( ($invert && (($insensitive && !/$pattern/io) || !/$pattern/o)) || (!$invert && (($insensitive && /$pattern/io) || /$pattern/o)) ) { print "$_\n"; } } # Rotated log files are frequently compressed and there are a variety of # formats it could be compressed with. Rather than use just one that is # detected and hardcoded at Exim compile time, detect and use what the # logfile is compressed with on the fly. # # List of known compression extensions and their associated commands: my $compressors = { gz => { cmd => 'zcat', args => '' }, bz2 => { cmd => 'bzcat', args => '' }, xz => { cmd => 'xzcat', args => '' }, lzma => { cmd => 'lzma', args => '-dc' }, zst => { cmd => 'zstdcat', args => '' }, }; my $csearch = 0; sub detect_compressor_bin { my $ext = shift(); my $c = $compressors->{$ext}->{cmd}; $compressors->{$ext}->{bin} = `which $c 2>/dev/null`; chomp($compressors->{$ext}->{bin}); } sub detect_compressor_capable { my $filename = shift(); map { &detect_compressor_bin($_) } keys %$compressors if (!$csearch); $csearch = 1; return undef unless (grep {$filename =~ /\.(?:$_)$/} keys %$compressors); # Loop through them, figure out which one it detected, # and build the commandline. my $cmdline = undef; foreach my $ext (keys %$compressors) { if ($filename =~ /\.(?:$ext)$/) { # Just die if compressor not found; if this occurs in the middle of # two valid files with a lot of matches, error could easily be missed. die("Didn't find $ext decompressor for $filename\n") if ($compressors->{$ext}->{bin} eq ''); $cmdline = $compressors->{$ext}->{bin} ." ". $compressors->{$ext}->{args}; last; } } return $cmdline; } sub grep_for_related { my ($line,$id) = @_; $id_list{$id} = 1 if $line =~ m/$related_re/; } sub get_related_ids { my ($id) = @_; push @Mids, $id unless grep /\b$id\b/, @Mids; my $re = join '|', @Mids; $related_re = qr/$re/; } # The main program. Extract the pattern and make sure any relevant characters # are quoted if the -l flag is given. The -t flag gives a time-on-queue value # which is an additional condition. The -M flag will also display "related" # loglines (msgid from matched lines is searched in following lines). GetOptions( 'I|sensitive' => sub { $insensitive = 0 }, 'l|literal' => \$literal, 'M|related' => \$related, 't|queue-time=i' => \$queue_time, 'pager!' => \$use_pager, 'v|invert' => \$invert, 'h|help' => sub { pod2usage(-exit => 0, -verbose => 1) }, 'm|man' => sub { pod2usage( -exit => 0, -verbose => 2, -noperldoc => system('perldoc -V 2>/dev/null >&2') ); }, 'version' => sub { print basename($0) . ": $0\n", "build: 4.100\n", "perl(runtime): $]\n"; exit 0; }, ) and @ARGV or pod2usage; $pattern = shift @ARGV; $pattern = quotemeta $pattern if $literal; # Start a pager if output goes to a terminal if (-t 1 and $use_pager) { # for perl >= v5.10.x: foreach ($ENV{PAGER}//(), 'less', 'more') foreach (defined $ENV{PAGER} ? $ENV{PAGER} : (), 'less', 'more') { local $ENV{LESS} .= ' --no-init --quit-if-one-screen'; open(my $pager, '|-', $_) or next; select $pager; last; } } # If file arguments are given, open each one and process according as it is # is compressed or not. if (@ARGV) { foreach (@ARGV) { my $filename = $_; if (-x '/bin/zcat' && $filename =~ /\.(?:gz)$/o) { open(LOG, "/bin/zcat $filename |") || die "Unable to zcat $filename: $!\n"; } elsif (my $cmdline = &detect_compressor_capable($filename)) { open(LOG, "$cmdline $filename |") || die "Unable to decompress $filename: $!\n"; } else { open(LOG, "<$filename") || die "Unable to open $filename: $!\n"; } do_line() while (); close(LOG); } } # If no files are named, process STDIN only else { do_line() while (); } # At the end of processing all the input, print any uncompleted messages. for (keys %id_list) { print "+++ $_ has not completed +++\n$saved{$_}\n"; } __END__ =head1 NAME exigrep - search Exim's main log =head1 SYNOPSIS B [options] pattern [log] ... =head1 DESCRIPTION The B utility is a Perl script that searches one or more main log files for entries that match a given pattern. When it finds a match, it extracts all the log entries for the relevant message, not just those that match the pattern. Thus, B can extract complete log entries for a given message, or all mail for a given user, or for a given host, for example. If no file names are given on the command line, the standard input is read. For known file extensions indicating compression (F<.gz>, F<.bz2>, F<.xz>, F<.lzma>, and F<.zst>) a suitable de-compressor is used, if available. The output is sent through a pager if a terminal is connected to STDOUT. As pager are considered: C<$ENV{PAGER}>, C, C. =head1 OPTIONS =over =item B<-l>|B<--literal> This means 'literal', that is, treat all characters in the pattern as standing for themselves. Otherwise the pattern must be a Perl regular expression. The pattern match is case-insensitive. =item B<-t>|B<--queue-time> I Limit the output to messages that spent at least I in the queue. =item B<-I>|B<--sensitive> Do a case sensitive search. =item B<-v>|B<--invert> Invert the meaning of the search pattern. That is, print message log entries that are not related to that pattern. =item B<-M>|B<--related> Search for related messages too. =item B<--no-pager> Do not use a pager, even if STDOUT is connected to a terminal. =item B<-h>|B<--help> Print a short reference help. For more detailed help try L, or C. =item B<-m>|B<--man> Print this manual page of B. =back =head1 SEE ALSO L, L, L =head1 AUTHOR This manual page was stitched together from spec.txt by Andreas Metzler L and updated by Heiko Schlittermann L. =cut # vim:ft=perl: