sendmail not working

19 views
Skip to first unread message

Victor Preatoni

unread,
Jul 4, 2022, 11:50:51 AM7/4/22
to Earthworm Community Forum
Hi,

I configured Linux sendmail to relay system emails. If used by command line it works properly, but if an earthworm module calls it, fails.

For example, using ewhtmlreport module, I get the following log:

20220704_UTC_15:14:44 ewhtmlreport: Sending email alert to 1 recipients.
20220704_UTC_15:14:44 Debug: issuing this email command: cat /opt/earthworm/run_working/data/ewhtml/report__header.tmp  | /usr/sbin/sendmail -t
20220704_UTC_15:14:45 Debug: return value from command: 256


Checking syslog, I can see the following error:
Jul  4 12:09:41 earthworm startstop[146457]: sh: 1: cat: not found
Jul  4 12:09:42 earthworm sSMTP[146458]: Creating SSL connection to host
Jul  4 12:09:44 earthworm sSMTP[146458]: SSL connection using RSA_AES_256_GCM_SHA384
Jul  4 12:09:44 earthworm startstop[146458]: sendmail: No recipients specified although -t option used


So, it seems that when ewhtmlreport calls "cat /opt/earthworm/run_working/data/ewhtml/report__header.tmp  | /usr/sbin/sendmail -t" command, the cat command is failing.

Tests I did so far:
- Checked path and "cat" is on it.
- Tried manually running command and it works.
- Tried manually running command under "sh" shell, using same user as earthworm runs on, and it works.

Any help appreciated!
Thanks


Stefan Lisowski

unread,
Aug 19, 2022, 11:38:25 AM8/19/22
to earthwo...@googlegroups.com, Victor Preatoni
I haven't heard of this kind of issue before. What Linux are you running
on? What user is Earthworm/startstop running under? What does 'which
cat' say for that user?

On 7/4/22 11:50 AM, Victor Preatoni wrote:
> Hi,
>
> I configured Linux /sendmail/ to relay system emails. If used by command
> line it works properly, but if an earthworm module calls it, fails.
>
> For example, using /ewhtmlreport/ module, I get the following log:
>
> 20220704_UTC_15:14:44 ewhtmlreport: Sending email alert to 1 recipients.
> 20220704_UTC_15:14:44 Debug: issuing this email command: cat
> /opt/earthworm/run_working/data/ewhtml/report__header.tmp  |
> /usr/sbin/sendmail -t
> 20220704_UTC_15:14:45 Debug: return value from command: 256
>
> Checking /syslog/, I can see the following error:
> Jul  4 12:09:41 earthworm startstop[146457]: sh: 1: cat: not found
> Jul  4 12:09:42 earthworm sSMTP[146458]: Creating SSL connection to host
> Jul  4 12:09:44 earthworm sSMTP[146458]: SSL connection using
> RSA_AES_256_GCM_SHA384
> Jul  4 12:09:44 earthworm startstop[146458]: sendmail: No recipients
> specified although -t option used
>
> So, it seems that when /ewhtmlreport/ calls "cat
> /opt/earthworm/run_working/data/ewhtml/report__header.tmp  |
> /usr/sbin/sendmail -t" command, the /cat/ command is failing.
>
> Tests I did so far:
> - Checked path and "cat" is on it.
> - Tried manually running command and it works.
> - Tried manually running command under "sh" shell, using same user as
> earthworm runs on, and it works.
>
> Any help appreciated!
> Thanks
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Earthworm Community Forum" group.
>
> To post to this group, send an email to earthwo...@googlegroups.com
>
> To unsubscribe from this group, send an email to
> earthworm_for...@googlegroups.com
>
> For more options, visit this group at
> http://groups.google.com/group/earthworm_forum?hl=en
> <http://groups.google.com/group/earthworm_forum?hl=en>
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Earthworm Community Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to earthworm_for...@googlegroups.com
> <mailto:earthworm_for...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/earthworm_forum/6ebb4193-9508-4b60-81f4-eeb529f1896an%40googlegroups.com
> <https://groups.google.com/d/msgid/earthworm_forum/6ebb4193-9508-4b60-81f4-eeb529f1896an%40googlegroups.com?utm_medium=email&utm_source=footer>.

--








*To follow ISTI news and updates please subscribe to our newsletter
"the isti letter" at  https://www.isti.com/newsletter-sign-up
<https://www.isti.com/newsletter-sign-up>.*





Victor Preatoni

unread,
Aug 22, 2022, 1:04:16 PM8/22/22
to Earthworm Community Forum
Hi Stefan,

I'm running Ubuntu Server 20.04 kernel 5.4.0-124-generic x86_64


EW is running on a dedicated earthworm user account, with the following parameters on /etc/passwd:
earthworm:x:998:998::/run/earthworm:/usr/sbin/nologin


sudo -u earthworm which cat
/usr/bin/cat



I've been checking ewhtmlemail.c code and realize that it uses the system() library function.
Then, reading system() documentation, there is an interesting caveat at the end:
"system() will not, in fact, work properly from programs with set-user-ID or set-group-ID privileges on systems on which /bin/sh is bash version 2: as a security measure, bash 2 drops privileges on startup."

Not really sure if this is the case, but I did some changes to ewhtmlemail.c code, and instead of using the system() function, changed to popen() / pclose() functions, which allow to pipe data directly to sendmail program. Another benefit is that there is no need to create a temporary header file to then cat to sendmail, as it can be done in RAM.

After those changes, ewhtmlemail is working properly. I would be happy to share code, but not sure about it's "portability" to non-POSIX operating systems.


Thanks!
Victor
Reply all
Reply to author
Forward
0 new messages