Printable Version of Topic
Click here to view this topic in its original format
XMail Forum > Documentation and Knowledge Base > XMail Sendmail permission denied !


Posted by: crys Mar 4 2006, 09:53 AM
Hi All,

I do this,
CODE
ns1 # sendmail crys@domain.tld -s "SSH Alert" admin@omain.tld

And I get,
CODE
/var/MailRoot/spool/temp/1141458289000.22430.ns1: Permission denied

I checked the dirs,
CODE
ns1 # ls -la /var/MailRoot/spool/
total 108
drwx------  27 root root 4096 Feb 23 20:47 .
drwx------  15 root root 4096 Mar  4 10:01 ..
drwx------  25 root root 4096 Feb  7 10:53 0
drwx------  25 root root 4096 Feb  7 10:53 1
drwx------  25 root root 4096 Feb  7 10:53 10
--- continue ---
drwx------  25 root root 4096 Feb  7 10:53 7
drwx------  25 root root 4096 Feb  7 10:53 8
drwx------  25 root root 4096 Feb  7 10:53 9
drwx------   2 root root 4096 Feb 28 11:39 local
drwx------   2 root root 4096 Feb 28 11:38 temp
ns1 #

and this,
CODE
ns1 # ls -la /usr/sbin/sendmail*
-rwxr-xr-x  1 root  root    103 Mar  4 13:18 /usr/sbin/sendmail
-rwxr-xr-x  1 root  root    118 Feb  7 14:25 /usr/sbin/sendmail.org
-rws--S---  1 xmail xmail 14688 Mar  4 13:15 /usr/sbin/sendmail.xmail
ns1 #

What could be the problem?

Thnx

Crys.

Posted by: hschneider Mar 4 2006, 10:21 AM
mv sendmail sendmail.org2
ln -s sendmail.xmail.sh sendmail
chmod +s sendmail.xmail.sh

The sendmail.xmail.sh should call sendmail.xmail then.

Mine looks like this:

CODE

#!/bin/sh

export DEFAULT_DOMAIN="xxx.com"

if [ -z $MAIL_ROOT ]; then
       export MAIL_ROOT=/var/MailRoot
fi
/usr/sbin/sendmail.xmail $*


CODE

lrwxr-xr-x  1 root  wheel     17 Oct 13 10:06 sendmail -> sendmail.xmail.sh
-rwsr-sr-x  1 root  wheel  15428 Oct 13 10:04 sendmail.xmail
-rwsr-sr-x  1 root  wheel    141 Oct 14 07:35 sendmail.xmail.sh

Posted by: crys Mar 6 2006, 10:21 AM
Thanks,

This works charm!. Do you care to explain WHY?. Not Mandatory but will help!!

Thanks,

Crys

Posted by: hschneider Mar 6 2006, 11:03 AM
mv sendmail sendmail.org2
This disables the original sendmail binary by renaming it.

ln -s sendmail.xmail.sh sendmail
Here we create a symbolic link called sendmail, which calls sendmail.xmail.sh. So each call to the sendmail binary is redirected to that script.

chmod +s sendmail.xmail.sh
This means the script is executed under the ID of its owner (root).

The script itself just sets the global environment variables DEFAULT_DOMAIN + MAIL_ROOT and finally calls XMail's sendmail binary:
/usr/sbin/xmail.sendmail
which has also its SUID bit set (chmod +s)

Posted by: crys Mar 7 2006, 03:59 AM
THANK YOU,

And off topic
I'd like to share something for which I toil to get this XMail sendmail CLI working!!,

1. I wanted to get SSH login/connection alert from my box (I have a gentoo box)

2. Create a file called /etc/ssh/sshrc
CODE
vi /etc/ssh/sshrc
# /etc/ssh/sshrc
# Send a brief alert with connection details
#
when=`/usr/bin/date`
sWhen=`/usr/bin/date +'%F %T'`
where=`echo $SSH_CONNECTION|cut -f1 -d' '|cut -f4 -d:`
if [ -z "$SSH_TTY" ]; then
  what="Connect by $USER"
else
  what="Login by $USER on $SSH_TTY"
fi

/usr/sbin/sendmail -t >&2 <<-EOM
Subject:SSH Alert - ${sWhen}
From:root ns1 <root>
To:Crysanthus Silva <crys@domain.tld>, System administrator <admin@domain.tld>

 ${what} from ${where} at ${when}
EOM

3. Whenever a connection is made thru' SSH I get a mail.
4. My next step is to setup a sms alert to my mobile!!!.

I'll be very glad if this helps somebody. Please please improve this junk if a genius see this !!!.

Thnx

Crys.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)