-1

So yesterday Webmin deleted my /etc/passwd and although it looks like everything is working, I can't get sendmail to work when used in a PHP script.

Using mail() returns false, using PHPMailer results in "Mailer cannot execute sendmail".

I am 100% sure that this problem has happened because of the passwd file, I just can't figure out how to fix it.

I noticed a few users got corrupt and I had to replace them.

I should probably mention, if I try and send it through sendmail itself it works perfectly.

For people saying restore the /etc/passwd, I have already done this and the issue still remains.

grep smmsp /etc/group
smmsp:x:51:

ls -ld /var/spool/mqueue/
drwx------ 2 root mail 4096 Nov  8 02:56 /var/spool/mqueue/

ls -ld /var/spool/clientmqueue/
drwxrwx--- 2 smmsp smmsp 4096 Nov  8 02:55 /var/spool/clientmqueue/

ls -ld /var/spool/mail/
drwxrwxr-x 2 root mail 4096 Nov  8 02:18 /var/spool/mail/

ls -l /usr/sbin/sendmail
lrwxrwxrwx 1 root root 21 Aug  8 21:29 /usr/sbin/sendmail -> /etc/alternatives/mta

ls -l /usr/sbin/sendmail.sendmail
-rwxrwsrwx 1 root smmsp 806460 Aug 11 17:32 /usr/sbin/sendmail.sendmail

Error

Nov  8 15:58:18 jbrunton sendmail[6222]: pA8FwIPJ006222: SYSERR(UID0): Who are you?:       Permission denied
Nov  8 15:58:18 jbrunton sendmail[6222]: pA8FwIPJ006222: from=apache@jbrunton.net, size=456, class=0, nrcpts=1, msgid=<1320767898.6199@jbrunton.net>, relay=root@localhost
Nov  8 15:58:18 jbrunton sendmail[6225]: pA8FwIdW006225: SYSERR(root): collect: Cannot write ./dfpA8FwIdW006225 (bfcommit, uid=0, gid=51): Permission denied
Nov  8 15:58:18 jbrunton sendmail[6225]: pA8FwIdW006225: from=<apache@jbrunton.net>, size=598, class=0, nrcpts=1, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Nov  8 15:58:18 jbrunton sendmail[6222]: pA8FwIPJ006222: to=jbhero@gmail.com, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30456, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: 421 4.3.0 collect: Cannot write ./dfpA8FwIdW006225 (bfcommit, uid=0, gid=51): Permission denied
quanta
  • 51,413
  • 19
  • 159
  • 217
JamieB
  • 101
  • 4
  • Did you take a look at `/var/log/maillog`? – quanta Nov 08 '11 at 09:20
  • Just checked it now and I am getting this error: Nov 8 03:18:54 jbrunton sendmail[25949]: NOQUEUE: SYSERR(UID48): /etc/mail/submit.cf: line 432: readcf: option RunAsUser: unknown user smmsp: Permission denied – JamieB Nov 08 '11 at 09:22
  • How did you restore `/etc/passwd`? `grep smmsp /etc/passwd`? – quanta Nov 08 '11 at 09:28
  • Just renamed an old file and dumped it in the /etc/ folder, I assume this wasn't the way to restore the passwd file? Grep returns smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin – JamieB Nov 08 '11 at 09:29
  • Edit your original post and post all the output of `grep smmsp /etc/group`, `ls -ld /var/spool/mqueue/`, `ls -ld /var/spool/clientmqueue/`, `ls -ld /var/spool/mail/`, `ls -l /usr/sbin/sendmail`. – quanta Nov 08 '11 at 09:37
  • I've made the edit with the return values. – JamieB Nov 08 '11 at 09:42
  • `ls -l /etc/alternatives/mta`? – quanta Nov 08 '11 at 09:50
  • > ls -l /etc/alternatives/mta lrwxrwxrwx 1 root root 27 Sep 15 01:12 /etc/alternatives/mta -> /usr/sbin/sendmail.sendmail – JamieB Nov 08 '11 at 09:52
  • `ls -l /usr/sbin/sendmail.sendmail`? – quanta Nov 08 '11 at 09:53
  • You haven't answered my last question. – quanta Nov 08 '11 at 15:39
  • Yes I have it is in the original post. – JamieB Nov 08 '11 at 15:47
  • Switch to `apache` user `su - apache -s /bin/bash` and try to send mail with this user from the command line to see what does it say. If it doesn't work, post the log. – quanta Nov 08 '11 at 15:51
  • It's a no go, error posted in original post. – JamieB Nov 08 '11 at 15:59
  • I have it working through CLI now but I am getting Nov 8 16:46:04 jbrunton sendmail[3094]: NOQUEUE: SYSERR(UID48): can not write to queue directory /var/spool/clientmqueue/ (RunAsGid=0, required=51): Permission denied when sending through PHP. – JamieB Nov 08 '11 at 16:50
  • `grep -i runas /etc/mail/*.cf`? – quanta Nov 09 '11 at 00:38

3 Answers3

2

To help avoid this problem in future, you can version control /etc, so in case of errors there you can always just revert to a previous version. The etckeeper package can help with this, by keeping track of permissions within the version control repository, and integrating commits into maintenance operations.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
2

The passwd file can be regenerated but with a lot of effort. Instead, you can use the following sample passwd file to at least make some of your system accounts work/


root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
smmsp:x:511:511:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
libuuid:x:100:101::/var/lib/libuuid:/bin/sh
syslog:x:101:103::/home/syslog:/bin/false
messagebus:x:102:107::/var/run/dbus:/bin/false

As I have added the user smmmp to the passwd file, so your sendmail might work fine.

Also, look for /etc/passwd- file as well, as it is backup passwed kept by OS as well. it might be there.

user9517
  • 115,471
  • 20
  • 215
  • 297
Farhan
  • 4,269
  • 11
  • 49
  • 80
  • Thanks but I already kept an old backup of my passwd file, sendmail just seems to think smmsp doesn't exist. – JamieB Nov 08 '11 at 09:48
  • 1
    How often is this passwd- file backuped? Who perform this backup? passwd command? OS kernel? On what frequency? – jyz Feb 15 '13 at 18:15
0

Add the apache user to the smmsp group and try again:

# usermod -a -G smmsp apache
quanta
  • 51,413
  • 19
  • 159
  • 217