From 0ad9786acad71a21cb41b35f9f12b6f3cabc9519 Mon Sep 17 00:00:00 2001
From: Thomas Picouet <thomas.picouet@riseup.net>
Date: Wed, 24 Oct 2018 18:09:06 +0200
Subject: [PATCH] connexion LMTP, ajout user mail2

---
 pica-mail-mda/auth_plaintext/Dockerfile    |  1 +
 pica-mail-mda/auth_plaintext/entrypoint.sh | 26 ++++++++++++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/pica-mail-mda/auth_plaintext/Dockerfile b/pica-mail-mda/auth_plaintext/Dockerfile
index 2061a8ae..4c617f34 100644
--- a/pica-mail-mda/auth_plaintext/Dockerfile
+++ b/pica-mail-mda/auth_plaintext/Dockerfile
@@ -14,6 +14,7 @@ RUN apt-get update -y \
 
 #configuration de dovecot
 
+COPY ./10-master.conf /etc/dovecot/conf.d/10-master.conf
 COPY ./10-auth.conf /etc/dovecot/conf.d/10-auth.conf
 COPY entrypoint.sh /
 
diff --git a/pica-mail-mda/auth_plaintext/entrypoint.sh b/pica-mail-mda/auth_plaintext/entrypoint.sh
index 54f9cd07..e5e8d1d3 100755
--- a/pica-mail-mda/auth_plaintext/entrypoint.sh
+++ b/pica-mail-mda/auth_plaintext/entrypoint.sh
@@ -1,9 +1,12 @@
 #!/bin/bash
 
-#ajouter utilisateur
+#ajout utilisateurs
 adduser --disabled-password mail1
-#insertion de l'utilisateur mail1 dans la BD des password.
+adduser --disabled-password mail2
+
+#insertion des utilisateurs mail1 et mail2 dans la BD des password.
 echo "mail1:{PLAIN}mail1pwd:1000:1000::/home/mail1" > /etc/dovecot/users
+echo "mail2:{PLAIN}mail2pwd:1001:1001::/home/mail2" >> /etc/dovecot/users
 
 #désactiver l'utilisation du protocole ssl
 cat <<EOF >> /etc/dovecot/conf.d/10-ssl.conf
@@ -15,5 +18,24 @@ cat <<EOF >> /etc/dovecot/conf.d/10-mail.conf
 mail_location = maildir:~/Maildir
 EOF
 
+#protocoles supportés par le mda
+#lmtp est le protocole permettant de faire du lda
+cat <<EOF >> /etc/dovecot/dovecot.conf
+protocols = imap lmtp
+EOF
+
+#on enlève la communication lmtp en socket unix...
+#il faut récupérer l'adresse IP par laquelle le conteneur communique avec son hôte
+ETH0_ADRESS=$(ip address show eth0 | grep inet | cut -b 10-19)
+
+cat <<EOF >> /etc/dovecot/conf.d/10-master.conf
+service lmtp {
+ inet_listener lmtp {
+   address = ${ETH0_ADRESS} 127.0.0.1
+   port = 24
+ }
+}
+EOF
+
 #lancer dovecot au premier plan
 dovecot -F
-- 
GitLab