<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Werk &#187; BSD</title>
	<atom:link href="http://werk.feub.net/category/bsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://werk.feub.net</link>
	<description>Pourquoi Werk? ^.^</description>
	<lastBuildDate>Tue, 06 Dec 2011 14:18:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Mise en place d&#8217;un serveur VNC et tunnel SSH</title>
		<link>http://werk.feub.net/2011/12/mise-en-place-dun-serveur-vnc-et-tunnel-ssh/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mise-en-place-dun-serveur-vnc-et-tunnel-ssh</link>
		<comments>http://werk.feub.net/2011/12/mise-en-place-dun-serveur-vnc-et-tunnel-ssh/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 14:08:23 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[putty]]></category>
		<category><![CDATA[remote access]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tigervnc]]></category>
		<category><![CDATA[vnc]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=900</guid>
		<description><![CDATA[Voici un court tutoriel pour utiliser VNC sur une machine CentOS et ainsi accéder à une (ou des) session(s) X. En ce qui me concerne, je l&#8217;utilise ponctuellement pour avoir accès au bureau XFCE de mon serveur dédié. Installation du paquet L&#8217;installation se fait toujours avec yum, pour CentOS 5.x et Fedora avant F11: # [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/12/Network_Connections.png" alt="" class="floatleft" />Voici un court tutoriel pour utiliser <a href="http://fr.wikipedia.org/wiki/Virtual_Network_Computing" title="Wikipedia : VNC" target="_blank">VNC</a> sur une machine <a href="http://www.centos.org/" title="CentOS" target="_blank">CentOS</a> et ainsi accéder à une (ou des) session(s) X. En ce qui me concerne, je l&#8217;utilise ponctuellement pour avoir accès au bureau <a href="http://www.xfce.org/" title="XFCE" target="_blank">XFCE</a> de mon serveur dédié.
</p>
<p><span id="more-900"></span></p>
<h4>
Installation du paquet<br />
</h4>
<p>
L&#8217;installation se fait toujours avec <code>yum</code>, pour CentOS 5.x et <a href="http://fedoraproject.org/" title="Fedora Project" target="_blank">Fedora</a> avant F11:
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install vnc-server</span></pre></div></div>

<p>
Pour CentOS 6.x et Fedora après F11, on utilise TigerVNC :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install tigervnc-server</span></pre></div></div>

<h4>
Attribuer un mot de passe VNC à l&#8217;utilisateur<br />
</h4>
<p>
Se connecter en tant que l&#8217;utilisateur pour l&#8217;accès VNC, puis lui attribuer un mot de passe avec cette commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">vncpasswd</pre></div></div>

<p>
Ceci va créer le répertoire <code>.vnc</code> et stocker le mot de passe.
</p>
<h4>
Configurer le serveur<br />
</h4>
<p>
Il faut éditer le fichier <code>/etc/sysconfig/vncservers</code> avec quelque chose comme ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">VNCSERVERS</span>=<span style="color: #ff0000;">&quot;2:fabien toto:6&quot;</span>
VNCSERVERARGS<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;-geometry 1024x768 -localhost&quot;</span>
VNCSERVERARGS<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;-geometry 800x600&quot;</span></pre></div></div>

<p>
Ce qui signifie que fabien va avoir un écran de 1024x768px accessible sur le port VNC 2 (port VNC 5900 + 2 = 5902) seulement en local, alors que toto utilisera le port 6 avec une résolution de 800x600px.
</p>
<h4>
Démarrage et initialisation du serveur<br />
</h4>
<p>
Le serveur doit etre lancé une fois pour initialiser le fichier de configuration <code>~/.vnc/xstartup</code> des utilisateurs :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /sbin/service vncserver start</span>
<span style="color: #666666; font-style: italic;"># /sbin/service vncserver stop</span></pre></div></div>

<p>
Il ne reste plus que quelques modifications à effectuer pour accéder à sa session à distance. Dans le cas de XFCE, je remplace simplement <code>twm &#038;</code> par <code>startxfce4 &#038;</code> (<code>gnome-session &#038;</code> pour Gnome ou <code>startkde &#038;</code> pour KDE). La ligne <code>XKL_XMODMAP_DISABLE=1</code> est nécessaire pour éviter des problèmes de mappage de clavier, il est bon de ne pas l&#8217;oublier. Voici mon fichier <code>xstartup</code> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Uncomment the following two lines for normal desktop:</span>
<span style="color: #666666; font-style: italic;">#unset SESSION_MANAGER</span>
<span style="color: #666666; font-style: italic;">#exec /etc/X11/xinit/xinitrc</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-x</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vnc<span style="color: #000000; font-weight: bold;">/</span>xstartup <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>vnc<span style="color: #000000; font-weight: bold;">/</span>xstartup
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.Xresources <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> xrdb <span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.Xresources
xsetroot <span style="color: #660033;">-solid</span> grey
vncconfig <span style="color: #660033;">-iconic</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
xterm <span style="color: #660033;">-geometry</span> 80x24+<span style="color: #000000;">10</span>+<span style="color: #000000;">10</span> <span style="color: #660033;">-ls</span> <span style="color: #660033;">-title</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$VNCDESKTOP</span> Desktop&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
<span style="color: #666666; font-style: italic;">#twm &amp;</span>
startxfce4 <span style="color: #000000; font-weight: bold;">&amp;</span></pre></div></div>

<h4>
Tunnel SSH<br />
</h4>
<p>
L&#8217;option <code>-localhost</code> n&#8217;autorise l&#8217;accès qu&#8217;en local. Pour accèder à ce serveur en VNC il faut donc au préalable établir une connexion SSH entre la machine cliente et celui-ci en créant un tunnel qui redirigera le port 5904 du serveur vers le port &#8211; par exemple &#8211; 6004 du client. Voici comment instancier cette connexion SSH depuis un client linux :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">6002</span>:localhost:<span style="color: #000000;">5902</span> IP_SERVEUR</pre></div></div>

<p>
Et voici la configuration de ce tunnel avec <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" title="puTTY" target="_blank">puTTY</a> sous Windows :
</p>
<div class="post-image">
<img src="http://werk.feub.net/medias/2011/12/1_tunnel_putty.png" alt="" title="puTTY" width="456" height="442" class="alignnone size-full wp-image-901" />
</div>
<div class="post-image">
<img src="http://werk.feub.net/medias/2011/12/2_tunnel_putty.png" alt="" title="Tunnel avec puTTY" width="456" height="442" class="alignnone size-full wp-image-903" />
</div>
<p>
Une fois la connexion effectuée, il suffit d&#8217;utiliser son client VNC avec localhost et le port 6004 pour accéder au serveur en toute sécurité. En ligne de commande sous linux avec le client vncviewer :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ vncviewer localhost:<span style="color: #000000;">6002</span></pre></div></div>

<p>
Et sous Windows par exemple avec le client UltraVNC :
</p>
<div class="post-image">
<img src="http://werk.feub.net/medias/2011/12/3_ultravnc.png" alt="" title="UltraVNC" width="375" height="372" class="alignnone size-full wp-image-904" />
</div>
<p>
De cette façon, il n&#8217;est pas possible de se connecter à la machine depuis une autre IP que la locale (<code>127.0.0.1</code>).</p>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/12/mise-en-place-dun-serveur-vnc-et-tunnel-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stockage : réplication en temps réel avec DRBD</title>
		<link>http://werk.feub.net/2011/09/drbd-centos-6/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=drbd-centos-6</link>
		<comments>http://werk.feub.net/2011/09/drbd-centos-6/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 09:24:40 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[drbd]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[storage]]></category>
		<category><![CDATA[synchronisation]]></category>
		<category><![CDATA[système de fichiers]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=879</guid>
		<description><![CDATA[DRBD (Distributed Replicated Block Device) est une architecture de stockage distribuée pour GNU/Linux, pour parler rapidement on peut dire qu&#8217;il s&#8217;agit d&#8217;une sorte de RAID 1 au niveau du réseau. Cela permet d&#8217;avoir deux machines avec réplication de données de l&#8217;une vers l&#8217;autre, l&#8217;une étant désignée primaire et l&#8217;autre secondaire (mais il existe un mode [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/09/drbd_logo_small.gif" alt="" class="floatleft" /><a href="http://fr.wikipedia.org/wiki/DRBD" title="Wikipedia: DRBD" target="_blank">DRBD</a> (Distributed Replicated Block Device) est une architecture de stockage distribuée pour GNU/Linux, pour parler rapidement on peut dire qu&#8217;il s&#8217;agit d&#8217;une sorte de RAID 1 au niveau du réseau. Cela permet d&#8217;avoir deux machines avec réplication de données de l&#8217;une vers l&#8217;autre, l&#8217;une étant désignée primaire et l&#8217;autre secondaire (mais il existe un mode primaire/primaire également). Il s&#8217;agit d&#8217;un logiciel libre développé par la société <a href="http://www.linbit.com/" title="linbit.com" target="_blank">Linbit</a> qui par ailleurs offre un service de support.
</p>
<p>
DRBD réplique au niveau des périphériques de bloc, pour plus d&#8217;informations sur son fonctionnement, je vous renvoie à la <a href="http://fr.wikipedia.org/wiki/DRBD#Principe_de_fonctionnement" title="Wikipedia : DRBD" target="_blank">page Wikipedia de DRBD</a>.
</p>
<p><span id="more-879"></span></p>
<h4>Pré-requis</h4>
<p>
Ce tutoriel est réalisé avec deux machines sous <a href="http://www.centos.org/" title="centos.org" target="_blank">CentOS 6</a>, celles-ci sont respectivement nommées <code>centos-ha1</code> (IP : 192.168.1.10) et <code>centos-ha2</code> (IP : 192.168.1.11), le terme de nœud sera utilisé pour les désigner.<br />
SELinux est désactivé et le port 7789 ouvert au niveau du firewall.
</p>
<p>
DRBD fonctionnant au niveau bloc, il faut un disque ou une partition dédiée à cela. Dans l&#8217;exemple de ce billet, on part d&#8217;un groupe de volumes LVM nommé <code>vg_storage</code> avec un unique volume logique <code>lv_storage</code> qui est libre pour créer notre ressource DRBD. Un volume logique étant un périphérique de bloc aux yeux de Linux, cela convient parfaitement. Celui-ci n&#8217;a pas besoin (et ne doit pas) d&#8217;être formatté.
</p>
<h4>Installation</h4>
<p>
Depuis CentOS 6, les paquets DRBD ne sont plus dans les dépots de base, il faut donc ajouter ceux de <a href="http://atrpms.net/" title="atRPMS" target="_blank">atRPMS</a>. Pour ce faire, ajouter le fichier <code>atrpms.repo</code> sous <code>/etc/yum.repos.d</code> contenant ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>atrpms<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #007800;">name</span>=CentOS <span style="color: #007800;">$releasever</span> - <span style="color: #007800;">$basearch</span> - ATrpms
<span style="color: #007800;">baseurl</span>=http:<span style="color: #000000; font-weight: bold;">//</span>dl.atrpms.net<span style="color: #000000; font-weight: bold;">/</span>el<span style="color: #007800;">$releasever</span>-<span style="color: #007800;">$basearch</span><span style="color: #000000; font-weight: bold;">/</span>atrpms<span style="color: #000000; font-weight: bold;">/</span>stable
<span style="color: #007800;">gpgkey</span>=http:<span style="color: #000000; font-weight: bold;">//</span>atrpms.net<span style="color: #000000; font-weight: bold;">/</span>RPM-GPG-KEY.atrpms
<span style="color: #007800;">gpgcheck</span>=<span style="color: #000000;">1</span></pre></div></div>

<p>
Vérification de la présence de paquets relatifs à DRBD :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum search drbd</span>
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
<span style="color: #000000; font-weight: bold;">*</span> base: ftp.plusline.de
<span style="color: #000000; font-weight: bold;">*</span> extras: ftp.plusline.de
<span style="color: #000000; font-weight: bold;">*</span> updates: mirrors.prometeus.net
========================================= Matched: drbd =========================================
drbd.i686 : Distributed Replicated Block Device.
drbd-kmdl-2.6.32-131.0.15.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-131.12.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-131.2.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-131.4.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-131.6.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.14.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.18.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.18.2.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.24.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.29.1.el6.centos.plus.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.29.1.el6.i686.i686 : Distributed Redundant Block Device.
drbd-kmdl-2.6.32-71.7.1.el6.i686.i686 : Distributed Redundant Block Device.</pre></div></div>

<p>
Nous pouvons installer le paquet <code>drbd</code> ainsi que le module du noyau correspondant au noyau en cours. Je vérifie quel noyau j&#8217;ai sur mon système :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># uname -r</span>
2.6.32-71.29.1.el6.i686</pre></div></div>

<p>
J&#8217;installe le module correspondant :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install drbd drbd-kmdl-2.6.32-71.29.1.el6.i686.i686</span></pre></div></div>

<p>
Il faut charger le nouveau module dans le noyau :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># modprobe drbd</span></pre></div></div>

<p>
Et bien sur on veut qu&#8217;il se charge au démarrage de la machine, on ajoute donc cette ligne au fichier <code>/etc/rc.local</code>.
</p>
<h4>Configuration</h4>
<p>
La configuration de DRBD se situe sous <code>/etc/drbd.conf</code>, mais pour plus de lisibilité, ce fichier fait appel à ceux situés sous <code>/etc/drbd.d/</code>, la configuration se fait donc d&#8217;une part dans <code>global_common.conf</code> pour la configuration commune et dans un fichier <code>r0.res</code> que nous allons créer pour notre nouvelle ressource. Ce nom r0 est arbitraire.<br />
Donc pour commencer, vérifier que le fichier <code>global_common.conf</code> possède les options suivantes :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">global <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  usage-count <span style="color: #c20cb9; font-weight: bold;">yes</span>;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
common <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  net <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    protocol C;
    verify-alg sha1;
    csums-alg sha1;
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>
L&#8217;option <code>protocol C</code> signifie que la réplication s&#8217;effectue de façon synchrone. Avec ce mode de fonctionnement synchrone, l&#8217;écriture de données n&#8217;est considérée terminée que lorsque le nœud secondaire a terminé d&#8217;écrire, validant ainsi l&#8217;opération. <code>verify-alg sha1</code> <a href="http://www.drbd.org/users-guide/s-online-verify.html" title="drbd.org" target="_blank">vérifie l&#8217;intégrité des données</a> bloc par bloc entre les nœuds. <code>csums-alg sha1</code> active la synchronisation avec somme de contrôle (checksum). Comme expliqué dans la documentation, la synchronisation n&#8217;est pas la même chose que la réplication des périphériques. La seconde se fait en temps réel, c&#8217;est le fonctionnement normal de DRBD, alors que la première s&#8217;effectue lorsqu&#8217;il y a eu perte d&#8217;un des deux nœuds (pour quelque raison que ce soit) et une (re)synchronisation est nécessaire.
</p>
<p>
Il est temps de créer la vraie ressource dans un nouveau fichier <code>r0.res</code> contenant ces informations :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">resource r0 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	on mailsrv-ha1 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    	address   192.168.1.10:<span style="color: #000000;">7789</span>;
    	device    <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1;
		disk      <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>vg_storage-lv_storage;
		meta-disk internal;
  	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
  	on mailsrv-ha2 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    	address   192.168.1.11:<span style="color: #000000;">7789</span>;
    	device    <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1;
		disk      <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>vg_storage-lv_storage;
		meta-disk internal;
  	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>
Petite explication sur la configuration de cette ressource qui dans son ensemble parle d&#8217;elle-même. On définit les deux nœuds avec le mot-clé <code>on</code> suivi du nom de l&#8217;hôte. On spécifie l&#8217;IP du nœud et le port utilisé &#8211; ici 7789. Le périphérique de bloc logique est définit par <code>device</code> suivi du chemin vers celui-ci. Ensuite il faut indiquer la partition de bas niveau sur laquelle le périphérique de bloc logique se posera grace au mot-clé <code>disk</code> suivi de son chemin. <code>meta-disk internal</code> indique que la zone réservée aux données de contrôle sera sur la même partition, toujours au niveau bloc (plus d&#8217;<a href="http://www.drbd.org/users-guide/ch-internals.html" title="http://www.drbd.org/users-guide/ch-internals.html" target="_blank">informations sur ce sujet</a> sur la documentation officielle).
</p>
<p>
On voit que certaines options (presque toutes sauf l&#8217;IP) sont les mêmes, on peut donc simplifier notre fichier <code>r0.res</code> comme ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">resource r0 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	device    <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1;
    disk      <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>mapper<span style="color: #000000; font-weight: bold;">/</span>vg_storage-lv_storage;
    meta-disk internal;
	on mailsrv-ha1 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    	address   192.168.137.201:<span style="color: #000000;">7789</span>;
  	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
  	on mailsrv-ha2 <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    	address   192.168.137.203:<span style="color: #000000;">7789</span>;
  	<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<h4>Activation de la ressource</h4>
<p>
Voilà, tout est bien configuré, on peut activer la ressource. Je répète que le système de fichiers de bas niveau <code>/dev/mapper/vg_storage-lv_storage</code> doit être démonté et ne doit pas être formatté. Si tel est le cas, son contenu va de toutes façons être perdu.
</p>
<p>
On commence par créer les meta-données du périphérique :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm create-md r0</span></pre></div></div>

<p>
Si des erreurs sont retournées, c&#8217;est que le système de fichiers existe, on le détruit donc :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># dd if=/dev/zero of=/dev/mapper/vg_storage-lv_storage bs=1M count=128</span></pre></div></div>

<p>
On relance la commande de création des meta-données. Tout devrait bien se passer, on peut activer la ressource :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm up r0</span></pre></div></div>

<p>
Il faut faire de même sur l&#8217;autre nœud. Lorsque la deuxième machine est prête on initialise la première synchronisation par cette commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm primary --force r0</span></pre></div></div>

<p>
Alors que se passe-t-il? Lorsque la ressource est activée, les deux nœuds sont marquées comme secondaires, une première synchronisation est nécessaire, on va donc forcer (avec l&#8217;option <code>--force</code>) cette opération sur le nœud que l&#8217;on veut primaire.
</p>
<p>
A ce stade, il est possible de vérifier l&#8217;état de DRBD par la commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbd-overview </span>
  <span style="color: #000000;">1</span>:r0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>  SyncSource Primary<span style="color: #000000; font-weight: bold;">/</span>Secondary UpToDate<span style="color: #000000; font-weight: bold;">/</span>Inconsistent C r----- 
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">&gt;</span>....................<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #c20cb9; font-weight: bold;">sync</span><span style="color: #ff0000;">'ed:  0.6% (53340/53652)M</span></pre></div></div>

<p>
On voit que la ressource est en cours de synchronisation, suivant la taille de la partition, cela peut être long. On a plus d&#8217;info avec :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cat /proc/drbd </span>
version: 8.4.0 <span style="color: #7a0874; font-weight: bold;">&#40;</span>api:<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>proto:<span style="color: #000000;">86</span>-<span style="color: #000000;">100</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
GIT-hash: 28753f559ab51b549d16bcf487fe625d5919c49c build by gardner<span style="color: #000000; font-weight: bold;">@</span>, <span style="color: #000000;">2011</span>-08-<span style="color: #000000;">26</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">24</span>:<span style="color: #000000;">30</span>
&nbsp;
 <span style="color: #000000;">1</span>: cs:SyncSource ro:Primary<span style="color: #000000; font-weight: bold;">/</span>Secondary ds:UpToDate<span style="color: #000000; font-weight: bold;">/</span>Inconsistent C r-----
    ns:<span style="color: #000000;">1482108</span> nr:<span style="color: #000000;">0</span> dw:<span style="color: #000000;">0</span> dr:<span style="color: #000000;">1487544</span> al:<span style="color: #000000;">0</span> bm:<span style="color: #000000;">90</span> lo:<span style="color: #000000;">0</span> pe:<span style="color: #000000;">2</span> ua:<span style="color: #000000;">5</span> ap:<span style="color: #000000;">0</span> ep:<span style="color: #000000;">1</span> wo:b oos:<span style="color: #000000;">53461324</span>
	<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">&gt;</span>....................<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #c20cb9; font-weight: bold;">sync</span><span style="color: #ff0000;">'ed:  2.7% (52208/53652)M
	finish: 0:41:59 speed: 21,216 (22,100) K/sec</span></pre></div></div>

<p>
On voit que le processus de synchronisation est en cours (<code>cs:SyncSource</code>), que le nœud primaire est à jour mais le secondaire est encore dans un étant incohérent (<code>ds:UpToDate/Inconsistent</code>).<br />
Il n&#8217;est pas nécessaire d&#8217;attendre la fin de la synchronisation pour créer le système de fichiers, donc allons-y, créons un système de fichiers <code>ext4</code> et montons-le :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mkfs.ext4 <span style="color: #660033;">-L</span> storage <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>storage
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>drbd1 <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>storage</pre></div></div>

<p>
Le système de fichiers est maintenant utilisable et va être répliqué en temps réel. On peut vérifier l&#8217;état de synchronisation :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cat /proc/drbd </span>
version: 8.4.0 <span style="color: #7a0874; font-weight: bold;">&#40;</span>api:<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>proto:<span style="color: #000000;">86</span>-<span style="color: #000000;">100</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
GIT-hash: 28753f559ab51b549d16bcf487fe625d5919c49c build by gardner<span style="color: #000000; font-weight: bold;">@</span>, <span style="color: #000000;">2011</span>-08-<span style="color: #000000;">26</span> <span style="color: #000000;">23</span>:<span style="color: #000000;">24</span>:<span style="color: #000000;">30</span>
&nbsp;
 <span style="color: #000000;">1</span>: cs:Connected ro:Primary<span style="color: #000000; font-weight: bold;">/</span>Secondary ds:UpToDate<span style="color: #000000; font-weight: bold;">/</span>UpToDate C r-----
    ns:<span style="color: #000000;">56499808</span> nr:<span style="color: #000000;">36</span> dw:<span style="color: #000000;">1557816</span> dr:<span style="color: #000000;">54944894</span> al:<span style="color: #000000;">422</span> bm:<span style="color: #000000;">3354</span> lo:<span style="color: #000000;">0</span> pe:<span style="color: #000000;">0</span> ua:<span style="color: #000000;">0</span> ap:<span style="color: #000000;">0</span> ep:<span style="color: #000000;">1</span> wo:b oos:<span style="color: #000000;">0</span></pre></div></div>

<p>
Voilà, c&#8217;est fini, notre resource est connectée (<code>cs:Connected</code>), on est sur le noeud primaire (<code>ro:Primary/Secondary</code>) et elle est à jour des deux cotés (<code>ds:UpToDate/UpToDate</code>). Avec <code>drbd-overview</code> on obtient plus d&#8217;informations, en particulier sur la taille du stockage :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbd-overview </span>
  <span style="color: #000000;">1</span>:r0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>  Connected Primary<span style="color: #000000; font-weight: bold;">/</span>Secondary UpToDate<span style="color: #000000; font-weight: bold;">/</span>UpToDate C r----- <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>storage ext4 52G 730M 49G <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">%</span></pre></div></div>

<p>
Toute modification sur la ressource peut se faire en temps réel, après un changement, il faut copier le fichier de configuration sur le second nœud et opérer cette commande (sur les deux nœuds) :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm adjust r0</span></pre></div></div>

<h4>Vérification en ligne automatique</h4>
<p>
Nous avons vu que l&#8217;option <code>verify-alg</code> permet de vérifier l&#8217;intégrité des données en ligne, pour faire ce test il suffit d&#8217;invoquer la commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># drbdadm verify r0</span></pre></div></div>

<p>
DRBD commence alors la vérification et s&#8217;il détecte des blocs non synchronisés, il les marque comme tel et l&#8217;inscrit dans le log du noyau. Il est bon d&#8217;automatiser cette tâche en l&#8217;ajoutant dans le <code>cron</code>. Pour ce faire, ajouter un fichier <code>/etc/cron.d/drbd-verify</code> avec &#8211; par exemple &#8211; ce contenu :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">42</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">0</span>    root    <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>drbdadm verify r0</pre></div></div>

<p>
Par ailleurs, si des blocs non synchronisés ont été détectés, il faut les re-synchroniser comme ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">drbdadm disconnect r0
drbdadm connect r0</pre></div></div>

<h4>Restauration manuelle après un split-brain</h4>
<p>
Un <a href="http://fr.wikipedia.org/wiki/Split-brain" title="Wikipedia : Split-brain" target="_blank">split-brain</a> se produit lorsque pour une raison quelconque les deux nœuds se retrouvent déconnectés, lorsque la connectivité revient, DRBD détecte que les 2 nœuds sont en mode primaire, DRBD rompt alors immédiatement la connexion de réplication par sécurité. Après le split-brain, un nœud passe en mode <code>StandAlone</code> et l&#8217;autre passe soit en mode secondaire ou en <code>WFConnection</code>. Il est temps d&#8217;intervenir.
</p>
<p>
Pour repartir sans corrompre les données &#8211; pour que le primaire sache qu&#8217;il est &laquo;&nbsp;maitre&nbsp;&raquo; &#8211; il faut aller sur le (futur) nœud secondaire et le déclarer comme tel, puis on connecte la ressource en lui disant d&#8217;oublier ses données :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">drbdadm secondary r0
drbdadm connect <span style="color: #660033;">--discard-my-data</span> r0</pre></div></div>

<p>
On passe sur le primaire que l&#8217;on connecte et que l&#8217;on déclare primaire :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">drbdadm connect r0
drbdadm primary r0</pre></div></div>

<p>
Notre ressource <code>r0</code> est repartie.
</p>
<h4>Tester la réplication</h4>
<p>
Il est temps de tester un peu le fonctionnement de la réplication. Créons un fichier quelconque de 500Mo sous <code>/mnt/storage</code> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># dd if=/dev/zero of=/mnt/storage/toto.dat bs=10M count=50</span>
<span style="color: #000000;">50</span>+<span style="color: #000000;">0</span> records <span style="color: #000000; font-weight: bold;">in</span>
<span style="color: #000000;">50</span>+<span style="color: #000000;">0</span> records out
<span style="color: #000000;">524288000</span> bytes <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">524</span> MB<span style="color: #7a0874; font-weight: bold;">&#41;</span> copied, <span style="color: #000000;">31.4183</span> s, <span style="color: #000000;">16.7</span> MB<span style="color: #000000; font-weight: bold;">/</span>s
<span style="color: #666666; font-style: italic;"># ls -l /mnt/storage/</span>
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> root root <span style="color: #000000;">524288000</span> Sep <span style="color: #000000;">22</span> <span style="color: #000000;">11</span>:04 toto.dat</pre></div></div>

<p>
Celui-ci devrait maintenant exister également sur <code>centos-ha2</code>, pour le vérifier il faut suivre les étapes suivantes, sur le primaire : démonter le système de fichiers, le passer en secondaire, et sur le secondaire : le passer en primaire et monter le système de fichiers. Cela donne :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># umount /mnt/storage</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha1 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># drbdadm secondary r0</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha2 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># drbdadm primary r0</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha2 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># mount /dev/drbd1 /mnt/storage</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>centos-ha2 ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ls -l /mnt/storage</span>
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> root root <span style="color: #000000;">524288000</span> Sep <span style="color: #000000;">22</span> <span style="color: #000000;">11</span>:04 toto.dat</pre></div></div>

<p>
Tout est parfait, même si cela semble un peu long. Il ne faut pas oublier que le système de fichiers sur le nœud secondaire n&#8217;est pas accessible en l&#8217;état (il n&#8217;est d&#8217;ailleurs pas monté). Dans un environnement de production, la manipulation est un peu fastidieuse, c&#8217;est pourquoi il vaut mieux utiliser un CRM (Cluster Resource management) &#8211; comme <a href="http://www.clusterlabs.org/wiki/Pacemaker" title="clusterlabs.org" target="_blank">Pacemaker</a> &#8211; qui fera ce travail automatiquement. Ce sera l&#8217;objet d&#8217;un prochain article.
</p>
<p style="text-align:right">
^.^
</p>
<hr />
<p><strong>Ressources :</strong></p>
<ul>
<li><a href="http://www.drbd.org/users-guide/drbd-users-guide.html" title="drbd.org" target="_blank">The DRBD User&#8217;s Guide</a></li>
<li><a href="http://fr.wikipedia.org/wiki/DRBD" title="Wikipedia : DRBD" target="_blank">Wikipedia : DRBD</a></li>
<li><a href="http://www.centos.org/" title="centos.org" target="_blank">CentOS 6</a></li>
<li><a href="http://atrpms.net/" title="atRPMS" target="_blank">Dépôt atRPMS</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/09/drbd-centos-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajouter le support TLS à Postfix et Dovecot</title>
		<link>http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix-et-dovecot/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ajouter-le-support-tls-a-postfix-et-dovecot</link>
		<comments>http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix-et-dovecot/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 13:16:57 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[mailserver]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[smtp]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[tls]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=858</guid>
		<description><![CDATA[TLS (qui s&#8217;appelait SSL avant 2001) signifie Transport Layer Security. Il s&#8217;agit d&#8217;une couche qui crypte la communication entre deux hôtes. En utilisant SMTP AUTH (voir cet article) avec les mécanismes PLAIN ou LOGIN, le nom d&#8217;utilisateur ainsi que le mot de passe transitent en clair et sont exposés à quiconque sniffe le réseau. C&#8217;est [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/05/Messagerie.png" alt="" title="" class="floatleft" /><a href="http://fr.wikipedia.org/wiki/Transport_Layer_Security" title="Wikipedia TLS" target="_blank">TLS</a> (qui s&#8217;appelait <a href="http://fr.wikipedia.org/wiki/Secure_Sockets_Layer" title="Wikipedia SSL" target="_blank">SSL</a> avant 2001) signifie Transport Layer Security. Il s&#8217;agit d&#8217;une couche qui crypte la communication entre deux hôtes. En utilisant <a href="http://fr.wikipedia.org/wiki/SMTP_AUTH" title="Wikipedia SMTP AUTH" target="_blank">SMTP AUTH</a> (<a href="http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/" title="Postfix SASL avec Dovecot">voir cet article</a>) avec les mécanismes PLAIN ou LOGIN, le nom d&#8217;utilisateur ainsi que le mot de passe transitent en clair et sont exposés à quiconque sniffe le réseau. C&#8217;est là que la couche TLS peut résoudre ce point faible.<br />
Pour utiliser le cryptage, il faut un <a href="http://fr.wikipedia.org/wiki/Certificat_%C3%A9lectronique" title="Wikipedia Certificat électronique" target="_blank">certificat</a> qui valide notre authenticité pour le client qui va se connecter au serveur de messagerie. Normalement un tel certificat doit s&#8217;acheter auprès d&#8217;une autorité compétente comme <a href="http://www.thawte.com/" title="Thawte" target="_blank">Thawte</a> ou <a href="http://www.verisign.com/" title="Verisign" target="_blank">Verisign</a>. L&#8217;autre solution est d&#8217;auto-signer son certificat, c&#8217;est bien entendu gratuit, mais n&#8217;étant pas <em>officiel</em> (mais reste légal!), les utilisateurs du serveur de messagerie devront vous faire confiance en acceptant ce certificat &laquo;&nbsp;maison&nbsp;&raquo;. Cette soluton est décrite ci-dessous.
</p>
<p><span id="more-858"></span></p>
<h4>Création du certificat</h4>
<p>
La création du certificat s&#8217;effectue avec la commande <code>openssl</code>, comme suit :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># openssl req -new -x509 -days 3650 -nodes -out /etc/postfix/mailserver.pem -keyout /etc/postfix/mailserver.pem</span></pre></div></div>

<p>
C&#8217;est parti pour une série de questions, peu importe les réponses données, seul le <em>Common Name</em> est important et doit refléter le nom d&#8217;hôte du serveur, dans notre exemple : <code>mail.example.net</code>. Le certificat sera valide 10 ans (10 x 365 jours).<br />
Il faut veiller à placer les bonnes permissions sur le fichier :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># chmod 600 /etc/postfix/mailserver.pem</span></pre></div></div>

<h4>Postfix</h4>
<p>
On ajoute les bonnes directives au <code>main.conf</code> de <a href="http://www.postfix.org/" title="Postfix" target="_blank">Postfix</a>, par exemple en fin de fichier :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">smtpd_tls_key_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>mailserver.pem
smtpd_tls_cert_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>mailserver.pem
smtpd_tls_security_level = encrypt
smtpd_tls_received_header = <span style="color: #c20cb9; font-weight: bold;">yes</span>
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>urandom
smtp_tls_loglevel = <span style="color: #000000;">3</span></pre></div></div>

<p>
Redémarrage de Postfix :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postfix reload</span></pre></div></div>

<p>
Tout est en place, le serveur SMTP devrait pouvoir instantier une connexion TLS maintenant, essayons en <a href="http://fr.wikipedia.org/wiki/Telnet" title="Wikipedia telnet" target="_blank">telnet</a>, si une nouvelle ligne <code>STARTTLS</code> apparait et que le serveur répond correctement, c&#8217;est tout bon :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ telnet mail.example.net <span style="color: #000000;">25</span>
Trying 91.127.162.55...
Connected to mail.example.net.
Escape character is <span style="color: #ff0000;">'^]'</span>.
<span style="color: #000000;">220</span> mail.example.net ESMTP Postfix
EHLO localhost
<span style="color: #000000;">250</span>-mail.example.net
<span style="color: #000000;">250</span>-PIPELINING
<span style="color: #000000;">250</span>-SIZE <span style="color: #000000;">10240000</span>
<span style="color: #000000;">250</span>-VRFY
<span style="color: #000000;">250</span>-ETRN
<span style="color: #000000;">250</span>-STARTTLS
<span style="color: #000000;">250</span>-AUTH PLAIN LOGIN
<span style="color: #000000;">250</span>-AUTH=PLAIN LOGIN
<span style="color: #000000;">250</span>-ENHANCEDSTATUSCODES
<span style="color: #000000;">250</span>-8BITMIME
<span style="color: #000000;">250</span> DSN</pre></div></div>

<p>
STARTTLS est bien présent, on tape la commande STARTTLS :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">STARTTLS
<span style="color: #000000;">220</span> 2.0.0 Ready to start TLS</pre></div></div>

<p>
La serveur dit qu&#8217;il est pret, sinon revoir ses certificats, les chemins et les bonne options dans <code>main.cf</code>. Cependant il reste un petit problème de sécurité, il faut que l&#8217;authentification SMTP AUTH PLAIN ne soit disponible que lorsque l&#8217;utilisateur utilise TLS. Ainsi Postfix va effectuer le SMTP AUTH uniquement après que la couche soit TLS soit établie. Pour ce faire il suffit de rajouter cette ligne au <em>main.cf</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">smtpd_tls_auth_only = <span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>
On redémarre Postfix :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postfix reload</span></pre></div></div>

<p>
On re-telnet :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ telnet mail.example.net <span style="color: #000000;">25</span>
Trying 91.127.162.55...
Connected to mail.example.net.
Escape character is <span style="color: #ff0000;">'^]'</span>.
<span style="color: #000000;">220</span> mail.example.net ESMTP Postfix
EHLO localhost
<span style="color: #000000;">250</span>-mail.example.net
<span style="color: #000000;">250</span>-PIPELINING
<span style="color: #000000;">250</span>-SIZE <span style="color: #000000;">10240000</span>
<span style="color: #000000;">250</span>-VRFY
<span style="color: #000000;">250</span>-ETRN
<span style="color: #000000;">250</span>-STARTTLS
<span style="color: #000000;">250</span>-ENHANCEDSTATUSCODES
<span style="color: #000000;">250</span>-8BITMIME
<span style="color: #000000;">250</span> DSN</pre></div></div>

<p>
On voit que maintenant SMTP AUTH ne sera disponible qu&#8217;après avoir établit la liaison TLS (les lignes AUTH ne sont plus visibles à ce niveau).
</p>
<h4>Dovecot SSL</h4>
<p>
Au tour de Dovecot de passer en SSL. C&#8217;est très simple, nous allons utiliser le même certificat que pour Postfix. On ajoute les lignes suivantes au fichier <code>dovecot.conf</code> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">protocols = imap imaps
ssl_disable = no
<span style="color: #666666; font-style: italic;"># ssl = yes pour les versions supérieures à v1.2.beta1</span>
ssl_cert_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>postfix.pem
ssl_key_file = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>ssl<span style="color: #000000; font-weight: bold;">/</span>postfix.pem
verbose_ssl = <span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>
Un petit rappel sur les permissions du certificat qui ne doit etre accessible que par l&#8217;utilisateur root : <code>root:root 0444</code>. Autre petit point qui a son importance, on refuse désormais les connexions LOGIN à moins que TLS/SSL soit établi. Pour ce faire, on modifie cette ligne :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">disable_plaintext_auth = <span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>
On re-démarre le serveur IMAP :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service dovecot restart</span></pre></div></div>

<p>
On peut le tester :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ openssl s_client <span style="color: #660033;">-connect</span> mail.example.net:imaps
CONNECTED<span style="color: #7a0874; font-weight: bold;">&#40;</span>00000003<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">depth</span>=<span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
verify error:<span style="color: #007800;">num</span>=<span style="color: #000000;">18</span>:self signed certificate
verify <span style="color: #7a0874; font-weight: bold;">return</span>:<span style="color: #000000;">1</span>
<span style="color: #007800;">depth</span>=<span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
verify <span style="color: #7a0874; font-weight: bold;">return</span>:<span style="color: #000000;">1</span>
<span style="color: #660033;">---</span>
Certificate chain
 <span style="color: #000000;">0</span> s:<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
   i:<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #660033;">---</span>
Server certificate
<span style="color: #660033;">-----BEGIN</span> CERTIFICATE-----
MIIDojCCAwugAwIBAgIJAKn3cs1HiGLvMA0GCSqGSIb3DQEBBQUAMIGTMQswCQYD
VQQGEwJJVDEOMAwGA1UECBMFTGF6aW8xDTALBgNVBAcTBFJvbWExFzAVBgNVBAoT
DmZhYmllbmFtYW5uLmV1MRMwEQYDVQQLEwptYWlsc2VydmVyMRwwGgYDVQQDExNt
YWlsLmZhYmllbmFtYW5uLmV1MRkwFwYJKoZIhvcNAQkBFgpfQGZldWIubmV0MB4X
DTExMDgwNDEzNTY1OFoXDTIxMDgwMTEzNTY1OFowgZMxCzAJBgNVBAYTAklUMQ4w
DAYDVQQIEwVMYXppbzENMAsGA1UEBxMEUm9tYTEXMBUGA1URChMOZmFiaWVuYW1h
bm4uZXUxEzARBgNVBAsTCm1haWxzZXJ2ZXIxHDAaBgNVBAMTE21haWwuZmFiaWVu
YW1hbm4uZXUxGTAXBgkqhkiG9w0BCQEWCmZAZmV1Yi5uZXQwgZ8wDQYJKoZIhvcN
AQEBBQADgY0AMIGJAoGBAO5esAspC+j2yVIPRsSQ6aUsbR+8iS<span style="color: #000000; font-weight: bold;">/</span>u5H4LgwL8OQd5
799lXzG9hWmn0uMR+6SutjgDFbDL+<span style="color: #c20cb9; font-weight: bold;">w</span>+zdXzGZ2UQi6OjKjKo+L<span style="color: #000000; font-weight: bold;">/</span>pwEkdokRRIpNw
mhyIum+F+7XcfP1KHdVQu85cDphd+rhPDkDtYNUMD8Nd8ClmaftTeVVaV5T1MEGt
AgMBAAGjgfswfafaHQYDVR0OBBYEFKCxvAc+P1gk+ILQWc3NXvdxNxYRMIHIBgNV
HSMEgcAwgb2AFKCxvAc+P1gk+ILQWc3nXvdxNxYRoYGZpIGWMIGTMQswCQYDVQQG
EwJJVDEOMAwGA1UECBMFTGF6aW8xDTALBgNVBAcTBFJvbWEXFzAVBgNVBAoTDmZh
YmllbmFtYW5uLmV1MRMwEQYDVQQLEwptYWlsc2VydmVyMRwwGgYDVQQDExNtYWls
LmZhYmllkikiFtYW5uLmV1MRkwFwYJKoZIhvcNAQkBFgpmQGZldWIuV0ggkAqfdy
zUeIYu8wDAYDVR0TBAUwAwEB<span style="color: #000000; font-weight: bold;">/</span>zANBgkqhdiG9w0BAQUFAAOBgQAyESbxZh8WID39
Qwr<span style="color: #000000; font-weight: bold;">/</span>NjotqatAsKqGXCIuW5WROo+7ZVvmPoVx<span style="color: #000000; font-weight: bold;">/</span>OLvnYQnF5DzCnMF<span style="color: #000000; font-weight: bold;">/</span>9E7kuiW2feg
BmQPYT5UXU5cH2R5fBkT<span style="color: #000000; font-weight: bold;">/</span>bnIgPTEr33L75RFDWiKE4vKzvtTDneUIWxXxw+goGOz
SK3TyKQawclFSbVC9nvBixw5+<span style="color: #000000;">4</span><span style="color: #007800;">hbfg</span>==
<span style="color: #660033;">-----END</span> CERTIFICATE-----
<span style="color: #007800;">subject</span>=<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #007800;">issuer</span>=<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=IT<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lazio<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Roma<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mailserver<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mail.example.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #660033;">---</span>
No client certificate CA names sent
<span style="color: #660033;">---</span>
SSL handshake has <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #000000;">1505</span> bytes and written <span style="color: #000000;">319</span> bytes
<span style="color: #660033;">---</span>
New, TLSv1<span style="color: #000000; font-weight: bold;">/</span>SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is <span style="color: #000000;">1024</span> bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : DHE-RSA-AES256-SHA
    Session-ID: 7A7619EB698CEF9463774C06E6729F0A2CE9D9E551DD96439C00D7BA3001641D1
    Session-ID-ctx: 
    Master-Key: 89E6DA90F03046C65F4C330A9D24209D3260A4DE134EC4287D6516B344AFBE80BCAE0FDCE037177B384E2F166C17CBCE
    Key-Arg   : None
    Krb5 Principal: None
    Start Time: <span style="color: #000000;">1312960774</span>
    Timeout   : <span style="color: #000000;">300</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>sec<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    Verify <span style="color: #7a0874; font-weight: bold;">return</span> code: <span style="color: #000000;">18</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>self signed certificate<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #660033;">---</span>
<span style="color: #000000; font-weight: bold;">*</span> OK Dovecot ready.</pre></div></div>

<p>
Le serveur de messagerie est maintenant plus sécurisé avec cette couche TLS/SSL qui crypte les communications et authentifie l&#8217;identité du serveur. L&#8217;utilisation d&#8217;un cryptage à clé publique permet au client de vérifier que le serveur possède un certificat valide et ainsi ce client sait pour des utilisations ultérieures qu&#8217;il peut faire confiance à ce serveur. L&#8217;utilisateur qui se connecte est également vérifié dans ce processus.
</p>
<hr />
<h4>En complément :</h4>
<ul>
<li>Première partie : <a href="http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/"><strong>Serveur de messagerie simple avec Postfix et Dovecot</strong></a></li>
<li>Deuxième partie : <a href="http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/" title="Postfix SASL avec Dovecot"><strong>Postfix SASL avec Dovecot</strong></a></li>
<li>Troisième partie : Ajouter le support TLS à Postfix</li>
<li><a href="http://www.postfix.org/" title="Postfix" target="_blank">http://www.postfix.org/</a></li>
<li><a href="http://www.dovecot.org/" title="Dovecot" target="_blank">http://www.dovecot.org/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix-et-dovecot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postfix SASL avec Dovecot</title>
		<link>http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=postfix-sasl-avec-dovecot</link>
		<comments>http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 11:02:45 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[messagerie]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[sasl]]></category>
		<category><![CDATA[sécurité]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=838</guid>
		<description><![CDATA[L&#8217;authentification SMTP (SMTP Auth) est un mécanisme de contrôle d&#8217;accès qui permet de ne relayer que les utilisateurs autorisés, ainsi toute personne non authentifiée est rejetée. Depuis la version 2.3, Postfix supporte SMTP AUTH au travers de Dovecot SASL (introduit depuis Dovecot 1.0). Il est possible de vérifier si votre installation de Postfix est compilée [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/05/Messagerie.png" alt="" title="" class="floatleft" />L&#8217;<a href="http://fr.wikipedia.org/wiki/Internet_message_access_protocol_authentication" title="Wikipedia SMTP auth" target="_blank">authentification SMTP</a> (SMTP Auth) est un mécanisme de contrôle d&#8217;accès qui permet de ne relayer que les utilisateurs autorisés, ainsi toute personne non authentifiée est rejetée. Depuis la version 2.3, <a href="http://www.postfix.org/" title="Postfix" target="_blank">Postfix</a> supporte SMTP AUTH au travers de Dovecot <a href="http://fr.wikipedia.org/wiki/SASL" title="Wikipedia SASL" target="_blank">SASL</a> (introduit depuis Dovecot 1.0). Il est possible de vérifier si votre installation de Postfix est compilée avec le support de SASL avec la commande :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postconf -a</span></pre></div></div>

<p><span id="more-838"></span></p>
<h4>Configurer Dovecot SASL</h4>
<p>
Le server POP/IMAP <a href="http://www.dovecot.org/" title="Dovecot" target="_blank">Dovecot</a> possède bien entendu son propre système d&#8217;authentification des clients POP/IMAP. Lorsque Postfix utilise Dovecot SASL, celui-ci ré-utilise cette configuration. La communication se fait par l&#8217;intermédiaire d&#8217;un <a href="http://fr.wikipedia.org/wiki/Sockets_du_domaine_UNIX">socket Unix</a>. Le chemin vers ce socket ainsi que la liste des méthodes d&#8217;authentification proposées doivent être spécifiées dans <code>dovecot.conf</code>. Voici ce qu&#8217;il faut ajouter au fichier de configuration de Dovecot existant :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">auth default <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  mechanisms = plain <span style="color: #c20cb9; font-weight: bold;">login</span>  
  socket listen <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    client <span style="color: #7a0874; font-weight: bold;">&#123;</span>
      <span style="color: #666666; font-style: italic;"># Un socket est exporté pour pouvoir etre utilisé par un client.</span>
      <span style="color: #666666; font-style: italic;"># Ici c'est notre serveur SMTP Postfix</span>
      path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>auth-client
      mode = 0660
      user = postfix
      group = postfix
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>On relance Dovecot :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service dovecot restart</span></pre></div></div>

<h4>La partie Postfix</h4>
<p>
Maintenant il faut dire à Postfix comment utiliser SASL. Par défaut celui-ci gère du <a href="http://www.postfix.org/SASL_README.html#server_sasl" title="Postfix" target="_blank">Cyrus SASL</a>, il faut donc explicitement lui dire que l&#8217;on utilise le mécanisme de Dovecot, on renseigne le chemin vers le socket et on lui passe quelques options de sécurité. Voici la partie SASL à ajouter au <code>main.cf</code> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># On utilise le SASL de Dovecot</span>
smtpd_sasl_type = dovecot
<span style="color: #666666; font-style: italic;"># Chemin vers le socket Unix</span>
smtpd_sasl_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>auth-client
<span style="color: #666666; font-style: italic;"># On active le SASL</span>
smtpd_sasl_auth_enable = <span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #666666; font-style: italic;"># Quelques options de sécurité assez parlantes</span>
smtpd_recipient_restrictions =  permit_mynetworks,
    permit_sasl_authenticated, reject_unauth_destination
<span style="color: #666666; font-style: italic;"># Ceci assure une compatibilité avec d'anciens clients (Outlook par ex.)</span>
broken_sasl_auth_clients = <span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #666666; font-style: italic;"># Pas de connexions anonymes</span>
smtpd_sasl_security_options = noanonymous</pre></div></div>

<p>On re-charge Postfix :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postfix reload</span></pre></div></div>

<h4>Test de la configuration</h4>
<p>
La configuration est terminée, il est temps de tester le bon fonctionnement du SMTP Auth en <a href="http://fr.wikipedia.org/wiki/Telnet" title="Wikipedia telnet" target="_blank">telnet</a>:
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ telnet mail.example.net <span style="color: #000000;">25</span>
Trying 90.112.151.15...
Connected to mail.example.net.
Escape character is <span style="color: #ff0000;">'^]'</span>.
<span style="color: #000000;">220</span> mail.example.net ESMTP Postfix
EHLO localhost
<span style="color: #000000;">250</span>-mail.example.net
<span style="color: #000000;">250</span>-PIPELINING
<span style="color: #000000;">250</span>-SIZE <span style="color: #000000;">10240000</span>
<span style="color: #000000;">250</span>-VRFY
<span style="color: #000000;">250</span>-ETRN
<span style="color: #000000;">250</span>-AUTH PLAIN LOGIN
<span style="color: #000000;">250</span>-AUTH=PLAIN LOGIN
<span style="color: #000000;">250</span>-ENHANCEDSTATUSCODES
<span style="color: #000000;">250</span>-8BITMIME
<span style="color: #000000;">250</span> DSN</pre></div></div>

<p>
On voit les deux lignes AUTH indiquant que le SASL est pris en compte. Pourquoi deux lignes? La deuxième avec le signe égal est pour la compatibilité avec les anciens clients (option : <code>broken_sasl_auth_clients = yes</code>).
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">MAIL FROM:<span style="color: #000000; font-weight: bold;">&lt;</span>lulu<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000;">250</span> 2.1.0 Ok
RCPT TO: fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #000000;">554</span> 5.7.1 <span style="color: #000000; font-weight: bold;">&lt;</span>fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net<span style="color: #000000; font-weight: bold;">&gt;</span>: Relay access denied</pre></div></div>

<p>
La connexion est refusée, il faut maintenant penser à s&#8217;authentifier avec la commande AUTH. Mais attention, en telnet il est nécessaire d&#8217;encoder le couple nom d&#8217;utilisateur/mot de passe en <a href="http://fr.wikipedia.org/wiki/Base64" title="Wikipedia base64" target="_blank">base64</a>, par exemple avec :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-ne</span> <span style="color: #ff0000;">'\000username\000password'</span> <span style="color: #000000; font-weight: bold;">|</span> openssl base64</pre></div></div>

<p>
Ce qui donne :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">AUTH PLAIN AGhvbnTHY3RAZmDiavVuKikI7hbm5uZVBAc3BjKXRuoJWsK
<span style="color: #000000;">235</span> 2.0.0 Authentication successful
RCPT TO: fabien<span style="color: #000000; font-weight: bold;">@</span>feub.net
<span style="color: #000000;">250</span> 2.1.5 Ok
DATA
<span style="color: #000000;">354</span> End data with <span style="color: #000000; font-weight: bold;">&lt;</span>CR<span style="color: #000000; font-weight: bold;">&gt;&lt;</span>LF<span style="color: #000000; font-weight: bold;">&gt;</span>.<span style="color: #000000; font-weight: bold;">&lt;</span>CR<span style="color: #000000; font-weight: bold;">&gt;&lt;</span>LF<span style="color: #000000; font-weight: bold;">&gt;</span>
Yes<span style="color: #000000; font-weight: bold;">!</span>
.
<span style="color: #000000;">250</span> 2.0.0 Ok: queued <span style="color: #c20cb9; font-weight: bold;">as</span> E72163EB1E
quit
<span style="color: #000000;">221</span> 2.0.0 Bye
Connection closed by foreign host.</pre></div></div>

<p>
Le message devrait être délivré sous peu ^.^
</p>
<hr />
<h4>En complément :</h4>
<ul>
<li>Première partie : <a href="http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/"><strong>Serveur de messagerie simple avec Postfix et Dovecot</strong></a></li>
<li>Deuxième partie : Postfix SASL avec Dovecot</li>
<li>Troisième partie : <a href="http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix/" title="Ajouter le support TLS à Postfix"><strong>Ajouter le support TLS à Postfix</strong></a></li>
<li><a href="http://www.postfix.org/" title="Postfix" target="_blank">http://www.postfix.org/</a></li>
<li><a href="http://www.dovecot.org/" title="Dovecot" target="_blank">http://www.dovecot.org/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Serveur de messagerie simple avec Postfix et Dovecot</title>
		<link>http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=serveur-de-messagerie-simple-avec-postfix-et-dovecot</link>
		<comments>http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/#comments</comments>
		<pubDate>Fri, 13 May 2011 13:37:51 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[courrier]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[imap]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[maildir]]></category>
		<category><![CDATA[mailserver]]></category>
		<category><![CDATA[mta]]></category>
		<category><![CDATA[postfix]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=796</guid>
		<description><![CDATA[Ce tutoriel aide à la mise en oeuvre d&#8217;un serveur de messagerie complet, par serveur simple, j’entends par là, pas de SSL, de MySQL et de fonctions avancées. Ces fonctions viendront par la suite dans de prochains articles. La solution proposée est à base de Postfix pour le MTA et Dovecot comme serveur IMAP. Il [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/05/Messagerie.png" alt="" title="" class="floatleft" />Ce tutoriel aide à la mise en oeuvre d&#8217;un serveur de messagerie complet, par serveur <em>simple</em>, j’entends par là, pas de <a href="http://fr.wikipedia.org/wiki/SSL">SSL</a>, de <a href="http://fr.wikipedia.org/wiki/Mysql">MySQL</a> et de fonctions <em>avancées</em>. Ces fonctions viendront par la suite dans de prochains articles. La solution proposée est à base de <a title="Postfix" href="http://www.postfix.org/">Postfix</a> pour le <a title="Wikipedia" href="http://fr.wikipedia.org/wiki/Mail_Transfer_Agent">MTA</a> et <a title="Dovecot" href="http://www.dovecot.org/">Dovecot</a> comme serveur <a title="Wikipedia" href="http://fr.wikipedia.org/wiki/IMAP">IMAP</a>.
</p>
<p>
Il gérera des boîtes aux lettres virtuelles – c’est-à-dire indépendantes des comptes <em>systèmes</em> – d’autant d’utilisateurs et de domaines que ce soit.
</p>
<p>
Pour la suite des opérations, la machine utilisée est sous <a title="fedora-fr.org" target="_blank" href="http://www.fedora-fr.org">Fedora</a>, le tutoriel pourra donc convenir aux utilisateurs de <a href="http://www.centos.org/">CentOS</a> et de <a href="http://www.redhat.com/rhel/">Red Hat</a>. On supposera qu&#8217;elle s’appelle <em>monhostname.local.mondomaine.net</em>. C&#8217;est parti ^.^
</p>
<h4>Postfix</h4>
<p>L&#8217;installation se fait naturellement avec <em>yum</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install postfix</span></pre></div></div>

<p>
Afin de préparer le terrain, il faut créer l’arborescence qui accueillera les boîtes aux lettres virtuelles et l’utilisateur/groupe de celles-ci. Pour ce faire, ajouter un utilisateur <em>vmail</em> et un groupe du même nom ayant tout deux des uid et gid non réservés, par exemple 6000. Le home de cet utilisateur sera <em>/home/vmail</em>, c’est ici que les BAL seront construites :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># groupadd -g 6000 vmail</span>
<span style="color: #666666; font-style: italic;"># useradd -d /home/vmail -m -u 6000 -g 6000 -s /dev/null vmail</span></pre></div></div>

<p>
On change les droits et le propriétaire des répertoires pour plus de sécurité :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># chmod -R 750 /home/vmail/</span>
<span style="color: #666666; font-style: italic;"># chown -R vmail:vmail /home/vmail/</span></pre></div></div>

<p>
Les fichiers de configuration Postfix se situent sous <em>/etc/postfix</em> et c’est <em>main.conf</em> qui nous intéresse. Je vais juste copier-coller le mien ci-dessous, pour plus de renseignement sur ses paramètres, voir <a title="feub.net" target="_blank" href="http://werk.feub.net/2011/01/activer-postfix-sous-mac-os-x/">cet article</a>.
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">alias_database = <span style="color: #007800;">$alias_maps</span>
alias_maps = <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = <span style="color: #c20cb9; font-weight: bold;">yes</span>
command_directory = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin
config_directory = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix
daemon_directory = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>libexec<span style="color: #000000; font-weight: bold;">/</span>postfix
data_directory = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>postfix
debug_peer_level = <span style="color: #000000;">2</span>
delay_warning_time = 4h
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailbox_transport = lmtp:unix:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>imap<span style="color: #000000; font-weight: bold;">/</span>socket<span style="color: #000000; font-weight: bold;">/</span>lmtp
mailbox_size_limit = <span style="color: #000000;">512000000</span>
mailq_path = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mailq.postfix
manpage_directory = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">man</span>
masquerade_domains = mondomaine.net
message_size_limit = <span style="color: #000000;">50000000</span>
mydestination = <span style="color: #007800;">$myhostname</span>, localhost.<span style="color: #007800;">$myhostname</span>, localhost
mydomain = mondomaine.net
myhostname = monhostname.local.mondomaine.net
mynetworks = 192.168.1.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span>, 127.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span>
myorigin = <span style="color: #007800;">$myhostname</span>
newaliases_path = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>newaliases
queue_directory = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>postfix
readme_directory = no
recipient_delimiter = +
relayhost = <span style="color: #7a0874; font-weight: bold;">&#91;</span>smtp.sfr.fr<span style="color: #7a0874; font-weight: bold;">&#93;</span>
sendmail_path = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sendmail</span>
setgid_group = postdrop
smtp_generic_maps = <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>generic
smtpd_banner = <span style="color: #007800;">$myhostname</span> ESMTP
smtpd_recipient_limit = <span style="color: #000000;">50</span>
unknown_local_recipient_reject_code = <span style="color: #000000;">550</span>
virtual_alias_maps = <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>virtual
virtual_gid_maps = static:<span style="color: #000000;">6000</span>
virtual_mailbox_base = <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vmail
virtual_mailbox_domains = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>domains
virtual_mailbox_limit = <span style="color: #000000;">512000000</span>
virtual_mailbox_maps = <span style="color: #7a0874; font-weight: bold;">hash</span>:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>user_mailboxes_path
virtual_minimum_uid = <span style="color: #000000;">6000</span>
virtual_uid_maps = static:<span style="color: #000000;">6000</span></pre></div></div>

<p>
<span style="text-decoration: underline;">Astuce</span> : Si comme moi, le serveur est sur un domaine local (monhostname.local.mondomaine.net), quelques difficultés vont être rencontrées lors de l’envoi de message vers l’extérieur, la machine de relai [smtp.sfr.fr] va refuser d’acheminer les emails car le domaine n’est pas enregistré sur la toile : <code>Sender address rejected: Domain not found</code>. Pour remédier à cela, il faut substituer l’adresse de l’émetteur en ajoutant ceci dans <em>/etc/postfix/generic</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">@</span>monhostname.local.mondomaine.net       <span style="color: #000000; font-weight: bold;">@</span>mondomaine.net</pre></div></div>

<p>On compile ce fichier avec <em>postmap</em> avant de relancer Postfix :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># postmap /etc/postfix/generic</span></pre></div></div>

<p>
Pour savoir où délivrer le courrier, le système va lire le nom des domaines virtuels gérés dans le fichier <em>domains</em> et les adresses emails ainsi que leur chemin seront dans <em>user_mailboxes_path</em>, tout deux toujours sous <em>/etc/postfix</em>. Il suffit d’ajouter des domaines séparés par des retours ligne, comme suit :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mondomaine.net
monautredomaine.com</pre></div></div>

<p>
Et pour les boîtes aux lettres virtuelles :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tutu<span style="color: #000000; font-weight: bold;">@</span>mondomaine.net mondomaine.net<span style="color: #000000; font-weight: bold;">/</span>tutu<span style="color: #000000; font-weight: bold;">/</span>
toto<span style="color: #000000; font-weight: bold;">@</span>monautredomaine.com monautredomaine.com<span style="color: #000000; font-weight: bold;">/</span>toto<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>
Noter le / (slash) de fin important pour indiquer qu&#8217;il s&#8217;agit de boîtes au format Maildir.
</p>
<p>
On ajoute un alias pour par exemple rediriger le courrier de <em>toto@monautredomaine.com</em> vers l’adresse <em>tutu@mondomaine.net</em> dans <em>user_aliases</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">toto<span style="color: #000000; font-weight: bold;">@</span>monautredomaine.com tutu<span style="color: #000000; font-weight: bold;">@</span>mondomaine.net</pre></div></div>

<p>
Et pour fignoler, on redirige le courrier de root – qui arrive sous <em>/var/mail/root</em> – vers une adresse virtuelle pour que la lecture des courriers important du système soit facilité. Ceci ce fait dans le fichier <em>/etc/aliases</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root: tutu<span style="color: #000000; font-weight: bold;">@</span>mondomaine.net</pre></div></div>

<p>
Postfix ne lit pas ce genre de fichier tel quel, il faut comme pour le fichier <em>generic</em> le compiler pour créer le fichier de base de données grâce à la commande <em>postmap</em>, comme ceci :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">postmap <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>user_mailboxes_path
postmap <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>postfix<span style="color: #000000; font-weight: bold;">/</span>user_aliases</pre></div></div>

<p>Les alias locaux eux se compilent avec la commande :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">newaliases</pre></div></div>

<p>Une fois les changements effectués, on recharge Postfix :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service postfix reload</span></pre></div></div>

<p>On peut désormais faire un petit essai d’envoi d’email :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># &quot;Email test&quot; | mail -s &quot;Test email root&quot; root</span></pre></div></div>

<p>
Le message doit arriver dans <em>/home/vmail/mondomaine.net/tutu/new/</em>, l’arborescence étant créée automatiquement par Postfix dès réception de l’email.<br />
A noter qu’il est préférable d’avoir un champ MX mondomaine.net dans vos zones DNS pour que le courrier soit bien acheminé.
</p>
<h4>Dovecot</h4>
<p>
Comme le dit <a title="lairdutemps.org" href="http://ll.lairdutemps.org/linux/howto/postfix?s=postfix">le site</a> sur lequel je me suis inspiré, recevoir du courrier c’est bien, pouvoir le lire c’est mieux. Pour cela, il faut installer Dovecot que l&#8217;on utilisera en serveur IMAP.
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install dovecot</span></pre></div></div>

<p>
Le fichier de configuration se situant sous <em>/etc/dovecot/dovecot.conf</em>, on l’édite comme suit :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># On veut des BAL IMAP</span>
protocols = imap
&nbsp;
<span style="color: #666666; font-style: italic;"># Chemin des les logs</span>
log_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot.log
info_log_path = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>dovecot-info.log
&nbsp;
<span style="color: #666666; font-style: italic;"># Je ne veux pas de SSL</span>
ssl_disable = <span style="color: #c20cb9; font-weight: bold;">yes</span>
disable_plaintext_auth = no
&nbsp;
<span style="color: #666666; font-style: italic;"># Les BAL seront au format Maildir</span>
mail_location = maildir:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n
&nbsp;
<span style="color: #666666; font-style: italic;"># Optimisations</span>
<span style="color: #007800;">dotlock_use_excl</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #007800;">maildir_copy_with_hardlinks</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Configuration de l'authentification</span>
auth_verbose = <span style="color: #c20cb9; font-weight: bold;">yes</span>
auth default <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    mechanisms = plain
    passdb passwd-file <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Chemin vers les utilisateurs dovecot (les adresses email gérées)</span>
        args = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
    userdb static <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #666666; font-style: italic;"># Chemin vers les BAL</span>
        args = <span style="color: #007800;">uid</span>=vmail <span style="color: #007800;">gid</span>=vmail <span style="color: #007800;">home</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>vmail<span style="color: #000000; font-weight: bold;">/%</span>d<span style="color: #000000; font-weight: bold;">/%</span>n<span style="color: #000000; font-weight: bold;">/</span>
    <span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>
Maintenant il faut créer les utilisateurs (adresses emails) et les mots de passes associés pour accèder aux BAL dans le fichier <em>/etc/dovecot/passwd</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;tutu@mondomaine.net:<span style="color: #780078;">`dovecotpw -p lemotdepasse`</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">passwd</span></pre></div></div>

<p>On démarre Dovecot :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service dovecot start</span></pre></div></div>

<p>
Et voilà, c’est fini! Il ne reste plus qu’à le tester. On peut commencer par essayer d’accéder à une BAL en <a title="Wikipedia" href="http://fr.wikipedia.org/wiki/Telnet">telnet</a> sur le port 143 :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ telnet monhostname.mondomaine.net <span style="color: #000000;">143</span>
Trying 127.0.0.1...
Connected to monhostname.mondomaine.net.
Escape character is <span style="color: #ff0000;">'^]'</span>.
<span style="color: #000000; font-weight: bold;">*</span> OK Dovecot ready.
<span style="color: #000000;">1</span> <span style="color: #c20cb9; font-weight: bold;">login</span> tutu<span style="color: #000000; font-weight: bold;">@</span>mondomaine.net motdepasse
&nbsp;
<span style="color: #000000;">1</span> OK Logged in.
<span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">select</span> inbox
<span style="color: #000000; font-weight: bold;">*</span> FLAGS <span style="color: #7a0874; font-weight: bold;">&#40;</span>\Answered \Flagged \Deleted \Seen \Draft<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">*</span> OK <span style="color: #7a0874; font-weight: bold;">&#91;</span>PERMANENTFLAGS <span style="color: #7a0874; font-weight: bold;">&#40;</span>\Answered \Flagged \Deleted \Seen \Draft \<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> Flags permitted.
&nbsp;
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">1</span> EXISTS
<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">0</span> RECENT
<span style="color: #000000; font-weight: bold;">*</span> OK <span style="color: #7a0874; font-weight: bold;">&#91;</span>UIDVALIDITY <span style="color: #000000;">1217314075</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> UIDs valid
&nbsp;
<span style="color: #000000; font-weight: bold;">*</span> OK <span style="color: #7a0874; font-weight: bold;">&#91;</span>UIDNEXT <span style="color: #000000;">15</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> Predicted next UID
<span style="color: #000000;">2</span> OK <span style="color: #7a0874; font-weight: bold;">&#91;</span>READ-WRITE<span style="color: #7a0874; font-weight: bold;">&#93;</span> Select completed.
&nbsp;
<span style="color: #000000;">3</span> list <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">*</span>
<span style="color: #000000; font-weight: bold;">*</span> LIST <span style="color: #7a0874; font-weight: bold;">&#40;</span>\HasNoChildren<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #ff0000;">&quot;Drafts&quot;</span>
<span style="color: #000000; font-weight: bold;">*</span> LIST <span style="color: #7a0874; font-weight: bold;">&#40;</span>\HasNoChildren<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #ff0000;">&quot;Sent&quot;</span>
<span style="color: #000000; font-weight: bold;">*</span> LIST <span style="color: #7a0874; font-weight: bold;">&#40;</span>\HasNoChildren<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #ff0000;">&quot;Trash&quot;</span>
<span style="color: #000000; font-weight: bold;">*</span> LIST <span style="color: #7a0874; font-weight: bold;">&#40;</span>\HasNoChildren<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #ff0000;">&quot;.&quot;</span> <span style="color: #ff0000;">&quot;INBOX&quot;</span>
&nbsp;
<span style="color: #000000;">3</span> OK List completed.</pre></div></div>

<p>
Si cela fonctionne, vous pouvez essayer avec un vrai client (Thunderbird, Mail.app, Claws Mail, Outlook). Sinon, il faut aller voir d&#8217;où vient le problème dans les logs sous <em>/var/log</em> et mieux vaut lire et relire les documentations (voir ci-dessous).
</p>
<hr />
<h4>En complément :</h4>
<ul>
<li>Première partie : Serveur de messagerie simple avec Postfix et Dovecot</li>
<li>Deuxième partie : <a href="http://werk.feub.net/2011/08/postfix-sasl-avec-dovecot/" title="Postfix SASL avec Dovecot"><strong>Postfix SASL avec Dovecot</strong></a></li>
<li>Troisième partie : <a href="http://werk.feub.net/2011/08/ajouter-le-support-tls-a-postfix/" title="Ajouter le support TLS à Postfix"><strong>Ajouter le support TLS à Postfix</strong></a></li>
<li><a href="http://www.postfix.org/" title="Postfix" target="_blank">http://www.postfix.org/</a></li>
<li><a href="http://www.dovecot.org/" title="Dovecot" target="_blank">http://www.dovecot.org/</a></li>
<li><a title="lairdutemps.org" href="http://ll.lairdutemps.org/linux/howto/postfix?s=postfix">lairdutemps.org</a></li>
</ul>
<hr />
<p>
Les bases de cet article à l&#8217;origine pour <a href="http://archlinux.fr/">Arch Linux</a> datent du 29 juillet 2008, c&#8217;est une sorte de re-publication un peu mise-à-jour pour Fedora et un transfert de Joomla vers WordPress.</p>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/05/serveur-de-messagerie-simple-avec-postfix-et-dovecot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sauvegarder son compte Gmail avec getmail</title>
		<link>http://werk.feub.net/2011/05/sauvegarder-son-compte-gmail-avec-getmail/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sauvegarder-son-compte-gmail-avec-getmail</link>
		<comments>http://werk.feub.net/2011/05/sauvegarder-son-compte-gmail-avec-getmail/#comments</comments>
		<pubDate>Wed, 04 May 2011 14:24:21 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[fetchmail]]></category>
		<category><![CDATA[getmail]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[google apps]]></category>
		<category><![CDATA[maildir]]></category>
		<category><![CDATA[mbox]]></category>
		<category><![CDATA[sauvegarde]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=772</guid>
		<description><![CDATA[getmail est un script en python écrit par Charles Cazabon qui permet de rapatrier les courriers d&#8217;une ou plusieurs boites aux lettres d&#8217;une façon simple (mais efficace). Selon les mots de son auteur, getmail est conçu pour être sécurisé, flexible, fiable et facile d&#8217;utilisation. Il est un remplaçant potentiel de fetchmail. Ce petit tutoriel est [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/05/gmail_red.png" alt="" class="floatleft" /><a href="http://pyropus.ca/software/getmail/">getmail</a> est un script en python écrit par Charles Cazabon qui permet de rapatrier les courriers d&#8217;une ou plusieurs boites aux lettres d&#8217;une façon simple (mais efficace). Selon les mots de son auteur, getmail est conçu pour être sécurisé, flexible, fiable et facile d&#8217;utilisation. Il est un remplaçant potentiel de <a href="http://fetchmail.berlios.de/">fetchmail</a>.
</p>
<p>
Ce petit tutoriel est fait sur une distribution <a href="http://www.centos.org/">CentOS</a> et c&#8217;est la procèdure de sauvegarde que j&#8217;utilise pour mon compte Gmail (Google Apps). La boite aux lettres de destination est de type <a href="https://secure.wikimedia.org/wikipedia/fr/wiki/Maildir">Maildir</a>, c&#8217;est-à-dire que chaque courrier est dans un fichier unique contrairement à <a href="https://secure.wikimedia.org/wikipedia/fr/wiki/Mbox">Mbox</a> qui place tous les courriers dans un fichier unique.
</p>
<p><span id="more-772"></span></p>
<h4>Installation de getmail</h4>
<p>
Choisissez votre gestionnaire de paquets préféré, pour les habitués des distributions à base de Red Hat, ce sera <em>yum</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install getmail</span></pre></div></div>

<h4>Création des répertoires</h4>
<p>
Le script ne crée pas par lui-même les répertoires et fichiers nécessaires au bon fonctionnement de getmail, il faut donc les ajouter à la main. On commence par l&#8217;arborescence de type Maildir qui accueillera les emails :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> ~<span style="color: #000000; font-weight: bold;">/</span>Maildir<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>new,tmp,cur<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>
Je ne m&#8217;attarde pas sur les trois répertoires <em>cur</em>, <em>tmp</em> et <em>new</em>, c&#8217;est l&#8217;arborescence de <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Maildir#Technical_operation">fonctionnement de Maildir</a>. Ensuite, il faut créer le répertoire qui contiendra le fichier de configuration et les logs de getmail :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>.getmail
$ <span style="color: #c20cb9; font-weight: bold;">vim</span> ~<span style="color: #000000; font-weight: bold;">/</span>.getmail<span style="color: #000000; font-weight: bold;">/</span>gmailrc
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">700</span> ~<span style="color: #000000; font-weight: bold;">/</span>.getmail</pre></div></div>

<h4>Configuration</h4>
<p>
Voici mon fichier de configuration pour sauvegarder un compte <a href="http://www.google.com/apps/">Google Apps</a> en utilisant IMAP :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>retriever<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">type</span> = SimpleIMAPSSLRetriever
server = imap.gmail.com
mailboxes = <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;[Gmail]/All Mail&quot;</span>,<span style="color: #7a0874; font-weight: bold;">&#41;</span>
username = nom<span style="color: #000000; font-weight: bold;">@</span>domaine.net
password = mot_de_passe
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>destination<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">type</span> = Maildir
path = ~<span style="color: #000000; font-weight: bold;">/</span>Maildir<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>options<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #666666; font-style: italic;"># Mode verbeux</span>
<span style="color: #666666; font-style: italic;"># 0 : n'affiche que les warnings et les erreurs</span>
<span style="color: #666666; font-style: italic;"># 1 : affiche les notifications de récupération et de suppression de messages</span>
<span style="color: #666666; font-style: italic;"># 2 : toutes les actions</span>
verbose = <span style="color: #000000;">2</span>
message_log = ~<span style="color: #000000; font-weight: bold;">/</span>.getmail<span style="color: #000000; font-weight: bold;">/</span>gmail.log
&nbsp;
<span style="color: #666666; font-style: italic;"># ne récupére que les nouveaux messages</span>
<span style="color: #666666; font-style: italic;"># idéal pour de la sauvegarde régulière</span>
read_all = <span style="color: #c20cb9; font-weight: bold;">false</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># n'altère pas les messages</span>
delivered_to = <span style="color: #c20cb9; font-weight: bold;">false</span>
received = <span style="color: #c20cb9; font-weight: bold;">false</span></pre></div></div>

<h4>Lancement du script</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ getmail <span style="color: #660033;">-r</span> ~<span style="color: #000000; font-weight: bold;">/</span>.getmail<span style="color: #000000; font-weight: bold;">/</span>gmailrc</pre></div></div>

<p>
Le script commence le rapatriement des messages et les place dans l&#8217;arborescence Maildir.
</p>
<p>
<strong>Note</strong> : Google n&#8217;autorise le transfert que d&#8217;un nombre limité de messages à la fois, si votre boite aux lettres est assez importante il faut relancer cette commande plusieurs fois, car seuls les nouveaux messages sont récupérés, ou alors le faire de façon automatisée (voir ci-dessous).
</p>
<h4>Automatisation</h4>
<p>
Afin d&#8217;automatiser cette sauvegarde, un job peut être ajouté dans le <a href="https://secure.wikimedia.org/wikipedia/fr/wiki/Cron">cron</a>. L&#8217;option <em>-q</em> rend l&#8217;opération silentieuse, sauf pour les erreurs :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Le script est lancé à la 7ème minute de chaque heure ^.^</span>
<span style="color: #000000;">7</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>getmail <span style="color: #660033;">-q</span> <span style="color: #660033;">-r</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>.getmail<span style="color: #000000; font-weight: bold;">/</span>getmailrc</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/05/sauvegarder-son-compte-gmail-avec-getmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Créer un dépôt SVN local</title>
		<link>http://werk.feub.net/2011/04/creer-un-depot-svn-local/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creer-un-depot-svn-local</link>
		<comments>http://werk.feub.net/2011/04/creer-un-depot-svn-local/#comments</comments>
		<pubDate>Fri, 15 Apr 2011 15:43:42 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[commit]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[revisions]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[versions]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=755</guid>
		<description><![CDATA[Subversion, désormais Apache Subversion est un système de gestion de versions, celui-ci permet d&#8217;historiser les modifications effectuées sur des fichiers afin de pouvoir revenir sur des versions anciennes. Bien que très utilisé pour le développement, Subversion &#8211; en bref SVN &#8211; ne se limite pas à cela et peut fonctionner pour n&#8217;importe quel type d&#8217;utilisation [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/04/svn_logo.png" alt="" class="floatleft" />Subversion, désormais <a href="http://fr.wikipedia.org/wiki/Apache_Subversion">Apache Subversion</a> est un <a href="http://fr.wikipedia.org/wiki/Syst%C3%A8me_de_gestion_de_versions">système de gestion de versions</a>, celui-ci permet d&#8217;historiser les modifications effectuées sur des fichiers afin de pouvoir revenir sur des versions anciennes. Bien que très utilisé pour le développement, Subversion &#8211; en bref SVN &#8211; ne se limite pas à cela et peut fonctionner pour n&#8217;importe quel type d&#8217;utilisation (documents, images, etc), il faut juste garder à l&#8217;esprit que SVN est principalement fait pour gérer des fichiers dont le contenu évolue dans le temps. Par exemple, pour simplement partager des photos ou de la musique, SVN ne serait pas vraiment approprié car un fichier photo ou musical ne changent en principe pas dans le temps, alors qu&#8217;une lettre type, une documentation en cours ou des fichiers de développement bougent sans cesse et il est possible d&#8217;avoir besoin de revenir sur d&#8217;anciennes versions.
</p>
<p>
Cette article explique comment mettre en place un dépôt SVN pour les fichiers d&#8217;un site web. Le tutoriel est assez global, mais pour information il a été réalisé sur une Fedora 14.
</p>
<h4>Fonctionnement</h4>
<p>
Voici briévement comment fonctionne SVN. C&#8217;est un système de fichiers virtuels, on ajoute, édite, supprime des fichiers ou répertoires comme dans un système de fichiers traditionnel, mais tout se passe <em>en interne</em>, les différentes révisions des fichiers ne sont pas vraiment physiquement présentes. Pour mettre en pratique ce tutoriel, nous allons tout d&#8217;abord créer un dépôt (repository) où toute la gestion sera faite. Puis, dans un second temps nous allons importer un projet existant pour qu&#8217;il soit géré par SVN et c&#8217;est après que la magie s&#8217;opère ^.^
</p>
<p><span id="more-755"></span></p>
<h4>Création d&#8217;un dépôt local</h4>
<p>
Subversion possède deux commandes principales, l&#8217;une d&#8217;administration <em>svnadmin</em> et la commande de gestion <em>svn</em>. Pour créer un nouveau dépôt <em>svn_projet</em>, nous utilisons la première :
</p>
<pre>
$ svnadmin create --fs-type fsfs /chemin/depot/svn_projet
</pre>
<p>
Un nouveau dossier <em>svn_projet</em> est crée, voici son contenu :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> svn_projet<span style="color: #000000; font-weight: bold;">/</span>
total <span style="color: #000000;">368</span>
drwxr-xr-x  <span style="color: #000000;">2</span> fabien subversion   <span style="color: #000000;">4096</span> Apr  <span style="color: #000000;">8</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">52</span> conf
drwxr-sr-x  <span style="color: #000000;">6</span> fabien subversion   <span style="color: #000000;">4096</span> Apr  <span style="color: #000000;">8</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">52</span> db
<span style="color: #660033;">-r--r--r--</span>  <span style="color: #000000;">1</span> fabien subversion      <span style="color: #000000;">2</span> Apr  <span style="color: #000000;">8</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">52</span> format
drwxr-xr-x  <span style="color: #000000;">2</span> fabien subversion   <span style="color: #000000;">4096</span> Apr  <span style="color: #000000;">8</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">52</span> hooks
drwxr-xr-x  <span style="color: #000000;">2</span> fabien subversion   <span style="color: #000000;">4096</span> Apr  <span style="color: #000000;">8</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">52</span> locks
<span style="color: #660033;">-rw-r--r--</span>  <span style="color: #000000;">1</span> fabien subversion    <span style="color: #000000;">229</span> Apr  <span style="color: #000000;">8</span> <span style="color: #000000;">11</span>:<span style="color: #000000;">52</span> README.txt</pre></div></div>

<p>
Il est rare d&#8217;aller voir les fichiers à l&#8217;intérieur du dépôt et il n&#8217;est pas recommandé d&#8217;y toucher. Voyons les informations sur notre nouveau dépôt :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> info <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet<span style="color: #000000; font-weight: bold;">/</span>
Path: svn_projet
URL: <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet
Repository Root: <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet
Repository UUID: d9d451c0-72b9-<span style="color: #000000;">4830</span>-93bf-3f8829278afe
Revision: <span style="color: #000000;">0</span>
Node Kind: directory
Last Changed Rev: <span style="color: #000000;">0</span>
Last Changed Date: <span style="color: #000000;">2011</span>-04-08 <span style="color: #000000;">11</span>:<span style="color: #000000;">52</span>:00 +0200 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Fri, 08 Apr <span style="color: #000000;">2011</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>
On peut voir que la syntaxe pour interroger ce dépôt commence par <code>file://</code> pour une gestion locale. Ceci pourrait etre remplacé par <code>http://</code>,  <code>ssh://</code>, <code>svn://</code> ou <code>svn+ssh://</code> pour un dépôt distant. Pour l&#8217;exemple, nous partons avec un projet tout simple composé d&#8217;un fichier <em>index.html</em> et d&#8217;un fichier <em>style.css</em> dans un répertoire <em>css</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tree</span> <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>projet<span style="color: #000000; font-weight: bold;">/</span>web
<span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>projet<span style="color: #000000; font-weight: bold;">/</span>web<span style="color: #000000; font-weight: bold;">/</span>
├── css
│   └── style.css
└── index.html
&nbsp;
<span style="color: #000000;">1</span> directory, <span style="color: #000000;">2</span> files</pre></div></div>

<p>
Nous allons maintenant importer les fichiers <em>non encore gérés par SVN</em> dans le dépôt, ceci se fait avec la commande <em>svn import</em>. Je ne vais pas m&#8217;attarder là-dessus, mais par convention, il est bon de créer 3 répertoires dans notre dépôt : <em>trunk</em>, <em>tags</em> et <em>branches</em>. Le premier sera les fichiers du projet les plus récents, il s&#8217;agit de la version de travail la plus actuelle. <em>tags</em> contiendra en général les versions historisés (version 1, version 2, etc) et <em>branches</em> représente des dérivations dans le temps de l&#8217;évolution des éléments.<br />
Assez de blabla, importons!
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> projet
$ <span style="color: #c20cb9; font-weight: bold;">svn</span> import <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>projet<span style="color: #000000; font-weight: bold;">/</span>web <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet<span style="color: #000000; font-weight: bold;">/</span>trunk <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'Initial import.'</span>
Adding         web<span style="color: #000000; font-weight: bold;">/</span>css
Adding         web<span style="color: #000000; font-weight: bold;">/</span>css<span style="color: #000000; font-weight: bold;">/</span>style.css
Adding         web<span style="color: #000000; font-weight: bold;">/</span>index.html
&nbsp;
Committed revision <span style="color: #000000;">1</span>.</pre></div></div>

<p>
Le projet est importé, celui-ci existe désormais dans le dépôt, il s&#8217;agit de la version, plus précisément de la révision 1 et un commentaire est ajouté dans le log avec l&#8217;option <em>-m</em>, sans cette option l&#8217;éditeur par défaut s&#8217;ouvrirait et il serait demandé d&#8217;écrire une petite bafouille, sans quoi, pas de <em>commit</em>. L&#8217;action <em>commit</em> permet de figer un numéro de révision et ainsi de pouvoir y revenir plus tard. Chaque <em>commit</em> incrémente le compteur.
</p>
<p>
Nous pouvons vérifier notre log :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> log <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet
<span style="color: #660033;">------------------------------------------------------------------------</span>
r1 <span style="color: #000000; font-weight: bold;">|</span> amannf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">2011</span>-04-<span style="color: #000000;">15</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">10</span>:<span style="color: #000000;">46</span> +0200 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Fri, <span style="color: #000000;">15</span> Apr <span style="color: #000000;">2011</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">1</span> line
&nbsp;
Initial import.
<span style="color: #660033;">------------------------------------------------------------------------</span></pre></div></div>

<p>
A ce stade, il faut comprendre que notre site web est géré par SVN, une première révision existe belle et bien, il est donc possible de supprimer les anciens fichiers non historisés :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>projet<span style="color: #000000; font-weight: bold;">/</span>web</pre></div></div>

<p>
On se retrouve sans rien&#8230; ou presque. Le site est connu de SVN mais nous n&#8217;avons plus de fichiers de travail, il faut alors les (re)créer avec l&#8217;option <em>checkout</em> de la commande <em>svn</em>, celle-ci permet d&#8217;extraire une version qui servira de base au futur développement.
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>travail<span style="color: #000000; font-weight: bold;">/</span>web
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>travail<span style="color: #000000; font-weight: bold;">/</span>web
$ <span style="color: #c20cb9; font-weight: bold;">svn</span> checkout <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>travail<span style="color: #000000; font-weight: bold;">/</span>web
A    trunk
A    trunk<span style="color: #000000; font-weight: bold;">/</span>css
A    trunk<span style="color: #000000; font-weight: bold;">/</span>css<span style="color: #000000; font-weight: bold;">/</span>style.css
A    trunk<span style="color: #000000; font-weight: bold;">/</span>index.html
Checked out revision <span style="color: #000000;">1</span>.</pre></div></div>

<p>
D&#8217;accord, mais pourquoi à l&#8217;étape précèdente nous avons supprimé nos fichiers pour maintenant les rajouter, car il s&#8217;agit des mêmes.. Simplement parce que désormais cette copie va être gérée par SVN, nous pouvons d&#8217;ailleurs voir qu&#8217;il y a un répertoire <em>.svn</em> à la racine de chaque répertoire et sous-répertoire de notre copie de travail. Attention à ne jamais les supprimer, au risque de passer un précieux temps à remettre sur pieds un dépôt bancal.<br />
Au passage, on peut de nouveau vérifier l&#8217;état du dépôt :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> info <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet<span style="color: #000000; font-weight: bold;">/</span>
Path: svn_projet
URL: <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet
Repository Root: <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet
Repository UUID: d9d451c0-72b9-<span style="color: #000000;">4830</span>-93bf-3f8829278afe
Revision: <span style="color: #000000;">1</span>
Node Kind: directory
Last Changed Author: amannf
Last Changed Rev: <span style="color: #000000;">1</span>
Last Changed Date: <span style="color: #000000;">2011</span>-04-08 <span style="color: #000000;">12</span>:<span style="color: #000000;">52</span>:00 +0200 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Fri, 08 Apr <span style="color: #000000;">2011</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<h4>Faire des modifications de structure</h4>
<p>
Nous allons ajouter un répertoire <em>js</em> contenant un fichier <em>fonctions.js</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>travail<span style="color: #000000; font-weight: bold;">/</span>web
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> trunk<span style="color: #000000; font-weight: bold;">/</span>js
$ <span style="color: #c20cb9; font-weight: bold;">touch</span> trunk<span style="color: #000000; font-weight: bold;">/</span>js<span style="color: #000000; font-weight: bold;">/</span>fonction.js</pre></div></div>

<p>
Le répertoire doit être pris en compte par le dépôt maintenant. Ceci ne vas pas faire un <em>commit</em> mais juste indiquer au dépôt la présence de ce nouveau dossier (et de ce qu&#8217;il contient) :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> add trunk<span style="color: #000000; font-weight: bold;">/</span>js
A         trunk<span style="color: #000000; font-weight: bold;">/</span>js
A         trunk<span style="color: #000000; font-weight: bold;">/</span>js<span style="color: #000000; font-weight: bold;">/</span>fonction.js</pre></div></div>

<p>
Notre version a évolué avec ce nouveau répertoire <em>js</em>, il est temps de faire notre premier <em>commit</em>, c&#8217;est-à-dire d&#8217;incrémenter le numéro de révision de notre site web :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'First commit.'</span>
Adding         trunk<span style="color: #000000; font-weight: bold;">/</span>js
Adding         trunk<span style="color: #000000; font-weight: bold;">/</span>js<span style="color: #000000; font-weight: bold;">/</span>fonction.js
Transmitting <span style="color: #c20cb9; font-weight: bold;">file</span> data ..
Committed revision <span style="color: #000000;">2</span>.</pre></div></div>

<p>
Voilà, nous sommes passés en révision 2 ^.^ Le principe est le même avec la suppression de fichiers/répertoires, le mot clé est &#8211; je vous le donne en mille &#8211; <em>delete</em>, par example :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> delete trunk<span style="color: #000000; font-weight: bold;">/</span>js<span style="color: #000000; font-weight: bold;">/</span>fonctions.js
D         trunk<span style="color: #000000; font-weight: bold;">/</span>js<span style="color: #000000; font-weight: bold;">/</span>fonction.js</pre></div></div>

<p>
Pour valider le changement :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'Delete fonctions.js file.'</span>
Deleting       trunk<span style="color: #000000; font-weight: bold;">/</span>js<span style="color: #000000; font-weight: bold;">/</span>fonction.js
&nbsp;
Committed revision <span style="color: #000000;">3</span>.</pre></div></div>

<p>
Et voilà la révision 3. Nous estimons que ceci va correspondre à notre première version officielle, fini la beta! C&#8217;est là qu&#8217;entre le principe des <em>tags</em>, nous allons créer un <em>tags</em> pour la version 1, c&#8217;est-à-dire faire une copie à ce stade, et le développement normal continuera sur le <em>trunk</em>. Vous avez saisi le système du <em>trunk</em> et des <em>branches</em> maintenant. Alors, dans l&#8217;ordre cela donne :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> tags
$ <span style="color: #c20cb9; font-weight: bold;">svn</span> add tags
A         tags
$ <span style="color: #c20cb9; font-weight: bold;">svn</span> copy trunk<span style="color: #000000; font-weight: bold;">/</span> tags<span style="color: #000000; font-weight: bold;">/</span>version_1.0
A         tags<span style="color: #000000; font-weight: bold;">/</span>version_1.0</pre></div></div>

<p>
Voilà, notre version 1.0 est historisée. Presque. Il manque le <em>commit</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'Tagged version 1.0.'</span> tags<span style="color: #000000; font-weight: bold;">/</span>
Adding         tags
Adding         tags<span style="color: #000000; font-weight: bold;">/</span>version_1.0
Adding         tags<span style="color: #000000; font-weight: bold;">/</span>version_1.0<span style="color: #000000; font-weight: bold;">/</span>js
Deleting       tags<span style="color: #000000; font-weight: bold;">/</span>version_1.0<span style="color: #000000; font-weight: bold;">/</span>js<span style="color: #000000; font-weight: bold;">/</span>fonction.js
Adding         tags<span style="color: #000000; font-weight: bold;">/</span>version_1.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">test</span>
&nbsp;
Committed revision <span style="color: #000000;">4</span>.</pre></div></div>

<p>
Petite vérification du log :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> log <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #660033;">------------------------------------------------------------------------</span>
r4 <span style="color: #000000; font-weight: bold;">|</span> amannf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">2011</span>-04-<span style="color: #000000;">15</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">57</span>:<span style="color: #000000;">49</span> +0200 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Fri, <span style="color: #000000;">15</span> Apr <span style="color: #000000;">2011</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">1</span> line
&nbsp;
Tagged version <span style="color: #000000;">1.0</span>.
<span style="color: #660033;">------------------------------------------------------------------------</span>
r3 <span style="color: #000000; font-weight: bold;">|</span> amannf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">2011</span>-04-<span style="color: #000000;">15</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">48</span>:<span style="color: #000000;">30</span> +0200 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Fri, <span style="color: #000000;">15</span> Apr <span style="color: #000000;">2011</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">1</span> line
&nbsp;
Delete fonctions.js file.
<span style="color: #660033;">------------------------------------------------------------------------</span>
r2 <span style="color: #000000; font-weight: bold;">|</span> amannf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">2011</span>-04-<span style="color: #000000;">15</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">41</span>:<span style="color: #000000;">28</span> +0200 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Fri, <span style="color: #000000;">15</span> Apr <span style="color: #000000;">2011</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">1</span> line
&nbsp;
First commit.
<span style="color: #660033;">------------------------------------------------------------------------</span>
r1 <span style="color: #000000; font-weight: bold;">|</span> amannf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">2011</span>-04-<span style="color: #000000;">15</span> <span style="color: #000000;">15</span>:<span style="color: #000000;">10</span>:<span style="color: #000000;">46</span> +0200 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Fri, <span style="color: #000000;">15</span> Apr <span style="color: #000000;">2011</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">1</span> line
&nbsp;
Initial import.
<span style="color: #660033;">------------------------------------------------------------------------</span></pre></div></div>

<h4>Revenir sur une ancienne version</h4>
<p>
C&#8217;est bien beau de gérer les révisions de projets, mais encore faut-il pouvoir au besoin revenir sur une ancienne version. Rien de plus simple. Le plus difficile étant de savoir où revenir, d&#8217;où la nécessité de bien documenter ses <em>commits</em> (option <em>-m</em>). Dans notre cas, je veux revenir à la version avec le fichier <em>fonctions.js</em> avant sa suppression donc, d&#8217;après notre log du point précédent, on voit qu&#8217;il faut revenir en r1 :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> <span style="color: #660033;">-r</span> <span style="color: #000000;">1</span> <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>chemin<span style="color: #000000; font-weight: bold;">/</span>depot<span style="color: #000000; font-weight: bold;">/</span>svn_projet<span style="color: #000000; font-weight: bold;">/</span>trunk <span style="color: #000000; font-weight: bold;">/</span>nouveau<span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>
A    css
A    css<span style="color: #000000; font-weight: bold;">/</span>style.css
A    index.html
Checked out revision <span style="color: #000000;">1</span>.</pre></div></div>

<p>
La révision 1 est désormais accessible sous <em>/nouveau/chemin</em>.
</p>
<h4>Conclusion</h4>
<p>
Voici une introduction par la pratique de Subversion, certe un peu rapide, mais les grands principes sont là et cela permet de se lancer dans l&#8217;aventure.</p>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/04/creer-un-depot-svn-local/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Apache et SSL, accéder à un site en https</title>
		<link>http://werk.feub.net/2011/03/apache-et-ssl-acceder-a-un-site-en-https/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apache-et-ssl-acceder-a-un-site-en-https</link>
		<comments>http://werk.feub.net/2011/03/apache-et-ssl-acceder-a-un-site-en-https/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 16:42:39 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[httpd]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[mode rewrite]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=701</guid>
		<description><![CDATA[Petit tutoriel décrivant la mise en place d&#8217;un certificat SSL pour accéder à un serveur web Apache en mode sécurisé (avec https:// à la place de http://). Ce qui suit sous-entend que le serveur Apache est fonctionnel. Comme d&#8217;habitude, ceci est fait sur une Fedora 14, mais reste général. Le module SSL devrait être installé [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2010/03/fedora-logo_64.png" alt="" title="" class="floatleft" />Petit tutoriel décrivant la mise en place d&#8217;un certificat <a href="http://fr.wikipedia.org/wiki/SSL" title="Wikipedia">SSL</a> pour accéder à un serveur web <a href="http://httpd.apache.org/" title="Apache">Apache</a> en mode sécurisé (avec https:// à la place de http://). Ce qui suit sous-entend que le serveur Apache est fonctionnel. Comme d&#8217;habitude, ceci est fait sur une <a href="http://www.fedora-fr.org/" title="Fedora France">Fedora 14</a>, mais reste général.
</p>
<p><span id="more-701"></span></p>
<p>Le module SSL devrait être installé par défaut, sinon il faut l&#8217;ajouter :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum -y install mod_ssl</span></pre></div></div>

<h4>Création de la clé</h4>
<p>
Pour accepter les requêtes SSL, Apache a besoin d&#8217;une clé pour le serveur et d&#8217;un certificat signé. Les noms de ces fichiers n&#8217;ayant pas d&#8217;importance, dans ce tutoriel, elles seront respectivement nommées <em>server.key</em> et <em>server.crt</em>. Un certificat personnel &#8211; gratuit &#8211; va ainsi être crée, pour une utilisation professionnelle, il faudrait préférer un certificat &#8211; payant &#8211; délivré par une autorité comme <a href="http://www.verisign.com/" title="Verisign">Verisign</a>. La seule différence avec une clé <em>faîte maison</em> sera un avertissement par le navigateur lors de l&#8217;accès à une ressource SSL. La sécurité est la même, que le certificat soit signé par vous même ou par un organisme. La clé va être ajoutée sous <em>/etc/pki/tls/certs</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cd /etc/pki/tls/certs</span>
<span style="color: #666666; font-style: italic;"># make server.key</span>
<span style="color: #7a0874; font-weight: bold;">umask</span> <span style="color: #000000;">77</span> ; \
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #000000;">1024</span> <span style="color: #000000; font-weight: bold;">&gt;</span> server.key
Generating RSA private key, <span style="color: #000000;">1024</span> bit long modulus
......................................................++++++
.............++++++
e is <span style="color: #000000;">65537</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>0x10001<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Enter pass phrase: <span style="color: #000000; font-weight: bold;">//</span> Entrer une pass phrase
Verifying - Enter pass phrase: <span style="color: #000000; font-weight: bold;">//</span> Vérification</pre></div></div>

<p>Il est ennuyeux de toujours saisir la pass phrase, elle est donc retirée de la clé privée :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># openssl rsa -in server.key -out server.key</span></pre></div></div>

<h4>Ajout du certificat</h4>
<p>
Pour la création du certificat, plusieurs renseignements vont être demandés afin d&#8217;être incorporés dans celui-ci, certaines informations sont toutefois facultatives :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># make server.csr</span>
<span style="color: #7a0874; font-weight: bold;">umask</span> <span style="color: #000000;">77</span> ; \
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>openssl req <span style="color: #660033;">-utf8</span> <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> server.key <span style="color: #660033;">-out</span> server.csr
&nbsp;
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter <span style="color: #ff0000;">'.'</span>, the field will be left blank.
<span style="color: #660033;">-----</span>
Country Name <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span> letter code<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>GB<span style="color: #7a0874; font-weight: bold;">&#93;</span>: FR
State or Province Name <span style="color: #7a0874; font-weight: bold;">&#40;</span>full name<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Berkshire<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Lorraine
Locality Name <span style="color: #7a0874; font-weight: bold;">&#40;</span>eg, city<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Newbury<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Ramonchamp <span style="color: #000000; font-weight: bold;">//</span> Yes<span style="color: #000000; font-weight: bold;">!</span> ;<span style="color: #7a0874; font-weight: bold;">&#125;</span>
Organization Name <span style="color: #7a0874; font-weight: bold;">&#40;</span>eg, company<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>My Company Ltd<span style="color: #7a0874; font-weight: bold;">&#93;</span>:
Organizational Unit Name <span style="color: #7a0874; font-weight: bold;">&#40;</span>eg, section<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>:
Common Name <span style="color: #7a0874; font-weight: bold;">&#40;</span>eg, your server<span style="color: #ff0000;">'s hostname) []: mondomaine.net
Email Address []: nom@mondomaine.net
Please enter the following '</span>extra<span style="color: #ff0000;">' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:</span></pre></div></div>

<p>Création du certificat pour une durée de 10 ans :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650</span>
Signature ok
<span style="color: #007800;">subject</span>=<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=FR<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=Lorraine<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">L</span>=Ramonchamp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=mondomaine<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">OU</span>=mondomaine<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=mondomaine.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">emailAddress</span>=nom<span style="color: #000000; font-weight: bold;">@</span>mondomaine.net Getting Private key</pre></div></div>

<p>On change les droits sur ces fichiers désormais importants avant de passer à la suite :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># chmod 400 server.*</span></pre></div></div>

<h4>Directives Apache</h4>
<p>
Il ne reste plus qu&#8217;à ajouter les directives Apache pour prendre en compte le SSL. Comme Fedora fait bien le boulot, ce travail est pré-mâché dans un fichier de configuration sous <code>/etc/httpd/conf.d/ssl.conf</code>. Il faut dé-commenter les lignes suivantes dans ce fichier :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DocumentRoot <span style="color: #ff0000;">&quot;/var/www/html&quot;</span> <span style="color: #000000; font-weight: bold;">//</span> Environ ligne <span style="color: #000000;">84</span>
ServerName www.mondomaine.net:<span style="color: #000000;">443</span> <span style="color: #000000; font-weight: bold;">//</span> Environ ligne <span style="color: #000000;">85</span>
SSLCertificateFile <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>pki<span style="color: #000000; font-weight: bold;">/</span>tls<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>server.crt <span style="color: #000000; font-weight: bold;">//</span> Environ ligne <span style="color: #000000;">112</span>
SSLCertificateKeyFile <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>pki<span style="color: #000000; font-weight: bold;">/</span>tls<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>server.key <span style="color: #000000; font-weight: bold;">//</span> Environ ligne <span style="color: #000000;">119</span></pre></div></div>

<p>Redémarrage d&#8217;httpd :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service httpd restart</span></pre></div></div>

<p>
C&#8217;est terminé, les pages peuvent désormais être accédées par <strong><a href="https://www.mon-domaine.net/" title="https://www.mon-domaine.net/" rel="nofollow">https://www.mon-domaine.net/</a></strong>.
</p>
<h4>Forcer la consultation des pages en https</h4>
<p>
Ce qui peut être intéressant, c&#8217;est de forcer l&#8217;accès aux pages en https uniquement, pour faire ceci on va utiliser le mode rewrite. Ajouter ce qui suit au fichier httpd.conf (préfèrable) ou dans un fichier <em>.htaccess</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">RewriteEngine On
RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>SERVER_PORT<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>^<span style="color: #000000;">443</span>$
RewriteRule ^<span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>$  https:<span style="color: #000000; font-weight: bold;">//%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>SERVER_NAME<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">/</span>admin<span style="color: #000000; font-weight: bold;">/</span>? <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">R</span>=<span style="color: #000000;">301</span>,L<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>
Après avoir redémarré Apache, on voit qu&#8217;en tapant <strong>http</strong>://www.mondonaine.net, on passe tout de suite en <strong>https</strong>://www.mondonaine.net ^.^
</p>
<p><!-- cette article m'a été copié par ce site : http://wiki.games-over.org/index.php?title=SSL_-_Activer_et_configurer_SSL_pour_Apache --></p>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/03/apache-et-ssl-acceder-a-un-site-en-https/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Utiliser rTorrent</title>
		<link>http://werk.feub.net/2011/01/utiliser-rtorrent/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=utiliser-rtorrent</link>
		<comments>http://werk.feub.net/2011/01/utiliser-rtorrent/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 10:46:58 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[rtorrent]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[torrent]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=43</guid>
		<description><![CDATA[Utilisation de rTorrent pour télécharger et partager vos fichiers]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://werk.feub.net/medias/2011/01/rtorrent_logo64.png" alt="" title="" class="floatleft" /><a title="rakshasa.no" target="_blank" href="http://libtorrent.rakshasa.no/">rTorrent</a> est un client bittorrent non graphique que j&#8217;utilise depuis plusieurs années pour sa simplicité, sa faible empreinte niveau ressources et ses possibilités de configuration poussées. Au début il peut dérouter, mais après un temps d&#8217;adaptation, on découvre toute sa souplesse et sa puissance. Il suffit simplement d&#8217;un accès <a title="Wikipedia : SSH" target="_blank" href="http://fr.wikipedia.org/wiki/SSH">SSH</a> pour pouvoir gérer ses téléchargements depuis n&#8217;importe où, très utile. Une particularité très intéressante de rTorrent est qu&#8217;il scrute le contenu d&#8217;un répertoire donné qui recevra les fichiers <em>.torrent</em>, ainsi dès qu&#8217;un nouveau torrent est ajouté dans celui-ci, le téléchargement débute automatiquement.
</p>
<p><span id="more-43"></span></p>
<h4>Installation et configuration</h4>
<p>
J&#8217;avais originellement écrit cet article pour Archlinux, donc pour cette distro, rTorrent est dans les dépôts, pacman l&#8217;installe donc sans soucis, ainsi que <a title="Wikipedia : screen" target="_blank" href="http://fr.wikipedia.org/wiki/Screen">screen</a> le multiplexeur de terminaux :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># pacman -S rtorrent screen</span></pre></div></div>

<p>
Pour du Fedora :
</p>
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install rtorrent screen</span></pre></div></div>

<p>
Ensuite, il va falloir structurer les quelques répertoires nécessaires à son bon fonctionnement. J&#8217;ai ainsi crée quatre répertoires dans mon <em>home</em> sous <em>~/bt</em> : data, completed, watch et sessions, qui respectivement serviront à stocker les fichiers en cours de téléchargement, stocker les fichiers completement téléchargés, fournir un répertoire pour les fichiers <em>.torrent</em> que rtorrent scrutera régulièrement et un répertoire pour les sessions en cours :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># mkdir -p ~/bt/{data,sessions,watch,completed}</span></pre></div></div>

<p>
Il faut maintenant créer le fichier de configuration <em>~/.rtorrent.rc</em>, voici le mien :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Limite en upload et download</span>
upload_rate = <span style="color: #000000;">30</span>
download_rate = <span style="color: #000000;">6000</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Répertoire de destination des fichiers téléchargés et des sessions</span>
directory = <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>bt<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>
session = <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>bt<span style="color: #000000; font-weight: bold;">/</span>sessions
&nbsp;
<span style="color: #666666; font-style: italic;"># Ports utilisés et diverses options</span>
port_range = <span style="color: #000000;">6881</span>-<span style="color: #000000;">6999</span>
port_random = no
check_hash = <span style="color: #c20cb9; font-weight: bold;">yes</span>
max_memory_usage = <span style="color: #000000;">268435456</span>
encryption = allow_incoming,enable_retry,prefer_plaintext
&nbsp;
<span style="color: #666666; font-style: italic;"># Répertoire de dépôt des fichiers .torrent</span>
schedule = watch_directory,<span style="color: #000000;">15</span>,<span style="color: #000000;">15</span>,<span style="color: #007800;">load_start</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>fabien<span style="color: #000000; font-weight: bold;">/</span>bt<span style="color: #000000; font-weight: bold;">/</span>watch<span style="color: #000000; font-weight: bold;">/*</span>.torrent
schedule = tied_directory,<span style="color: #000000;">15</span>,<span style="color: #000000;">15</span>,<span style="color: #007800;">start_tied</span>=
schedule = untied_directory,<span style="color: #000000;">15</span>,<span style="color: #000000;">15</span>,<span style="color: #007800;">stop_untied</span>=
&nbsp;
<span style="color: #666666; font-style: italic;"># Répertoire où déplacer les fichiers lorsqu'ils sont complets</span>
system.method.set_key = event.download.finished,move_complete,<span style="color: #ff0000;">&quot;execute=mv, <span style="color: #000099; font-weight: bold;">\
</span>-u,<span style="color: #007800;">$d</span>.get_base_path=,/home/fabien/bt/completed ; <span style="color: #000099; font-weight: bold;">\
</span>d.set_directory=/home/fabien/bt/completed&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># On envoie un email pour prévenir qu'un fichier est téléchargé</span>
system.method.set_key = event.download.finished,notify_me, \
<span style="color: #ff0000;">&quot;execute=/home/fabien/bin/rtorrent_mail.sh,<span style="color: #007800;">$d</span>.get_name=&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Ferme le torrent lorsque l'espace disque est minimal</span>
schedule = low_diskspace,<span style="color: #000000;">5</span>,<span style="color: #000000;">60</span>,<span style="color: #007800;">close_low_diskspace</span>=100M
&nbsp;
<span style="color: #666666; font-style: italic;"># Ratio de 1:1 pour les fichiers inferieurs à 500Mo, sinon ratio de 2:1</span>
ratio.min.set=<span style="color: #000000;">100</span>
ratio.upload.set=200M
ratio.max.set=<span style="color: #000000;">200</span></pre></div></div>

<p>
Je passe sur son explication, c&#8217;est assez explicite. Pour plus d&#8217;informations, se reporter à la documentation du <a title="rakshasa.no" target="_blank" href="http://libtorrent.rakshasa.no/">site de rTorrent</a>.
</p>
<p>
Pour aider au lancement du programme, voici un script bash lançant rTorrent dans un screen :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-dmS</span> rtorrent <span style="color: #c20cb9; font-weight: bold;">nice</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">15</span> rtorrent</pre></div></div>

<p>
Ce deuxième script permet de visualiser le déroulement de rTorrent (en ré-attachant le screen) :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #c20cb9; font-weight: bold;">stty</span> stop undef
<span style="color: #c20cb9; font-weight: bold;">stty</span> start undef
<span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-rd</span> bt</pre></div></div>

<p>
En ce qui me concerne, mes scripts sont sous <em>~/bin</em>, ne pas oublier de leur attribuer les droits en exécution :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>btlaunch ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>btview</pre></div></div>

<p>
Et voici un script <a title="archlinux.fr" target="_blank" href="http://wiki.archlinux.fr/howto/comprendre/demarrage#rcconf_et_rcd">rc</a> qui permet de gérer rTorrent à la sauce Archlinux et de le démarrer en tant que <a title="Wikipedia : daemon" target="_blank" href="http://fr.wikipedia.org/wiki/Daemon">daemon</a> avec la machine, <em>rtorrent</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
. <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.conf
. <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>functions
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
stat_busy <span style="color: #ff0000;">&quot;Starting rtorrent&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">su</span> fabien <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'screen -d -m -S bt rtorrent'</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
stat_fail
<span style="color: #000000; font-weight: bold;">else</span>
add_daemon rtorrent
stat_done
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">;;</span>
stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
stat_busy <span style="color: #ff0000;">&quot;Stopping rtorrent&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">killall</span> <span style="color: #660033;">-w</span> <span style="color: #660033;">-s</span> <span style="color: #000000;">2</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>rtorrent <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
stat_fail
<span style="color: #000000; font-weight: bold;">else</span>
rm_daemon rtorrent
stat_done
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">;;</span>
restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">$0</span> stop
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
<span style="color: #007800;">$0</span> start
<span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: $0 {start|stop|restart}&quot;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>
Et enfin le petit bash d&#8217;envoi de l&#8217;email en fin de téléchargement, <em>rtorrent_mail.sh</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date)</span> : $1 - Download completed.&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;[rtorrent] - Download completed : $1&quot;</span> mon<span style="color: #000000; font-weight: bold;">@</span>adresse.net</pre></div></div>

<h4>Lancement et utilisation</h4>
<p>
Voilà, c’est terminé, il ne reste plus qu’à lancer le daemon et accessoirement de visualiser l’état avec les scripts :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>btlaunch.sh
$ ~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>btview.sh</pre></div></div>

<p>
Lancement/arrêt/re-démarrage avec la commande rc :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/rc.d/rtorrent start</span>
<span style="color: #666666; font-style: italic;"># /etc/rc.d/rtorrent stop</span>
<span style="color: #666666; font-style: italic;"># /etc/rc.d/rtorrent restart</span></pre></div></div>

<p>
Mais pour voir l’évolution, il faut bien entendu ajouter des torrents, pour se faire, copier simplement les fichiers <em>.torrent</em> dans le répertoire <em>watch</em>. Et vous verrez les téléchargements débuter. Ensuite l&#8217;utilisation se fait par quelques commandes, en voici quelques unes :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">CTRL+d         Stoppe un torrent <span style="color: #7a0874; font-weight: bold;">&#40;</span>ou supprime un torrent arrêté<span style="color: #7a0874; font-weight: bold;">&#41;</span>
CTRL+q         Quitte rTorrent <span style="color: #7a0874; font-weight: bold;">&#40;</span>ferme le <span style="color: #c20cb9; font-weight: bold;">screen</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
CTRL+s         Démarre un torrent arrêté
CTRL+a puis d     Détache le <span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>rTorrent tourne toujours<span style="color: #7a0874; font-weight: bold;">&#41;</span>
a ou s ou d ou     Augmente l’upload de 1Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 5Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 50Kb<span style="color: #000000; font-weight: bold;">/</span>s
z ou x ou c     Réduit l’upload de 1Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 5Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 50Kb<span style="color: #000000; font-weight: bold;">/</span>s
A ou S ou D ou     Augmente le download de 1Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 5Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 50Kb<span style="color: #000000; font-weight: bold;">/</span>s
Z ou X ou C     Réduit le download de 1Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 5Kb<span style="color: #000000; font-weight: bold;">/</span>s ou 50Kb<span style="color: #000000; font-weight: bold;">/</span>s</pre></div></div>

<p>​</p>
<p>
<em>Cet article fut publié pour la première fois le 18 février 2008.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2011/01/utiliser-rtorrent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>freebsd : mount_nullfs</title>
		<link>http://werk.feub.net/2009/12/freebsd-mount_nullfs/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=freebsd-mount_nullfs</link>
		<comments>http://werk.feub.net/2009/12/freebsd-mount_nullfs/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 06:07:33 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[mount_nullfs]]></category>
		<category><![CDATA[nullfs]]></category>

		<guid isPermaLink="false">http://werk.feub.net/?p=261</guid>
		<description><![CDATA[Sous GNU/Linux, j&#8217;utilisais assez les mount --bind pour monter un système de fichiers à un autre endroit de l&#8217;arborescence. Ceci étant une spécificité Linux, il n&#8217;existe pas sous FreeBSD. Mais il y a nullfs qui fait à peu près la même chose. Voici comment utiliser mount_nullfs pour &#8211; par exemple &#8211; monter une sous-arborescence music [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://werk.feub.net/medias/2010/03/freebsd-logo_64.png" alt="" width="64" height="64" class="ico-float-left" />Sous GNU/Linux, j&#8217;utilisais assez les <code>mount --bind</code> pour monter un système de fichiers à un autre endroit de l&#8217;arborescence. Ceci étant une spécificité Linux, il n&#8217;existe pas sous FreeBSD. Mais il y a <a href="http://www.freebsd.org/cgi/man.cgi?query=nullfs&#038;apropos=0&#038;sektion=0&#038;manpath=FreeBSD+8.0-RELEASE&#038;format=html">nullfs</a> qui fait à peu près la même chose. Voici comment utiliser <a href="http://www.freebsd.org/cgi/man.cgi?query=mount_nullfs&#038;apropos=0&#038;sektion=0&#038;manpath=FreeBSD+8.0-RELEASE&#038;format=html">mount_nullfs</a> pour &#8211; par exemple &#8211; monter une sous-arborescence <code>music</code> sous le home de <em>toto</em> :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># mkdir /usr/home/toto/music</span>
<span style="color: #666666; font-style: italic;"># mount_nullfs /dataraid/zfsdata/music /usr/home/toto/music</span></pre></div></div>

<p>
L&#8217;arborescence <code>/dataraid/zfsdata/music</code> est désormais <em>aliasée</em> et ainsi disponible dans le <em>home</em> de <em>toto</em>. La grosse différence entre ceci et un lien symbolique est que le chemin de cette nouvelle arborescence est réellement vu à l&#8217;endroit indiqué <code>/usr/home/toto/music</code>. Ainsi :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cd /usr/home/toto/music/</span>
<span style="color: #666666; font-style: italic;"># realpath .</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>alex<span style="color: #000000; font-weight: bold;">/</span>music
<span style="color: #666666; font-style: italic;"># stat .</span>
<span style="color: #000000;">134283012</span> <span style="color: #000000;">107</span> drwxr-xr-x <span style="color: #000000;">342</span> fabien wheel <span style="color: #000000;">0</span> <span style="color: #000000;">345</span> <span style="color: #ff0000;">&quot;Dec 22 03:01:29 2009&quot;</span> <span style="color: #ff0000;">&quot;Dec 19 17:00:43 2009&quot;</span> <span style="color: #ff0000;">&quot;Dec 19 17:00:43 2009&quot;</span> <span style="color: #ff0000;">&quot;Dec  9 20:32:31 2009&quot;</span> <span style="color: #000000;">4096</span> <span style="color: #000000;">27</span> <span style="color: #000000;">0</span> .</pre></div></div>

<p>
Le <code>realpath</code> retourne bien notre système de fichiers et non celui d&#8217;origine sous <code>/dataraid/zfsdata/music</code>. <code>stat</code> quant à lui nous indique qu&#8217;il s&#8217;agit bien d&#8217;un répertoire et non d&#8217;un lien symbolique.
</p>
<p>
Pour faire ce montage (en lecture-écriture) automatiquement au démarrage dans le <code>fstab</code>, ajouter cette ligne :
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>dataraid<span style="color: #000000; font-weight: bold;">/</span>zfsdata<span style="color: #000000; font-weight: bold;">/</span>music    <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>toto<span style="color: #000000; font-weight: bold;">/</span>music nullfs  rw      <span style="color: #000000;">0</span>       <span style="color: #000000;">0</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://werk.feub.net/2009/12/freebsd-mount_nullfs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc (Feed is rejected)
Page Caching using apc
Object Caching 828/896 objects using memcached

Served from: werk.feub.net @ 2012-02-09 00:39:31 -->
