Bom dia.

    Dei uma olhada aqui e o problema é o seguinte: o systemd não está repassando ao daemon do iwatch a variável de ambiente necessária para que ele encontre o arquivo ~/.sendxmpprc quando o comando sendxmpp é executado.

*Evidência:*

Se você utilizar o sendxmpp com a opção "-f /root/.sendxmpprc", o envio dos alertas é enviado com sucesso com o iwatch em modo daemon pelo systemd. Pode ser que esteja ocorrendo um problema no reconhecimento de alguma variável de ambiente  variáveis de ambiente


Se adicionarmos a linha abaixo no arquivo /bin/iwatch as variáveis de ambiente HOME ou USER não estão presentes:


  if(defined($Path->{exec})) {
    my $command = stringf("$Path->{exec}",%formats);
    print STDERR "[$now] * Command: $command\n" if($VERBOSE>0);
    syslog("info","* Command: $command") if($Path->{'syslog'});
    #We have already backslashed the escape characters in $Filename (in %formats).
    $command =~ /^(.+)$/;
    return if(!defined($1));
    my $securecommand = $1;
    system("$securecommand");
*    system("env >> /var/log/teste.log");**
**    system("ls -lha ~/ >> /var/log/teste.log");*
  }


root@debian:/etc/iwatch# tail -f /var/log/teste.log
LANGUAGE=pt_BR:pt:en
JOURNAL_STREAM=8:17071
PATH=/bin:/usr/bin:/usr/sbin
INVOCATION_ID=5eb8f5ac8204410ca60d5aa682197272
CONFIG_FILE=/etc/iwatch/iwatch.xml
LANG=pt_BR.UTF-8
PWD=/
PIDFILE=/run/iwatch.pid
START_DAEMON=false


*Soluções possíveis:*

1 - Adicionar as variáveis HOME ou USER na unit do systemd do serviço do iwatch para que ele possa carregar as variáveis de ambiente do usuário e localizar o arquivo ~/.sendxmpprc

root@debian:/etc/iwatch# cat /lib/systemd/system/iwatch.service
[Unit]
Description=realtime filesystem monitoring program using inotify
Documentation=man:iwatch
After=network.target remote-fs.target

[Service]
EnvironmentFile=/etc/default/iwatch
ExecStart=/usr/bin/iwatch -f $CONFIG_FILE -p /run/iwatch.pid -d
ExecReload=/bin/kill -HUP $MAINPID
Type=forking
PIDFile=/run/iwatch.pid
PrivateTmp=yes
*User=root*


[Install]
WantedBy=multi-user.target


2 - Utilizar a opção -f /root/.sendxmpprc no comando do sendxmpp dentro do arquivo do /etc/iwatch/iwatch.xml :

root@debian:/etc/iwatch# cat /etc/iwatch/iwatch.xml
<?xml version="1.0" ?>
<!DOCTYPE config SYSTEM "/etc/iwatch/iwatch.dtd" >
<config>
    <guard email="[email protected]" name="iWatch"/>
    <watchlist>
        <title>WEB server integrity monitoring</title>
        <contactpoint email="[email protected]" name="Administrator"/>
        <path type="recursive" syslog="on" alert="off" exec="echo %p: %e %f | /usr/bin/sendxmpp -t -f  /root/.sendxmpprc [email protected]">/bin</path>
    </watchlist>
</config>

--
<http://www.fortics.com.br/>

<https://www.facebook.com/fortics/>       

<https://www.instagram.com/forticstecnologia/>    

<https://www.linkedin.com/company/forticsoficial/>        

<https://api.whatsapp.com/send?phone=558003678427>        

<https://www.youtube.com/fortics>         

<https://twitter.com/forticsoficial>      

<https://www.tiktok.com/@fortics.tecnologia>

                *Benedito* Marques
*Desenvolvimento*
0800 367 8427
[email protected]

+55 (19) 3770-8100
0800 367 8427
0800 FORTICS

#JuntosSomosFortics

www.fortics.com.br <http://www.fortics.com.br/>


Essa mensagem é destinada exclusivamente ao seu destinatário e pode conter informações confidenciais, protegidas por sigilo profissional ou cuja divulgação seja proibida por lei. O uso não autorizado de tais informações é proibido e está sujeito às punições cabíveis.

This message is intended exclusively for its addressee and may contain information that is confidential and protected by a professional privilege or whose disclosure is prohibited by law. Unauthorized use of such information is prohibited and subject to applicable punishments.

Reply via email to