Como parar as mensagens sudo PAM no auth.log para um usuário específico no Ubuntu 16.04?

2

Estou no Ubuntu 16.04 e estou tentando impedir que /var/auth.log seja inundado por um script que verifica se alguns hosts estão vivos na rede periodicamente. O script usa internamente sudo com nmap .

Eu tenho isso no meu arquivo /etc/pam.d/sudo :

#%PAM-1.0

session [success=1 default=ignore] pam_succeed_if.so quiet uid = 0 ruser = deployer
session [success=1 default=ignore] pam_succeed_if.so quiet uid = 0

session    required   pam_env.so readenv=1 user_readenv=0
session    required   pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
@include common-auth
@include common-account
@include common-session-noninteractive

session [success=1 default=ignore] pam_succeed_if.so quiet uid = 0 ruser = deployer
session [success=1 default=ignore] pam_succeed_if.so quiet uid = 0

No entanto, ainda estou vendo isso em /var/log/auth.log:

Dec  1 10:27:43 TimeBox sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Dec  1 10:27:44 TimeBox sudo: deployer : TTY=unknown ; PWD=/data/deployer/timeagent ; USER=root ; COMMAND=/usr/bin/nmap -sn -PR -n -v0 -oX /tmp/nmap.xml20161201-5387-rn90pj 192.168.88.16
Dec  1 10:27:44 TimeBox sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Dec  1 10:27:44 TimeBox sudo: deployer : TTY=unknown ; PWD=/data/deployer/timeagent ; USER=root ; COMMAND=/usr/bin/nmap -sn -PR -n -v0 -oX /tmp/nmap.xml20161201-5387-dni0n5 192.168.88.20
Dec  1 10:27:44 TimeBox sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Dec  1 10:27:44 TimeBox sudo: deployer : TTY=unknown ; PWD=/data/deployer/timeagent ; USER=root ; COMMAND=/usr/bin/nmap -sn -PR -n -v0 -oX /tmp/nmap.xml20161201-5387-1vk93k7 192.168.88.19
Dec  1 10:27:44 TimeBox sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Dec  1 10:27:44 TimeBox sudo: deployer : TTY=unknown ; PWD=/data/deployer/timeagent ; USER=root ; COMMAND=/usr/bin/nmap -sn -PR -n -v0 -oX /tmp/nmap.xml20161201-5387-j4hcxl 192.168.88.21
Dec  1 10:27:44 TimeBox sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Dec  1 10:27:44 TimeBox sudo: deployer : TTY=unknown ; PWD=/data/deployer/timeagent ; USER=root ; COMMAND=/usr/bin/nmap -sn -PR -n -v0 -oX /tmp/nmap.xml20161201-5387-6krabn 192.168.88.13

Alguma idéia do que estou fazendo errado?

    
por Roman Gaufman 01.12.2016 / 11:30

2 respostas

2

Parece que o problema foi com @include common-session-noninteractive - isso funciona para mim em /etc/pam.d/sudo:

  #%PAM-1.0

  session [success=1 default=ignore] pam_succeed_if.so quiet uid = 0 ruser = deployer
  session    required   pam_env.so readenv=1 user_readenv=0
  session    required   pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0

  @include common-auth
  @include common-account
  # @include common-session-noninteractive

E também criei o /etc/rsyslog.d/35-pam_unix.conf para evitar o registro da linha de sudo atual:

if $syslogtag contains 'sudo' and $msg contains '/data/deployer/timeagent' then ~
    
por 01.12.2016 / 11:52
0

Você tem 3 opções:

  • execute o nmap como root
  • faça um regex de filtro no nível do syslog
  • modificar fonte

O primeiro é o caminho recomendado.

    
por 01.12.2016 / 11:37