3

Using Exim - root user can send email from command line, but non root users can not.

$ mail -s "test" test@test.com </dev/null
Null message body; hope that's ok
[xxx@master1 /usr/home/xxx]$ 2015-03-31 17:06:34 [58856] 
cwd=/usr/home/xxx 3 args: send-mail -i test@test.com

Seeing this in /var/log/messages:

Mar 31 17:07:11 master1 exim[59400]: 2015-03-31 17:07:11 [59400] 1Ycxl1-000FS4-0T failed to write to main log: length=134 result=-1 errno=9 (Bad file descriptor)
Mar 31 17:07:11 master1 exim[59400]: write failed on panic log: length=125 result=-1 errno=9 (Bad file descriptor)
Mar 31 17:07:11 master1 exim[59409]: 2015-03-31 17:07:11 [59409] 1Ycxl1-000FSD-1F failed to write to main log: length=134 result=-1 errno=9 (Bad file descriptor)
Mar 31 17:07:11 master1 exim[59409]: write failed on panic log: length=125 result=-1 errno=9 (Bad file descriptor)

exim is a symlink - both symlink and actual binary permissions look like:

[xxx@master1 ~]$ ls -l `which exim`
lrwsr-xr-x  1 root  wheel  13 Aug  5  2013 /usr/local/sbin/exim -> exim-4.80.1-2
[xxx@master1 ~]$ ls -l /usr/local/sbin/exim-4.80.1-2
-rwsr-xr-x  1 root  wheel  983184 Aug  5  2013 /usr/local/sbin/exim-4.80.1-2

Have tried adding user xxx as trusted_users in exim config - made no difference

Vuade
  • 51
  • What is your operating system/ distribution, please? And are you using your distribution's binary package, or not? And if not, why not? Ok, answering my own question - /usr/local/sbin is clearly not a system installation. Use the packaged binary, and your problems will likely go away. – Faheem Mitha Mar 31 '15 at 15:45
  • For all we know, the question lacking this information, this could be FreeBSD, Faheem Mitha. (Certainly wheel and /usr/home hint at this.) On FreeBSD, that is where the packaged binary lives. – JdeBP Mar 31 '15 at 19:28
  • Indeed - it is FreeBSD 9.1-RELEASE-p4, and that is the distributions binary package – Vuade Apr 01 '15 at 06:47
  • Are you sure mail is invoking /usr/local/sbin/exim and not perhaps an old version in /usr/lib/sendmail or /usr/sbin/sendmail? – wurtel Apr 01 '15 at 10:21
  • @wurtel I actually intend to use mutt. When I run mutt, I can see it invokes sendmail -oem -oi, and immediately thereafter I see the exim message in /var/log/messages. (/usr/sbin/sendmail -> /usr/sbin/mailwrapper) – Vuade Apr 01 '15 at 12:02

2 Answers2

2

Others have suggested to resolve this with

chmod 4755 /usr/sbin/exim

In this case both mail and mutt is invoking sendmail.

Problem resolved with:

chmod 4755 /usr/sbin/sendmail

Now messages are sent successfully, and /var/log/exim/mainlog is written to and reflect as such.

Vuade
  • 51
  • So you have /usr/sbin/sendmail and /usr/local/sbin/exim-4.80.1-2? So are you even running exim now to deliver your messages? – Chris Davies Apr 02 '15 at 12:14
  • @roaima sorry for the noob question - but how do I tell? I assumed exim because of:

    1- The fact that immediately after running a program like mail and mutt, exim writes to /var/log/messages 2- When root runs mutt/mail, messages are appended in /var/log/exim/mainlog, and 3 sudo ps aux | egrep 'exim|sendmail' yields only /usr/local/sbin/exim -bd -q30m (exim-4.80.1-2)

    – Vuade Apr 02 '15 at 13:16
  • What is result of ls -l /usr/sbin/sendmail? – Chris Davies Apr 02 '15 at 13:25
  • 2
    A lot of this confusion in various comments is coming from the fact that people aren't aware of how this stuff works on FreeBSD. It is not like Linux operating systems. The BSDs use mailwrapper. And third-party stuff from ports goes in /usr/local. – JdeBP Apr 03 '15 at 11:11
  • @roaima to answer your question, as @JdeBP pointed out, /usr/sbin/sendmail is a symlink to /usr/sbin/mailwrapper. Initially I tried to chmod only the symlink with chmod -h, but in the end the plain chmod did the trick by updating the permissions of /usr/sbin/mailwrapper – Vuade Apr 03 '15 at 16:46
  • @Vuade I missed the OS description because it was buried in the comments. This is why people are asked to update their Questions with pertinent information. – Chris Davies Apr 03 '15 at 17:26
  • after so much pain this is the answer that fixed it for me -- crazy that no where else on the internet mentions this as a possible solution -- my error was ssmtp: Cannot open mailhub:25 -- when trying to send mail through any various means mailx mutt sstmp. I knew there was a permission error but didn't know where. – qodeninja Aug 26 '18 at 16:39
0

I had a similar problem and this showed up on Google.

My solution was as simple as calling /usr/sbin/sendmail instead of just sendmail.

Found the path using which sendmail (as root). No permission change was needed.

(I use nullmailer's sendmail 'decoy', not even exim; don't think it makes a difference though)