Table des matières

Sendmail en mode démon "securisé"

Le but de la manip est d'avoir un démon Sendmail en permanence qui effectue des réessais d'envoi lorsque la passerelle est down. Pour une sécurité accrue le démon n'écoute qu'en local pour ne pas être relai d'autres machines.

note : cette manip fonctionne aussi sous d'autres Unix, ici seules les parties Mise à jour de Sendmail, Config du boot et Tests sont réellement spécifiques HP-UX.

Mise à jour de Sendmail

Il faut utiliser la version 8.13.3 qui est disponible ici. C'est un fichier dépot donc une fois sur la machine :

root@server306:/tmp#swinstall -s /tmp/Sendmail-Upgrade_B.11.23.1.005_HP-UX_B.11.23_IA+PA.depot

:!: Attention de bien spécifier le chemin complet. Ne pas tenir compte des warnings sur les éventuelles dépendances.

Fichiers de conf

:!: Se positionner sous /usr/contrib/sendmail/usr/newconfig/etc/mail/cf/cf/

sendmail.cf

On créé un fichier sendmail_new.mc en prenant soin de modifier l'entrée define(`SMART_HOST',`SERVER')dnl avec le bon serveur mail :

divert(-1)
#
# Copyright (c) 1998, 1999, 2001 Sendmail, Inc. and its suppliers.
#       All rights reserved.
# Copyright (c) 1983 Eric P. Allman.  All rights reserved.
# Copyright (c) 1988, 1993
#       The Regents of the University of California.  All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#

#
#  This is a generic configuration file for HP-UX 10.x.
#  It has support for local and SMTP mail only.  If you want to
#  customize it, copy it to a name appropriate for your environment
#  and do the modifications there.
#
#

divert(0)dnl
divert(-1)
# Ported changes from sendmail-8.11.1 - Manoj Nov 16, 2004.
# Fix for JAGaa30867.
# Enabled local site hiding and masquerading in default sendmail.cf file.
# Adding feature(always_add_domain) and define __MASQUERADE_ENVELOPE_
# Fix for JAGaa30300 - Added support for openmail
divert(0)dnl
VERSIONID(`$Id: generic-hpux10.mc,v 8.13 2001/05/29 17:29:52 ca Exp $')
OSTYPE(hpux11)dnl
DOMAIN(generic)dnl
FEATURE(genericstable)
FEATURE(masquerade_envelope)dnl
FEATURE(always_add_domain)dnl
define(`_MASQUERADE_ENVELOPE_')dnl
define(`MASQUERADE_NAME')dnl
define(`confTRY_NULL_MX_LIST',`T')dnl
define(`DATABASE_MAP_TYPE',`dbm')dnl
define(`_CLASS_U_')dnl
define(`_NO_MSA_')dnl
define(`SMART_HOST',`SERVER')dnl
define(`_ACCEPT_UNRESOLVABLE_DOMAINS_')dnl
DAEMON_OPTIONS(`Port=587, Name=MSA, Addr=127.0.0.1, M=E')dnl
TRUST_AUTH_MECH(`GSSAPI DIGEST-MD5')dnl
MAILER(smtp)dnl
MAILER(local)dnl

Ensuite on compile le fichier pour obtenir le .cf quivabien :

m4 ../m4/cf.m4 sendmail_new.mc > sendmail_new.cf

submit.cf

On créé un fichier submit_new.mc :

divert(-1)
#
# Copyright (c) 2001-2003 Sendmail, Inc. and its suppliers.
#       All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#

#
#  This is the prototype file for a set-group-ID sm-msp sendmail that
#  acts as a initial mail submission program.
#

divert(0)dnl
VERSIONID(`$Id: submit.mc,v 8.13 2003/09/10 22:12:48 ca Exp $')
FEATURE(`genericstable')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(`msp', `[127.0.0.1]',`MSA')dnl
define(`confCF_VERSION', `Submit')dnl
define(`__OSTYPE__',`')dnl dirty hack to keep proto.m4 from complaining
define(`_USE_DECNET_SYNTAX_', `1')dnl support DECnet
define(`confTIME_ZONE', `USE_TZ')dnl
define(`confDONT_INIT_GROUPS', `True')dnl
define(`_MASQUERADE_ENVELOPE_')dnl
define(`DATABASE_MAP_TYPE',`dbm')dnl
dnl
dnl If you use IPv6 only, change [127.0.0.1] to [IPv6:::1]

Ensuite on compile le fichier pour obtenir le .cf quivabien :

m4 ../m4/cf.m4 submit_new.mc > submit_new.cf

Copie des fichiers

On copie les fichiers dans le répertoire /etc/mail (on backup les anciens fichiers au passage ^_^) :

cp /usr/contrib/sendmail/usr/newconfig/etc/mail/cf/cf/sendmail_new.cf /etc/mail/sendmail.cf
cp /usr/contrib/sendmail/usr/newconfig/etc/mail/cf/cf/submit_new.cf /etc/mail/submit.cf

Ensuite il faut lancer le script gen_cf.utils qui rajoute les users et groupes nécessaires :

. /usr/contrib/sendmail/usr/newconfig/etc/mail/cf/cf/gen_cf.utils

Puis on appelle la fonction sourcée (répondre y) :

Create_User

Rechargement des fichiers + droits

On recharge les fichiers genericstable et aliases :

cd /etc/mail
makemap hash genericstable < genericstable
makemap hash aliases < aliases

On met à jour les droits des fichiers :

cd /etc/mail
chgrp smmsp *
chmod 644 *

On vérifie que tout est ok :

sendmail -bi

Config du boot

Vérifier le fichier /etc/rc.config.d/mailservs :

#########################################
# Mail configuration.  See sendmail(1m) #
#########################################
#
# @(#)B.11.11_LR
#
#  BSD's popular message handling system
#
# SENDMAIL_SERVER:      Set to 1 if this is a mail server and should
#                       run the sendmail deamon.
# SENDMAIL_SERVER_NAME: If this is not a mail server, but a client being
#                       served by another system, then set this variable
#                       to the name of the mail server system name so that
#                       site hiding can be performed.
#
export SENDMAIL_SERVER=0
export SENDMAIL_SERVER_NAME=
export SENDMAIL_SENDONLY=1

Tests

On effectue un A/R du sendmail :

/sbin/init.d/sendmail stop
/sbin/init.d/sendmail start

On vérifie que le démon est bien présent :

netstat -an|grep 587
ps -ef |grep sendmail

On vérifie la conf (on doit avoir un return code égal à 0. <key>C-d</key> pour sortir) :

server107:/usr/contrib/sendmail/etc/mail#sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> /tryflags es
> /try smtp prenom.nom@grossesociete.com

On effectue un envoi de mail :

echo "test" |mailx -s "test" prenom.nom@grossesociete.com

Vérifier dans les logs que tout se passe bien (elles sont verbeuses) :

/var/adm/syslog/mail.log

Des scripts d'install sont dispos ici.