0

I followed this tutorial to upgrade my linode instance from Debian 8 to Stable. In the wake of that upgrade, I've had several errors/issues with sendmail.

  1. $ which sendmail doesn't return anything. I do have sendmail installed. It's at /usr/sbin/sendmail.

  2. Sendmail's permissions are as follows:

    $ ls -la /usr/sbin/sendmail lrwxrwxrwx 1 root root 26 Jul 17 12:41 /usr/sbin/sendmail -> /etc/alternatives/sendmail

    The link (/etc/alternatives/sendmail) is highlighted in red.

  3. When I try to send a test email with sudo echo "Subject: sendmail test" | /usr/sbin/sendmail -v [email protected] I get the following error:

    can not write to queue directory /var/spool/mqueue-client/ (RunAsGid=115, required=0): Permission denied

    That directory's permissions are:

    $ ls -la /var/spool/mqueue-client drwxrwxr-x 2 root root 4096 Sep 15 2018 mqueue-client

So, I obviously have some sort of permission/ownership issue, but I also think there's something else going on given items 1 and 2. I need to be able to receive emails from the system's OSSEC and Fail2ban, so I can't really go without a working email client/server. I'm just not sure how to fix these issues.

My sendmail was simply installed with $ sudo apt-get install sendmail sendmail-bin, so it came direct from Debian's repos, which is why I'm a bit baffled by these issues... I assumed that whatever configuration was needed would be handled by the installation process.

EDIT: the output of ls -l /etc/alternatives/sendmail*

lrwxrwxrwx 1 root root 24 Jul 17 12:41 /etc/alternatives/sendmail -> /usr/lib/sm.bin/sendmail lrwxrwxrwx 1 root root 42 Jul 17 12:41 /etc/alternatives/sendmail.8.gz -> /usr/share/man/man8/sendmail.sendmail.8.gz lrwxrwxrwx 1 root root 24 Jul 17 12:41 /etc/alternatives/sendmail-msp -> /usr/lib/sm.bin/sendmail lrwxrwxrwx 1 root root 42 Jul 17 12:41 /etc/alternatives/sendmail-msp.8.gz -> /usr/share/man/man8/sendmail.sendmail.8.gz lrwxrwxrwx 1 root root 24 Jul 17 12:41 /etc/alternatives/sendmail-mta -> /usr/lib/sm.bin/sendmail lrwxrwxrwx 1 root root 42 Jul 17 12:41 /etc/alternatives/sendmail-mta.8.gz -> /usr/share/man/man8/sendmail.sendmail.8.gz 

Each pair ends in a different color, e.g. /usr/lib/sm.bin/sendmail is highlighted in amber, while /usr/share/man/man8/sendmail.sendmail.8.gz is highlighted in red. It's the same colors - amber and red - for each pair.

EDIT2: The output of (echo subject: test; echo ; echo test) | /usr/sbin/sendmail -d44.4 -i -v username (I used my real username, but have adjusted the resulting output for security):

