自动日志电子邮件的Apparmor和Senmail问题

从CLI运行时,他的bash脚本工作正常-

#!/bin/bash

tail -n 50 /var/log/suricata/fast.log > "$(date '+%Y-%m-%d_%H-%M-%S').log"

echo "Hello this is the body message,we are sending email with attachement using mutt and msmtp" \
| mutt -a /home/osboxes/Downloads/"$(date '+%Y-%m-%d_%H-%M-%S').log" \
       -s "this is the subject of the message" -- xxxx@gmail.com

但是,我尝试安装一个cronjob来每天运行它,但是它不起作用,这是工作:

# m h dom mon dow command
* * * * * root /home/osboxes/Downloads/sendlogzzz.sh**

这是系统错误:

Apr 17 20:34:07 osboxes kernel: [  982.464037] audit: type=1400 audit(1587170047.732:1614): apparmor="DENIED" operation="file_lock" profile="/usr/bin/msmtp" name="/tmp/msmtp.log" pid=5170 comm="sendmail" requested_mask="k" denied_mask="k" fsuid=0 ouid=0
Apr 17 20:34:07 osboxes kernel: [  982.564178] audit: type=1400 audit(1587170047.832:1615): apparmor="DENIED" operation="file_lock" profile="/usr/bin/msmtp" name="/tmp/msmtp.log" pid=5170 comm="sendmail" requested_mask="k" denied_mask="k" fsuid=0 ouid=0
Apr 17 20:34:07 osboxes kernel: [  982.664238] audit: type=1400 audit(1587170047.932:1616): apparmor="DENIED" operation="file_lock" profile="/usr/bin/msmtp" name="/tmp/msmtp.log" pid=5170 comm="sendmail" requested_mask="k" denied_mask="k" fsuid=0 ouid=0
Apr 17 20:34:12 osboxes cron[637]: sendmail: cannot log to /tmp/msmtp.log: cannot lock (tried for 10 seconds): Permission denied

这是我的sendmail配置器:

# Author: Simon Deziel <simon@sdeziel.info>
#include <tunables/global>
/usr/bin/msmtp flags=(attach_disconnected) {
  #include <abstractions/base>
  #include <abstractions/nameservice>
  #include <abstractions/p11-kit>
  #include <abstractions/ssl_certs>
  #include <abstractions/ssl_keys>

  /usr/bin/msmtp          mr,/etc/aliases            r,/etc/msmtprc            r,/etc/netrc              r,owner @{HOME}/.msmtp*   r,owner @{HOME}/.netrc    r,owner @{HOME}/.tls-crls r,owner @{HOME}/.msmtp*.log wk,/var/log/msmtp            wk,owner @{HOME}/**/.msmtprc        r,owner @{HOME}/**/dot_msmtprc     r,owner @{HOME}/.config/msmtp/*    r,owner @{HOME}/.cache/msmtp/*     r,owner @{HOME}/.cache/msmtp/*.log wk,@{PROC}/@{pid}/loginuid r,/tmp/                   rw,owner /tmp/*            rw,# to type password interactively
  owner /dev/pts/[0-9]*   rw,# secret helpers
  /{,usr/}bin/bash Cx -> helpers,/{,usr/}bin/dash Cx -> helpers,profile helpers {
    #include <abstractions/base>
    /{,usr/}bin/bash mr,usr/}bin/dash mr,/tmp/            rw,owner /tmp/*     rw,/usr/bin/secret-tool PUx,/usr/bin/gpg{,2}     PUx,/usr/bin/pass        PUx,/usr/bin/head        PUx,usr/}bin/cat      PUx,}

  #include <local/usr.bin.msmtp>
}
gay1718 回答:自动日志电子邮件的Apparmor和Senmail问题

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2415914.html

大家都在问