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
link|improve this question
Did you take a look at /var/log/maillog? – quanta Nov 8 '11 at 9: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 8 '11 at 9:22
How did you restore /etc/passwd? grep smmsp /etc/passwd? – quanta Nov 8 '11 at 9: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 8 '11 at 9: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 8 '11 at 9:37
show 10 more comments
feedback

3 Answers

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.

link|improve this answer
Thanks but I am looking for a solution to the problem not hindsight. – JamieB Nov 8 '11 at 9:43
This is not hindsight: it's foresight. I know it doesn't help you right now, but it can in the future. – Andrew Schulman Nov 8 '11 at 9:44
feedback

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.

link|improve this answer
Thanks but I already kept an old backup of my passwd file, sendmail just seems to think smmsp doesn't exist. – JamieB Nov 8 '11 at 9:48
feedback

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

# usermod -a -G smmsp apache
link|improve this answer
Thanks, still nothing though :( – JamieB Nov 8 '11 at 15:20
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.