$ (echo subject: test; echo ; echo test) | /usr/sbin/sendmail -d44.4 -i -v username safefile(/etc/mail/submit.cf, uid=1000, gid=0, flags=6000, mode=400): safedirpath(/etc/mail, uid=1000, gid=0, flags=6000, level=0, offset=0): [dir /etc/mail] OK [uid 0, nlink 1, stat 100644, mode 4] OK safefile(/etc/mail/relay-domains, uid=1000, gid=0, flags=6580, mode=400): safedirpath(/etc/mail, uid=1000, gid=0, flags=6580, level=0, offset=0): [dir /etc/mail] OK No such file or directory safefile(/etc/mail/service.switch, uid=1000, gid=115, flags=6480, mode=400): safedirpath(/etc/mail, uid=1000, gid=115, flags=6580, level=0, offset=0): [dir /etc/mail] OK [uid 0, nlink 1, stat 100644, mode 4] OK safefile(/etc/mail/service.switch, uid=1000, gid=115, flags=6480, mode=400): safedirpath(/etc/mail, uid=1000, gid=115, flags=6580, level=0, offset=0): [dir /etc/mail] OK [uid 0, nlink 1, stat 100644, mode 4] OK safefile( , uid=1000, gid=115, flags=40, mode=660): safedirpath(., uid=1000, gid=115, flags=40, level=0, offset=0): [dir .] OK No such file or directory [final dir . uid 111 mode 42770] Success safedirpath(/var/spool/mqueue-client, uid=1000, gid=115, flags=0, level=0, offset=0): [dir /var/spool/mqueue-client] OK safefile(./dfx6MIGnM5005502, uid=1000, gid=115, flags=2040, mode=600): safedirpath(., uid=1000, gid=115, flags=2040, level=0, offset=0): [dir .] OK No such file or directory [final dir . uid 111 mode 42770] Success username... Connecting to [127.0.0.1] via relay... 220 major-productions.com ESMTP Sendmail 8.15.2/8.15.2/Debian-12; Mon, 22 Jul 2019 14:16:49 -0400; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1] >>> EHLO major-productions.com 250-major-productions.com Hello localhost [127.0.0.1], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-EXPN 250-VERB 250-8BITMIME 250-SIZE 250-DSN 250-ETRN 250-AUTH DIGEST-MD5 CRAM-MD5 250-DELIVERBY 250 HELP >>> VERB 250 2.0.0 Verbose mode >>> MAIL From:<[email protected]> SIZE=20 [email protected] 250 2.1.0 <[email protected]>... Sender ok >>> RCPT To:<[email protected]> >>> DATA 250 2.1.5 <[email protected]>... Recipient ok 354 Enter mail, end with "." on a line by itself >>> . 421 4.3.0 collect: Cannot write ./dfx6MIGnHm005503 (bfcommit, uid=0, gid=115): No such file or directory >>> QUIT username... Deferred: 421 4.3.0 collect: Cannot write ./dfx6MIGnHm005503 (bfcommit, uid=0, gid=115): No such file or directory safefile(/var/lib/sendmail/sm-client.st, uid=1000, gid=115, flags=2282, mode=600): safedirpath(/var/lib/sendmail, uid=1000, gid=115, flags=2282, level=0, offset=0): [dir /var/lib/sendmail] OK No such file or directory safefile(/var/lib/sendmail/sm-client.st, uid=1000, gid=115, flags=2282, mode=600): safedirpath(/var/lib/sendmail, uid=1000, gid=115, flags=2282, level=0, offset=0): [dir /var/lib/sendmail] OK No such file or directory Closing connection to [127.0.0.1] 

EDIT 3: the output of (echo subject: test; echo ; echo test) | /usr/sbin/sendmail -Am -d44.4 -i -v username while logged in as root (with the username obfuscated as before):

# (echo subject: test; echo ; echo test) | /usr/sbin/sendmail -Am -d44.4 -i -v username safefile(/etc/mail/sendmail.cf, uid=0, gid=0, flags=6000, mode=400): safedirpath(/etc/mail, uid=0, gid=0, flags=6000, level=0, offset=0): [dir /etc/mail] OK [uid 0, nlink 1, stat 100644, mode 400] OK safefile(/etc/mail/local-host-names, uid=0, gid=0, flags=6580, mode=400): safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0): [dir /etc/mail] OK [uid 0, nlink 1, stat 100644, mode 400] OK safefile(/etc/mail/relay-domains, uid=0, gid=0, flags=6580, mode=400): safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0): [dir /etc/mail] OK No such file or directory safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400): safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0): [dir /etc/mail] OK [uid 0, nlink 1, stat 100644, mode 400] OK safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400): safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0): [dir /etc/mail] OK [uid 0, nlink 1, stat 100644, mode 400] OK safedirpath(/var/spool/mqueue, uid=0, gid=0, flags=4, level=0, offset=0): [dir /var/spool/mqueue] OK safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400): safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0): [dir /etc/mail] OK [uid 0, nlink 1, stat 100644, mode 400] OK safefile(/etc/mail/aliases.db, uid=0, gid=0, flags=584, mode=400): safedirpath(/etc/mail, uid=0, gid=0, flags=584, level=0, offset=0): [dir /etc/mail] OK [uid 110, nlink 1, stat 100640, mode 400] OK safedirpath(/home/username, uid=1000, gid=1000, flags=1985, level=0, offset=0): [dir /home/username] OK safefile(/home/username/.forward.major-productions, uid=1000, gid=1000, flags=1895, mode=400): No such file or directory safedirpath(/home/username, uid=1000, gid=1000, flags=1985, level=0, offset=0): [dir /home/username] OK safefile(/home/username/.forward, uid=1000, gid=1000, flags=1895, mode=400): No such file or directory safefile(./dfx6MKLN6r006080, uid=0, gid=0, flags=2040, mode=600): safedirpath(., uid=0, gid=0, flags=2040, level=0, offset=0): [dir .] OK No such file or directory [final dir . uid 0 mode 40700] Success username... Connecting to local... safefile(/usr/sbin/sensible-mda, uid=0, gid=0, flags=41904, mode=0): safedirpath(/usr/sbin, uid=0, gid=0, flags=41904, level=0, offset=0): [dir /usr/sbin] OK [uid 0, nlink 1, stat 104755, mode 0] OK username... Sent safefile(/var/lib/sendmail/sendmail.st, uid=0, gid=0, flags=2282, mode=600): safedirpath(/var/lib/sendmail, uid=0, gid=0, flags=2282, level=0, offset=0): [dir /var/lib/sendmail] OK No such file or directory safefile(/var/lib/sendmail/sendmail.st, uid=0, gid=0, flags=2282, mode=600): safedirpath(/var/lib/sendmail, uid=0, gid=0, flags=2282, level=0, offset=0): [dir /var/lib/sendmail] OK No such file or directory 
6
  • Use ls --dereference -l /usr/sbin/sendmail to chase the soft links chain to the end. Commented Jul 18, 2019 at 4:47
  • I get the following: -r-sr-sr-t 1 root smmsp 860672 Sep 15 2018 /usr/sbin/sendmail, with the /usr/sbin/sendmail portion highlighted in red Commented Jul 20, 2019 at 0:28
  • Post info about results of ls -l /etc/alternatives/sendmail* Commented Jul 20, 2019 at 1:07
  • I've added it as an edit to the bottom of this question in order for the formatting to work Commented Jul 20, 2019 at 1:12
  • FYI, as of July 6, Debian stable is version 10 (buster), not version 9 (stretch). If you upgraded directly from version 8 to version 10, without an intermediate upgrade to version 9, then I strongly suspect that may be the source of your problem. Skipping major versions is officially not supported (or recommended). Commented Jul 25, 2019 at 7:12

