Fix Logfile Permissions Macro
The fix_logfile_permissions_alarms_macros.cfg is a script macro to fix logfile permissions.
fix_logfile_permissions(DIRS, BYPASS, PERMS) init status =piktstatus level =piktlevel task "Fix logfile permissions." input proc "=find (DIRS) -type f -print 2>/dev/null" rule if $inlin =~ "(BYPASS)" next fi rule if $inlin =~ "/[^a-zA-Z]" // e.g., logfile name beginning // with "-" or "#" =output_other_mail(FIXLOGFILEPERMS, 'PIKT FixLogFilePermissions Errors on =pikthostname', =piktadmin, $inlin) next fi rule doexec wait "=chmod (PERMS) $inlin" end quit
You might invoke the =fix_logfile_permissions() macro in your alarms.cfg file thusly:
/////////////////////////////////////////////////////////////////////////////// // // logs_system_alarms.cfg // /////////////////////////////////////////////////////////////////////////////// FixMetaLogfilePermissions =fix_logfile_permissions(/var/log/kernel /var/log/crond /var/log/iptrap /var/log/pwdfail /var/log/ftpd /var/log/sshd /var/log/telnet /var/log/imap /var/log/pop /var/log/mail /var/log/everything /var/log/critical, .timestamp, 644) /////////////////////////////////////////////////////////////////////////////// FixPIKTLogfilePermissions =fix_logfile_permissions(=logdir =hstdir, =nonesuch, 600) ///////////////////////////////////////////////////////////////////////////////
For more examples, see Samples.