2 Answers 2

2
+150
  1. $ which sendmail doesn't return anything.

sendmail IS NOT installed in non privileged users' PATH => you observe expected/normal result. sendmail is expected to be executed by other programs like mail which use full/absolute path.

  1. can not write to queue directory /var/spool/mqueue-client/ (RunAsGid=115, required=0): Permission denied

fix /var/spool/mqueue-client permissions and ownership

chown smmsp:smmsp /var/spool/mqueue-client` chmod 02770 /var/spool/mqueue-client` 

MODERN SENDMAIL DOES NOT REQUIRE TO BE SET INSTALLED AS SET ROOT ID

see results of ls -l --dereference /usr/sbin/sendmail in the question's comments:
-r-sr-sr-t 1 root smmsp 860672 Sep 15 2018 /usr/sbin/sendmail

Change permission of the final target of /usr/sbin/sendmail and /etc/alternatives links in Debian:

chmod u-s /usr/lib/sm.bin/sendmail 
10
  • I think I'm getting closer. There are no errors on the command line, but looking at /var/log/mail.log I see repeated errors with SYSERR(root): collect: Cannot write ./dfx6K1Vxg0016309 (bfcommit, uid=0, gid=115): No such file or directory Commented Jul 20, 2019 at 1:38
  • @MajorProductions I added one more fix to the answear Commented Jul 20, 2019 at 4:32
  • Sorry for the delay in replying (long, hot weekend), but the error persists: Jul 22 13:34:53 picus sm-mta[5208]: x6MHYrvA005208: SYSERR(root): collect: Cannot write ./dfx6MHYrvA005208 (bfcommit, uid=0, gid=115): No such file or directory Commented Jul 22, 2019 at 17:36
  • @MajorProductions As non-root execute the following test/diagnostic command (echo subject: test; echo ; echo test) | /usr/sbin/sendmail -d44.4 -i -v username. sendmail may refuse to act when permissions are TOO BROAD (as security measure). Commented Jul 22, 2019 at 17:53
  • Hmm... the same error with the same hashed file name is in the output, but there are several other "No such file or directory" mentions in the output as well. I'm going to post the output in my initial question for space/formatting Commented Jul 22, 2019 at 18:19
0

Does it work if you run this:

echo "Subject: sendmail test" | sudo sendmail /usr/sbin/sendmail -v [email protected]

The distinction being that you are running echo as root, but not sendmail.

Thus the message: "(RunAsGid=115, required=0): Permission denied"

The "115" is the Group Id of your user, and it is expecting "0" (which is roots)

3
  • Same error, with the same Gid values. Commented Jul 18, 2019 at 1:27
  • My first comment was slightly off and did not include "sudo" in there. Did you pipe to sudo sendmail? Commented Jul 19, 2019 at 0:42
  • Yeah, same exact error/Gid values Commented Jul 20, 2019 at 0:27

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.