<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>~rom1v/blog</title>
 <link href="https://blog.rom1v.com/category/puf/feed/" rel="self"/>
 <link href="https://blog.rom1v.com/"/>
 <updated>2026-04-30T12:26:04+02:00</updated>
 <id>https://blog.rom1v.com/</id>
 <author>
   <name>Romain Vimont</name>
   <email>rom@rom1v.com</email>
 </author>

 
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
   
 <entry>
   <title>Chiffrer un disque dur externe (ou une clé USB) avec LUKS</title>
   <link href="https://blog.rom1v.com/2014/07/chiffrer-un-disque-dur-externe-ou-une-cle-usb-avec-luks/"/>
   <updated>2014-07-20T21:03:33+02:00</updated>
   <id>https://blog.rom1v.com/2014/07/chiffrer-un-disque-dur-externe-ou-une-cle-usb-avec-luks</id>
   <content type="html">&lt;p&gt;Un disque dur externe contenant vos données n’a pas de raisons de ne pas être
chiffré. Voici quelques commandes utiles pour l’utilisation de &lt;a href=&quot;http://fr.wikipedia.org/wiki/LUKS&quot;&gt;LUKS&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;prérequis&quot;&gt;Prérequis&lt;/h2&gt;

&lt;p&gt;Le paquet &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cryptsetup&lt;/code&gt; doit être installé :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;cryptsetup&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;initialisation&quot;&gt;Initialisation&lt;/h2&gt;

&lt;h3 id=&quot;trouver-le-disque&quot;&gt;Trouver le disque&lt;/h3&gt;

&lt;p&gt;Tout d’abord, il faut déterminer l’emplacement du disque dur dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev&lt;/code&gt;. Pour
cela, avant de le brancher, exécuter la commande :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo tail&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; /var/log/messages&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Lors du branchement du disque, plusieurs lignes similaires à celles-ci doivent
apparaître :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Jul 20 21:25:29 pc kernel: [  678.139988] sd 7:0:0:0: [sdb] 976754645 4096-byte logical blocks: (4.00 TB/3.63 TiB)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ici, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[sdb]&lt;/code&gt; signifie que l’emplacement est &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/sdb&lt;/code&gt;. Dans la suite, je
noterai cet emplacement &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/XXX&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Il est très important de ne pas se tromper d’emplacement, afin de ne pas
formater un autre disque…&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;effacer-le-disque&quot;&gt;Effacer le disque&lt;/h3&gt;

&lt;p&gt;Si des données étaient présentes sur ce disque, il est plus sûr de tout
supprimer physiquement :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo dd &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/zero &lt;span class=&quot;nv&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/dev/XXX &lt;span class=&quot;nv&quot;&gt;bs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;4K&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;em&gt;Cette commande peut prendre beaucoup de temps, puisqu’elle consiste à réécrire
physiquement tous les octets du disque dur.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;créer-la-partition-chiffrée&quot;&gt;Créer la partition chiffrée&lt;/h3&gt;

&lt;p&gt;Pour initialiser la partition chiffrée :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksFormat &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; sha256 /dev/XXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;La passphrase de déchiffrement sera demandée.&lt;/p&gt;

&lt;p&gt;Maintenant que nous avons une partition chiffrée, ouvrons-la :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksOpen /dev/XXX lenomquevousvoulez&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Cette commande crée un nouveau &lt;em&gt;device&lt;/em&gt; dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/mapper/lenomquevousvoulez&lt;/code&gt;,
contenant la version déchiffrée (en direct).&lt;/p&gt;

&lt;h3 id=&quot;formater&quot;&gt;Formater&lt;/h3&gt;

&lt;p&gt;Pour formater cette partition en &lt;a href=&quot;https://fr.wikipedia.org/wiki/Ext4&quot;&gt;ext4&lt;/a&gt; :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mkfs.ext4 /dev/mapper/lenomquevousvoulez &lt;span class=&quot;nt&quot;&gt;-L&lt;/span&gt; unlabel&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pour l’initialisation, c’est fini, nous pouvons fermer la vue déchiffrée :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksClose lenomquevousvoulez&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;montage-manuel&quot;&gt;Montage manuel&lt;/h2&gt;

&lt;p&gt;Il est possible de déchiffrer et monter la partition manuellement en ligne de commande :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksOpen /dev/XXX lenomquevousvoulez
&lt;span class=&quot;nb&quot;&gt;sudo mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /media/mydisk
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mount &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; ext4 /dev/mapper/lenomquevousvoulez /media/mydisk&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Le contenu est alors accessible dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/media/mydisk&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Pour démonter et fermer, c’est le contraire :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;umount /media/mydisk
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksClose /dev/XXX lenomquevousvoulez&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Mais c’est un peu fastidieux. Et je n’ai pas trouvé de solution pour permettre
le &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;luksOpen&lt;/code&gt; par un utilisateur (non-root) en ligne de commande.&lt;/p&gt;

&lt;h2 id=&quot;montage-semi-automatique&quot;&gt;Montage semi-automatique&lt;/h2&gt;

&lt;p&gt;Les environnement de bureau permettent parfois de monter un disque dur chiffré
simplement, avec la demande de la passphrase lors de l’ouverture du disque.
Voici ce que j’obtiens avec &lt;a href=&quot;http://www.xfce.org/&quot;&gt;XFCE&lt;/a&gt; :&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/luks/luksOpen.png&quot; alt=&quot;luksOpen&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Mais par défaut, le nom du point de montage est peu pratique : &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/media/rom/ae74bc79-9efe-4325-8b4d-63d1506fa928&lt;/code&gt;. Heureusement, il est possible de le changer. Pour cela, il faut déterminer le nom de la partition déchiffrée :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ls /dev/mapper/luks-*
/dev/mapper/luks-8b927433-4d4f-4636-8a76-06d18c09723e
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Le nom très long correspond en fait à l’UUID du disque, qui peut aussi être récupéré grâce à :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksUUID /dev/XXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;ou encore :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;blkid /dev/XXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;L’emplacement désiré, ainsi que les options qui-vont-bien, doivent être rajoutés
dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/fstab&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/dev/mapper/luks-8b927433-4d4f-4636-8a76-06d18c09723e /media/mydisk ext4 user,noauto
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ainsi, le disque sera désormais monté dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/media/mydisk&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Si en plus, nous souhaitons spécifier un nom &lt;em&gt;user-friendly&lt;/em&gt; pour la partition
déchiffrée (celui dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/mapper/&lt;/code&gt;), il faut ajouter une ligne dans
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/crypttab&lt;/code&gt; (en adaptant l’UUID) :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mydisk UUID=8b927433-4d4f-4636-8a76-06d18c09723e none luks,noauto
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Et utiliser celle-ci à la place dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/fstab&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/dev/mapper/mydisk /media/mydisk ext4 user,noauto
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;gestion-des-passphrases&quot;&gt;Gestion des passphrases&lt;/h2&gt;

&lt;p&gt;Il est possible d’utiliser plusieurs passphrases (jusqu’à 8) pour déchiffrer le
même disque.&lt;/p&gt;

&lt;p&gt;Pour en ajouter une :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksAddKey /dev/XXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pour en supprimer une :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksRemoveKey /dev/XXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pour changer une unique passphrase, il suffit d’en ajouter une nouvelle puis de
supprimer l’ancienne.&lt;/p&gt;

&lt;p&gt;Ou alors d’utiliser :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksChangeKey /dev/XXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;mais &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man cryptsetup&lt;/code&gt; dit qu’il y a un risque.&lt;/p&gt;

&lt;h2 id=&quot;état&quot;&gt;État&lt;/h2&gt;

&lt;p&gt;Pour consulter l’état d’une partition LUKS :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;cryptsetup luksDump /dev/XXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;gestion-de-len-tête&quot;&gt;Gestion de l’en-tête&lt;/h2&gt;

&lt;p&gt;L’en-tête LUKS est écrit au début du disque. L’écraser empêche définivement le
déchiffrement de la partition.&lt;/p&gt;

&lt;p&gt;Il est possible d’en faire une sauvegarde dans un fichier :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;cryptsetup luksHeaderBackup /dev/XXX &lt;span class=&quot;nt&quot;&gt;--header-backup-file&lt;/span&gt; fichier&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Et de les restaurer :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;cryptsetup luksHeaderRestore /dev/XXX &lt;span class=&quot;nt&quot;&gt;--header-backup-file&lt;/span&gt; fichier&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pour supprimer l’en-tête (et donc rendre les données définitivement
inaccessibles s’il n’y a pas de backup) :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;cryptsetup luksErase /dev/XXX&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Une fois configuré la première fois, et après les quelques modifications
pénibles pour choisir les noms pour le déchiffrement et le montage,
l’utilisation au quotidien est vraiment très simple : il suffit de rentrer la
passphrase directement à partir du navigateur de fichiers.&lt;/p&gt;
</content>
 </entry>
  
 
  
   
 <entry>
   <title>SSHFS inversé (rsshfs)</title>
   <link href="https://blog.rom1v.com/2014/06/sshfs-inverse-rsshfs/"/>
   <updated>2014-06-15T13:30:27+02:00</updated>
   <id>https://blog.rom1v.com/2014/06/sshfs-inverse-rsshfs</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;https://fr.wikipedia.org/wiki/SSHFS&quot;&gt;SSHFS&lt;/a&gt; permet de monter un répertoire d’une machine distance dans
l’arborescence locale en utilisant &lt;a href=&quot;https://fr.wikipedia.org/wiki/Secure_Shell&quot;&gt;SSH&lt;/a&gt; :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;sshfs serveur:/répertoire/distant /répertoire/local&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Mais &lt;strong&gt;comment monter un répertoire local sur une machine distante ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Une solution simple serait de se connecter en &lt;em&gt;SSH&lt;/em&gt; sur la machine distante et
d’exécuter la commande &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshfs&lt;/code&gt; classique.&lt;/p&gt;

&lt;p&gt;Mais d’abord, ce n’est pas toujours directement &lt;strong&gt;possible&lt;/strong&gt; : la machine locale
peut ne pas être accessible (non adressable) depuis la machine distante. &lt;em&gt;Ça se
contourne en créant un tunnel SSH utilisant la redirection de port distante
(option &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-R&lt;/code&gt;).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Et surtout, ce n’est pas toujours &lt;strong&gt;souhaitable&lt;/strong&gt; : cela nécessite que la clé
privée autorisée sur la machine locale soit connue de la machine distante. Or,
dans certains cas, nous ne voulons pas qu’une machine &lt;em&gt;esclave&lt;/em&gt; puisse se
connecter à notre machine &lt;em&gt;maître&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;reverse-sshfs&quot;&gt;Reverse SSHFS&lt;/h2&gt;

&lt;p&gt;En me basant sur &lt;a href=&quot;https://sourceforge.net/p/fuse/mailman/message/27034864/&quot;&gt;la commande donnée en exemple&lt;/a&gt;, j’ai donc écrit un
petit script &lt;em&gt;Bash&lt;/em&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rsshfs&lt;/code&gt;, licence &lt;a href=&quot;http://www.gnu.org/licenses/quick-guide-gplv3.fr.html&quot;&gt;GPLv3&lt;/a&gt;) qui permet le &lt;em&gt;reverse
SSHFS&lt;/em&gt; : &lt;a href=&quot;https://github.com/rom1v/rsshfs&quot;&gt;rsshfs&lt;/a&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git clone https://github.com/rom1v/rsshfs
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;rsshfs
&lt;span class=&quot;nb&quot;&gt;sudo install &lt;/span&gt;rsshfs /usr/local/bin&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;em&gt;Les paquets &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshfs&lt;/code&gt; et &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fuse&lt;/code&gt; doivent être installés sur la machine distante
(et l’utilisateur doit appartenir au groupe &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fuse&lt;/code&gt;). Le paquet
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openssh-sftp-server&lt;/code&gt; doit être installé sur la machine locale.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Son utilisation se veut similaire à celle de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshfs&lt;/code&gt; :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rsshfs /répertoire/local serveur:/répertoire/distant&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Comme avec &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshfs&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/répertoire/distant&lt;/code&gt; doit exister sur &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serveur&lt;/code&gt; et doit
être vide.&lt;/p&gt;

&lt;p&gt;Il est également possible de monter le répertoire en &lt;em&gt;lecture seule&lt;/em&gt; :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rsshfs /répertoire/local serveur:/répertoire/distant &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; ro&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Contrairement à &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshfs&lt;/code&gt;, étant donné que &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rsshfs&lt;/code&gt; agit comme un serveur, cette
commande ne retourne pas tant que le répertoire distant n’est pas démonté.&lt;/p&gt;

&lt;p&gt;Pour démonter, dans un autre terminal :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rsshfs &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; serveur:/répertoire/distant&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ou plus simplement en pressant &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl+C&lt;/code&gt; dans le terminal de la commande de
montage.&lt;/p&gt;

&lt;h2 id=&quot;amélioration&quot;&gt;Amélioration&lt;/h2&gt;

&lt;p&gt;J’ai choisi la facilité en écrivant un script indépendant qui appelle la
commande qui-va-bien.&lt;/p&gt;

&lt;p&gt;L’idéal serait d’ajouter cette fonctionnalité à &lt;a href=&quot;https://github.com/libfuse/sshfs&quot;&gt;sshfs&lt;/a&gt;
directement.&lt;/p&gt;

</content>
 </entry>
  
 
  
 
  
 
  
 
  
   
 <entry>
   <title>Duplicity : des backups incrémentaux chiffrés</title>
   <link href="https://blog.rom1v.com/2013/08/duplicity-des-backups-incrementaux-chiffres/"/>
   <updated>2013-08-14T14:59:42+02:00</updated>
   <id>https://blog.rom1v.com/2013/08/duplicity-des-backups-incrementaux-chiffres</id>
   <content type="html">&lt;p&gt;Quiconque s’&lt;a href=&quot;http://www.auto-hebergement.fr/&quot;&gt;auto-héberge&lt;/a&gt; doit maintenir un système de
sauvegarde de son serveur, permettant de tout remettre en place dans le cas d’un
crash de disque dur, d’un piratage ou d’un cambriolage.&lt;/p&gt;

&lt;h2 id=&quot;objectifs&quot;&gt;Objectifs&lt;/h2&gt;

&lt;p&gt;Il est nécessaire de sauvegarder à la fois des &lt;strong&gt;fichiers&lt;/strong&gt; (les mails, les
services hébergés, les fichiers de config…) et le contenu de &lt;strong&gt;bases de
données&lt;/strong&gt; (associées aux services hébergés).&lt;/p&gt;

&lt;p&gt;Le système de sauvegarde doit &lt;strong&gt;conserver les archives&lt;/strong&gt; durant un certain temps
(par exemple 2 mois). En effet, un piratage ou une erreur de manipulation
peuvent n’être détectés que quelques jours plus tard : il est important de
pouvoir restaurer un état antérieur.&lt;/p&gt;

&lt;p&gt;La sauvegarde doit être &lt;strong&gt;régulière&lt;/strong&gt; (par exemple quotidienne).&lt;/p&gt;

&lt;p&gt;Seule une infime partie des données étant modifiées d’un jour à l’autre, la
sauvegarde a tout intérêt à être &lt;a href=&quot;http://fr.wikipedia.org/wiki/Sauvegarde_%28informatique%29#Sauvegarde_incr.C3.A9mentielle_ou_incr.C3.A9mentale&quot;&gt;&lt;strong&gt;incrémentale&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Pour résister aux cambriolages, une sauvegarde doit être réalisée sur (au moins)
une machine distante. Il est donc préférable que ces données soient
&lt;a href=&quot;http://fr.wikipedia.org/wiki/Chiffrement&quot;&gt;&lt;strong&gt;chiffrées&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;duplicity&quot;&gt;Duplicity&lt;/h2&gt;

&lt;p&gt;Vous l’aurez compris, &lt;a href=&quot;http://duplicity.nongnu.org/&quot;&gt;&lt;em&gt;duplicity&lt;/em&gt;&lt;/a&gt; répond à tous ces besoins.&lt;/p&gt;

&lt;p&gt;Je ne vais pas expliquer tout ce qu’il sait faire, mais plutôt comment je
l’utilise et pourquoi.&lt;/p&gt;

&lt;h2 id=&quot;mes-choix-dutilisation&quot;&gt;Mes choix d’utilisation&lt;/h2&gt;

&lt;h3 id=&quot;sauvegarde-locale&quot;&gt;Sauvegarde locale&lt;/h3&gt;

&lt;p&gt;Personnellement, je n’effectue qu’une sauvegarde &lt;strong&gt;locale&lt;/strong&gt; dans une tâche
&lt;a href=&quot;http://fr.wikipedia.org/wiki/Cron&quot;&gt;&lt;em&gt;cron&lt;/em&gt;&lt;/a&gt;, c’est-à-dire que les fichiers de backups sont stockés sur le
serveur lui-même.&lt;/p&gt;

&lt;p&gt;En effet, une sauvegarde automatique vers un serveur distant, par &lt;em&gt;SSH&lt;/em&gt; par
exemple, nécessiterait une clé privée en clair sur le serveur. Cette
configuration ne résisterait pas à certains piratages : une intrusion sur le
serveur donnerait également accès aux sauvegardes, permettant à un pirate
d’effacer à la fois les données et les backups.&lt;/p&gt;

&lt;p&gt;C’est donc une autre machine, à l’initiative de la connexion, qui rapatrie les
backups. Évidemment, elle ne doit pas synchroniser localement les backups
supprimés du serveur (elle serait vulnérable à la suppression des backups par un
pirate), mais doit plutôt supprimer les anciennes sauvegardes de sa propre
initiative.&lt;/p&gt;

&lt;h3 id=&quot;chiffrement&quot;&gt;Chiffrement&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Duplicity&lt;/em&gt; utilise &lt;a href=&quot;https://fr.wikipedia.org/wiki/GNU_Privacy_Guard&quot;&gt;GPG&lt;/a&gt; pour le chiffrement, permettant :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;soit un &lt;a href=&quot;http://fr.wikipedia.org/wiki/Cryptographie_asym%C3%A9trique&quot;&gt;chiffrement asymétrique&lt;/a&gt; (une paire de clés publique/privée, la
clé privée pouvant elle-même être chiffrée par une &lt;a href=&quot;http://fr.wikipedia.org/wiki/Phrase_secr%C3%A8te&quot;&gt;passphrase&lt;/a&gt;) ;&lt;/li&gt;
  &lt;li&gt;soit un &lt;a href=&quot;http://fr.wikipedia.org/wiki/Cryptographie_sym%C3%A9trique&quot;&gt;chiffrement symétrique&lt;/a&gt; (une simple passphrase).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Le premier choix nécessite à la fois quelque chose que &lt;strong&gt;je possède&lt;/strong&gt; (la clé,
de forte entropie) et quelque chose que &lt;strong&gt;je connais&lt;/strong&gt; (la passphrase, de plus
faible &lt;a href=&quot;http://en.wikipedia.org/wiki/Password_strength#Entropy_as_a_measure_of_password_strength&quot;&gt;entropie&lt;/a&gt;). Le second ne nécessite que la passphrase à retenir.&lt;/p&gt;

&lt;p&gt;L’utilisation d’une clé privée autorise donc une meilleure sécurité, notamment
si vous souhaitez envoyer vos backups sur un &lt;a href=&quot;http://fr.wikipedia.org/wiki/PRISM_%28programme_de_surveillance%29&quot;&gt;serveur américain&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Néanmoins, les backups sont surtout utiles lors de la perte de données,
notamment dans le cas d’un cambriolage, où la clé GPG a potentiellement
également disparu. Et les sauvegardes distantes ne seront d’aucune utilité sans
la clé…&lt;/p&gt;

&lt;p&gt;Il peut donc être moins risqué d’opter, comme je l’ai fait, pour une simple
passphrase.&lt;/p&gt;

&lt;p&gt;À vous de placer le curseur entre la protection de vos données et le risque de
ne plus pouvoir les récupérer.&lt;/p&gt;

&lt;h2 id=&quot;installation&quot;&gt;Installation&lt;/h2&gt;

&lt;p&gt;Sur une &lt;em&gt;Debian&lt;/em&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install duplicity
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;fonctionnement&quot;&gt;Fonctionnement&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Duplicity&lt;/em&gt; effectue des sauvegardes &lt;strong&gt;complètes&lt;/strong&gt; et &lt;strong&gt;incrémentales&lt;/strong&gt;. Les
sauvegardes incrémentales nécessitent toutes les sauvegardes depuis la dernière
complète pour être restaurées.&lt;/p&gt;

&lt;p&gt;Personnellement, j’effectue une sauvegarde complète tous les mois, et une
incrémentale tous les jours.&lt;/p&gt;

&lt;p&gt;Pour choisir le mode :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;duplicity full …&lt;/code&gt; force une sauvegarde &lt;strong&gt;complète&lt;/strong&gt; ;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;duplicity incr …&lt;/code&gt; force une sauvegarde &lt;strong&gt;incrémentale&lt;/strong&gt; (échoue si aucune
&lt;strong&gt;complète&lt;/strong&gt; n’est trouvée) ;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;duplicity …&lt;/code&gt; effectue une sauvegarde &lt;strong&gt;incrémentale&lt;/strong&gt; si possible,
&lt;strong&gt;complète&lt;/strong&gt; sinon.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Exemple (à exécuter en &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; pour avoir accès à tous les fichiers) :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;duplicity / file:///var/backups/duplicity/ &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--include-globbing-filelist&lt;/span&gt; filelist.txt &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--exclude&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;**&apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;em&gt;Duplicity&lt;/em&gt; va sauvegarder à partir de la racine (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt;) tous les fichiers selon
les règles d’inclusion et d’exclusion définies dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;filelist.txt&lt;/code&gt;. Ce fichier
contient simplement la liste des fichiers et répertoires à sauvegarder, ainsi
que ceux à exclure. Par exemple :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/usr/local/bin/
/home/rom/Maildir/
/home/rom/.procmailrc
- /var/www/blog/wp-content/cache/
/var/www/blog/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Attention :&lt;/em&gt; les fichiers et répertoires à exclure doivent apparaître &lt;strong&gt;avant&lt;/strong&gt;
l’inclusion d’un répertoire parent. En effet, &lt;em&gt;duplicity&lt;/em&gt; s’arrête à la première
règle qui &lt;em&gt;matche&lt;/em&gt; un chemin donné pour déterminer s’il doit l’inclure ou
l’exclure.&lt;/p&gt;

&lt;p&gt;Pour &lt;strong&gt;restaurer&lt;/strong&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;duplicity restore file:///var/backups/duplicity/ /any/directory/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;(utiliser l’option &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-t&lt;/code&gt; pour restaurer à une date particulière)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Pour &lt;strong&gt;supprimer&lt;/strong&gt; les anciennes sauvegardes (ici de plus de 2 mois) :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;duplicity remove-older-than 2M file:///var/backups/duplicity/ --force
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;bases-de-données&quot;&gt;Bases de données&lt;/h2&gt;

&lt;p&gt;Tout comme pour les fichiers, il est préférable de sauvegarder incrémentalement
les bases de données (seule une toute petite partie des données change d’un jour
à l’autre).&lt;/p&gt;

&lt;p&gt;Une première solution serait d’utiliser la
&lt;a href=&quot;http://stackoverflow.com/questions/4411057/how-to-do-a-incremental-backup-in-mysql&quot;&gt;fonctionnalité-qui-va-bien&lt;/a&gt; de votre &lt;a href=&quot;http://fr.wikipedia.org/wiki/Syst%C3%A8me_de_gestion_de_base_de_donn%C3%A9es&quot;&gt;SGBD&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Mais si le contenu de vos bases de données ne dépasse pas quelques &lt;em&gt;Go&lt;/em&gt; (ce qui
est très probable pour de l’auto-hébergement), &lt;em&gt;duplicity&lt;/em&gt; permet de faire
beaucoup plus simple.&lt;/p&gt;

&lt;p&gt;Il suffit en effet de générer un &lt;em&gt;dump&lt;/em&gt; complet des bases de données vers des
fichiers &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.sql&lt;/code&gt; et d’inclure leur chemin dans la liste des fichiers à
sauvegarder. Et là, c’est magique, &lt;em&gt;duplicity&lt;/em&gt; va ne sauvegarder que les parties
de ces (gros) fichiers qui ont changées, grâce à &lt;a href=&quot;http://fr.wikipedia.org/wiki/Rsync&quot;&gt;rsync&lt;/a&gt; et à son
&lt;a href=&quot;http://en.wikipedia.org/wiki/Rsync#Algorithm&quot;&gt;algorithme&lt;/a&gt; qui utilise des &lt;a href=&quot;http://en.wikipedia.org/wiki/Rolling_hash&quot;&gt;rolling checksums&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Bien sûr, il ne faut pas compresser ces fichiers avant de les donner à manger à
&lt;em&gt;duplicity&lt;/em&gt; (sinon l’intégralité du fichier risque de changer) ; c’est lui qui
va s’en charger. De même, il vaut mieux éviter d’inclure dans les fichies &lt;em&gt;SQL&lt;/em&gt;
des informations liées au &lt;em&gt;dump&lt;/em&gt;, comme sa date de génération.&lt;/p&gt;

&lt;p&gt;Pour exporter une base de données &lt;em&gt;MySQL&lt;/em&gt; par exemple :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mysql -uroot -ppassword --skip-comments -ql my_database &amp;gt; my_database.sql
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;script&quot;&gt;Script&lt;/h2&gt;

&lt;p&gt;Il reste donc à écrire un script qui exporte les bases de données et qui appelle
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;duplicity&lt;/code&gt; avec la liste de ce qu’il y a à sauvegarder.&lt;/p&gt;

&lt;p&gt;Voici un prototype, à sauvegarder dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/local/bin/backup&lt;/code&gt; :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;BACKUP_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/var/backups
&lt;span class=&quot;nv&quot;&gt;TMP_DBDIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$BACKUP_HOME&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/dbdump&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;BACKUP_DIR&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$BACKUP_HOME&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/duplicity&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;MYSQLPW&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;mon_password_mysql
&lt;span class=&quot;nv&quot;&gt;PASSPHRASE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;ma_passphrase_de_chiffrement_des_backups
&lt;span class=&quot;nv&quot;&gt;DATABASES&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;blog autre_base&apos;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;FILELIST&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/usr/local/bin/
/home/rom/Maildir/
/home/rom/.procmailrc
- /var/www/blog/wp-content/cache/
/var/www/blog/
&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TMP_DBDIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# databases&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TMP_DBDIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;dbname &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$DATABASES&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;do
  &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;## Dump database &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
  mysqldump &lt;span class=&quot;nt&quot;&gt;-uroot&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$MYSQLPW&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--skip-comments&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-ql&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TMP_DBDIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.sql&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# duplicity&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;## Backup using duplicity...\n&apos;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;unset &lt;/span&gt;mode
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; full &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;full &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;(force full backup)\n&apos;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$BACKUP_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;PASSPHRASE
duplicity &lt;span class=&quot;nv&quot;&gt;$mode&lt;/span&gt; / file://&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$BACKUP_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;/ &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;--include-globbing-filelist&lt;/span&gt; &amp;lt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$FILELIST&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--exclude&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;**&apos;&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;## Delete old backups\n&apos;&lt;/span&gt;
duplicity remove-older-than 2M file://&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$BACKUP_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;/ &lt;span class=&quot;nt&quot;&gt;--force&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# backups are encrypted, we can make them accessible&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;chmod&lt;/span&gt; +r &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$BACKUP_DIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.gpg

&lt;span class=&quot;c&quot;&gt;# remove temp files&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$TMP_DBDIR&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.sql&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Une fois configuré, ne pas oublier de tester : exécuter le script et restaurer
les données dans un répertoire de test, puis vérifier que tout est OK. Cette
vérification doit être effectuée de temps en temps : il serait dommage de
s’apercevoir, lorsqu’on en a besoin, que les backups sont inutilisables ou qu’un
répertoire important a été oublié.&lt;/p&gt;

&lt;h2 id=&quot;cron&quot;&gt;Cron&lt;/h2&gt;

&lt;p&gt;Pour démarrer automatiquement une sauvegarde &lt;strong&gt;complète&lt;/strong&gt; le premier jour du mois et une &lt;strong&gt;incrémentale&lt;/strong&gt; tous les autres jours, &lt;em&gt;cron&lt;/em&gt; est notre ami :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo crontab -e
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ajouter les lignes :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;0 1 1    * * /usr/local/bin/backup full
0 1 2-31 * * /usr/local/bin/backup
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;La première colonne correspond aux minutes, la deuxième aux heures : le script
sera donc exécuté à 1h du matin. La 3e correspond au numéro du jour dans le
mois. Les deux suivantes sont le numéro du mois dans l’année et le jour de la
semaine.&lt;/p&gt;

&lt;p&gt;Il peut être préférable d’exécuter le script en priorité basse :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;0 1 1    * * nice -15 ionice -c2 /usr/local/bin/backup full
0 1 2-31 * * nice -15 ionice -c2 /usr/local/bin/backup
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;copies&quot;&gt;Copies&lt;/h2&gt;

&lt;p&gt;Il ne reste plus qu’à effectuer des copies des fichiers de backups ailleurs.&lt;/p&gt;

&lt;p&gt;À partir d’une autre machine, le plus simple est d’utiliser &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rsync&lt;/code&gt; (sans
l’option &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--delete&lt;/code&gt; !) :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;rsync &lt;span class=&quot;nt&quot;&gt;-rvP&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--partial-dir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/my/local/tmpbackup &lt;span class=&quot;nt&quot;&gt;--ignore-existing&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--stats&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt; server:/var/backups/duplicity/ /my/local/backup/&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--ignore-existing&lt;/code&gt; évite de récupérer des modifications malicieuses des backups
sur le serveur (ils ne sont pas censés être modifiés). Du coup, il faut aussi
faire attention à sauvegarder les transferts partiels ailleurs
(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--partial-dir&lt;/code&gt;), sans quoi ils ne se termineront jamais.&lt;/p&gt;

&lt;p&gt;Pour supprimer les anciens backups sur cette machine, c’est la même commande que
sur le serveur :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;duplicity remove-older-than 2M file:///my/local/backup/ --force
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;La génération de sauvegardes à la fois incrémentales et chiffrées, y compris
pour les bases de données, font de &lt;em&gt;duplicity&lt;/em&gt; &lt;strong&gt;une solution de backup idéale
pour l’auto-hébergement&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Je l’utilise depuis plusieurs mois, et j’en suis très satisfait (même si je n’ai
pas encore eu besoin de restaurer les backups en situation réelle).&lt;/p&gt;

&lt;p&gt;À vos backups !&lt;/p&gt;
</content>
 </entry>
  
 
  
   
 <entry>
   <title>GIT : squasher des merges</title>
   <link href="https://blog.rom1v.com/2013/05/git-squasher-des-merges/"/>
   <updated>2013-05-30T15:40:50+02:00</updated>
   <id>https://blog.rom1v.com/2013/05/git-squasher-des-merges</id>
   <content type="html">&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/squash_merges/gitmerge.jpg&quot; alt=&quot;gitmerge&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Supposons que je souhaite ajouter une fonctionnalité à un projet sur &lt;a href=&quot;http://fr.wikipedia.org/wiki/Git&quot;&gt;GIT&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Je prends la version actuelle de la branche &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;A&lt;/code&gt;), puis ajoute sur ma
branche &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;topic&lt;/code&gt; les commits &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;X&lt;/code&gt; et &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Y&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    X---Y  topic
   /
--A  master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Je propose la fonctionnalité &lt;em&gt;upstream&lt;/em&gt; (par un &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git request-pull&lt;/code&gt; ou une &lt;a href=&quot;https://help.github.com/articles/using-pull-requests&quot;&gt;pull
request&lt;/a&gt;), qui met un peu de temps à être revue.&lt;/p&gt;

&lt;p&gt;Pendant ce temps, la branche &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt; a avancé, et malheureusement les
modifications effectuées entrent en conflit avec mon travail sur &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;topic&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    X---Y  topic
   /
--A---B---C  master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Une fois mon code revu et accepté, les mainteneurs vont alors me demander de
résoudre les conflits avec la branche &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt; avant de merger ma branche
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;topic&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Si j’avais eu à prendre en compte les mises à jour de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt; &lt;strong&gt;avant&lt;/strong&gt; d’avoir
rendu public mon &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;topic&lt;/code&gt;, j’aurais simplement &lt;a href=&quot;http://git-scm.com/book/en/Git-Branching-Rebasing&quot;&gt;rebasé&lt;/a&gt; mon travail
par-dessus &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt;. Mais là, &lt;a href=&quot;http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html&quot;&gt;impossible&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Je dois donc merger. Très bien. Je merge et je résous les conflits.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    X---Y---M  topic
   /       /
--A---B---C  master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Mais, alors que je n’ai pas encore rendu &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M&lt;/code&gt; public, je m’aperçois qu’il y a un
nouveau commit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;D&lt;/code&gt; sur &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;master&lt;/code&gt;, que je veux intégrer dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;topic&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    X---Y---M  topic
   /       /
--A---B---C---D  master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;La solution la plus évidente est de merger à nouveau.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    X---Y---M---N  topic
   /       /   /
--A---B---C---D  master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Mais je voudrais éviter un commit de merge inutile. Pour un seul, ce n’est pas
très gênant, mais si on maintient une branche suffisamment longtemps avant
qu’elle ne soit mergée, ces commits inutiles vont se multiplier.&lt;/p&gt;

&lt;p&gt;Une solution serait de revenir à &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Y&lt;/code&gt; et de le merger avec &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;D&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git checkout topic
git reset --hard Y
git merge master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ce qui donne :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    X---Y---M&apos;  topic
   /         \
--A---B---C---D  master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Mais dans ce cas, pour créer &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M&apos;&lt;/code&gt;, je vais devoir résoudre à nouveau les
conflits que j’avais déjà résolu en créant &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Comment éviter ce problème ?&lt;/p&gt;

&lt;h2 id=&quot;rerere&quot;&gt;rerere&lt;/h2&gt;

&lt;p&gt;Une solution est d’avoir activé &lt;em&gt;rerere&lt;/em&gt; &lt;strong&gt;avant&lt;/strong&gt; d’avoir résolu les conflits
de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git config rerere.enabled true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ainsi, lorsque je tenterai de merger à nouveau &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Y&lt;/code&gt; et &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;D&lt;/code&gt;, les conflits entre
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Y&lt;/code&gt; et &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt; seront automatiquement résolus de la même manière que précédemment.&lt;/p&gt;

&lt;p&gt;Cependant, cette méthode a ses inconvénients.&lt;/p&gt;

&lt;p&gt;Tout d’abord, il ne s’agit que d’un cache local de résolutions des conflits,
stocké pendant une durée déterminée (par défaut à 60 jours pour les conflits
résolus), ce qui est peu pratique si on clone son dépôt sur plusieurs machines
(les conflits ne seront résolus automatiquement que sur certaines).&lt;/p&gt;

&lt;p&gt;Ensuite, elle est inutilisable lorsqu’on souhaite &lt;a href=&quot;http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits&quot;&gt;squasher&lt;/a&gt; un merge
conflictuel alors que &lt;em&gt;rerere&lt;/em&gt; était désactivé lors de sa création.&lt;/p&gt;

&lt;p&gt;Enfin, cette fonctionnalité est encore récente, et la fonction &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git rerere
forget&lt;/code&gt; (pour permettre de résoudre autrement des conflits déjà résolus), a la
fâcheuse tendance à &lt;a href=&quot;http://fr.wikipedia.org/wiki/Erreur_de_segmentation&quot;&gt;segfaulter&lt;/a&gt; (un &lt;a href=&quot;http://permalink.gmane.org/gmane.comp.version-control.git/220059&quot;&gt;patch&lt;/a&gt; a été proposé).&lt;/p&gt;

&lt;h2 id=&quot;rebranchement&quot;&gt;Rebranchement&lt;/h2&gt;

&lt;p&gt;La solution que j’utilise est donc la suivante.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    X---Y---M---N  topic
   /       /   /
--A---B---C---D  master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Une fois obtenus les deux merges &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M&lt;/code&gt; et &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;N&lt;/code&gt;, le principe est de remplacer le
parent de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;N&lt;/code&gt;, qui était &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M&lt;/code&gt;, par &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Y&lt;/code&gt;, sans rien changer d’autre au contenu.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;          -----
         /     \
    X---Y---M   N&apos; topic
   /       /   /
--A---B---C---D  master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ainsi, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;M&lt;/code&gt; devient inatteignable, et c’est exactement le résultat souhaité :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    X---Y-------N&apos; topic
   /           /
--A---B---C---D  master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pour faire cela, il faut déplacer le HEAD (pointant vers &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;topic&lt;/code&gt;) sur &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Y&lt;/code&gt;, faire
croire à GIT qu’on est en phase de merge avec &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;D&lt;/code&gt; en modifiant la référence
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MERGE_HEAD&lt;/code&gt;, puis commiter :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git checkout N
git reset &lt;span class=&quot;nt&quot;&gt;--soft&lt;/span&gt; Y
git update-ref MERGE_HEAD D
git commit &lt;span class=&quot;nt&quot;&gt;-eF&lt;/span&gt; &amp;lt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;git log ..HEAD@&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;1&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; ^master &lt;span class=&quot;nt&quot;&gt;--pretty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;# %H%n%s%n%n%b&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Il n’y a plus qu’à éditer le message de commit de merge.&lt;/p&gt;

&lt;p&gt;La fin de la ligne du &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git commit&lt;/code&gt; permet de concaténer l’historique des commits
intermédiaires (a priori uniquement des &lt;em&gt;merges&lt;/em&gt;) comme lors d’un &lt;em&gt;squash&lt;/em&gt; avec
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git rebase&lt;/code&gt; (pour pouvoir conserver les messages de merges intermédiaires,
contenant nontamment les conflits).&lt;/p&gt;

&lt;p&gt;En utilisant les références plutôt que les numéros de commit, cela donne :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git checkout feature
git reset &lt;span class=&quot;nt&quot;&gt;--soft&lt;/span&gt; HEAD~2
git update-ref MERGE_HEAD master
git commit &lt;span class=&quot;nt&quot;&gt;-eF&lt;/span&gt; &amp;lt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;git log ..HEAD@&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;1&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; ^master &lt;span class=&quot;nt&quot;&gt;--pretty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;# %H%n%s%n%n%b&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Si vous avez plus simple, je suis preneur…&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Merci aux membres de &lt;a href=&quot;http://stackoverflow.com/questions/1725708/git-rebase-interactive-squash-merge-commits-togethergi&quot;&gt;stackoverflow&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</content>
 </entry>
  
 
  
 
  
 
  
   
 <entry>
   <title>Formater du code C avec indent et Vim</title>
   <link href="https://blog.rom1v.com/2012/11/formater-du-code-c-avec-indent-et-vim/"/>
   <updated>2012-11-15T12:23:54+01:00</updated>
   <id>https://blog.rom1v.com/2012/11/formater-du-code-c-avec-indent-et-vim</id>
   <content type="html">&lt;p&gt;Pour suivre des règles de codage et s’y tenir, rien de tel qu’un outil qui
formate automatiquement le code (c’est plus rapide et sans erreurs). Sous
&lt;a href=&quot;http://fr.wikipedia.org/wiki/Eclipse_%28logiciel%29&quot;&gt;Eclipse&lt;/a&gt; par exemple, la combinaison de touches &lt;em&gt;Ctrl+Shift+F&lt;/em&gt; est
indispensable. Mon but est d’obtenir la même fonctionnalité sous &lt;a href=&quot;http://fr.wikipedia.org/wiki/Vim&quot;&gt;Vim&lt;/a&gt; pour le
&lt;a href=&quot;http://fr.wikipedia.org/wiki/C_%28langage%29&quot;&gt;langage C&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;indent&quot;&gt;Indent&lt;/h2&gt;

&lt;p&gt;L’outil &lt;a href=&quot;http://fr.wikipedia.org/wiki/Indent&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;indent&lt;/code&gt;&lt;/a&gt; permet de formater un source C selon des règles
définies par des paramètres en ligne de commande. Ces options sont &lt;a href=&quot;http://www.gnu.org/software/indent/manual/&quot;&gt;très
nombreuses&lt;/a&gt;. Heureusement, il y a quelques styles bien connus
prédéfinis, comme le &lt;a href=&quot;http://en.wikipedia.org/wiki/1_true_brace_style#K.26R_style&quot;&gt;style K&amp;amp;R&lt;/a&gt; (option &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-kr&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Pour illustrer son fonctionnement, voici un code source écrit n’importe comment
(et qui fait n’importe quoi) :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;  &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
 &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;goto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;cm&quot;&gt;/* my comment */&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
       &lt;span class=&quot;nl&quot;&gt;mylabel:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;%d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;   &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;/* what? */&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; \
&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; \
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;z&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;putchar&lt;/span&gt; \
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;    &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Pour formater :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;indent -st -kr -ts4 file.c
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-st&lt;/code&gt; affiche le résultat sur la sortie standard au lieu de modifier le
fichier ;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-kr&lt;/code&gt; utilise le style K&amp;amp;R ;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-ts4&lt;/code&gt; considère 4 espaces comme une tabulation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Voici le résultat :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;c&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;

void f&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;int &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;x&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;x &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 4&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

void g&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;int x&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    goto mylabel&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    /&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; my comment &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;/
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;x &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; 10&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
        x &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 10&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  mylabel:
    &lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;%d&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;, x &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; 2&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    switch &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;x&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; 1:
        x &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 4&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;nb&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; 2:
        x &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 1&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&amp;amp;x&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &amp;lt; 10&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
        x++&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;                    /&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; what? &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;/
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

void h&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;char &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;x&lt;span class=&quot;o&quot;&gt;())[])())&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    char &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;y&lt;span class=&quot;o&quot;&gt;)[])&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; x&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    char &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;z&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;y&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    char c &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; z&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    putchar&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;c&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

int main&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    int i &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; 2&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    f&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&amp;amp;i&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    g&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return &lt;/span&gt;0&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;C’est plus joli, non ?&lt;/p&gt;

&lt;h2 id=&quot;vim&quot;&gt;vim&lt;/h2&gt;

&lt;p&gt;Pour pouvoir reformater directement dans &lt;em&gt;Vim&lt;/em&gt;, il suffit d’ajouter dans
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.vimrc&lt;/code&gt; la ligne suivante :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vim&quot; data-lang=&quot;vim&quot;&gt;autocmd &lt;span class=&quot;nb&quot;&gt;BufNewFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;BufRead&lt;/span&gt; *&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;formatprg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;indent&lt;/span&gt;\ &lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;kr\ &lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;ts4&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Ensuite, la commande &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gq&lt;/code&gt; formate (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;u&lt;/code&gt; annule).&lt;/p&gt;

&lt;p&gt;Par exemple, sur le fichier source mal formaté ci-dessus :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;placer le curseur sur la ligne 7 ;&lt;/li&gt;
  &lt;li&gt;appuyer sur &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;V&lt;/code&gt; ;&lt;/li&gt;
  &lt;li&gt;descendre avec &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;j&lt;/code&gt; (ou la flèche du bas) jusqu’à la ligne 15 ;&lt;/li&gt;
  &lt;li&gt;taper &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gq&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ainsi, seule la fonction &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;g&lt;/code&gt; est formatée.&lt;/p&gt;

&lt;p&gt;À partir de la ligne 7, le même résultat est obtenu en tapant directement &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gq8j&lt;/code&gt;
(descendre de 8 lignes) ou &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gq15G&lt;/code&gt; (jusqu’à la ligne 15).&lt;/p&gt;

&lt;p&gt;Pour reformater un bloc, le plus simple est de se placer sur une accolade &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{&lt;/code&gt; ou
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;}&lt;/code&gt; et de taper &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gq%&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%&lt;/code&gt; navigue entre les &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{}&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;()&lt;/code&gt; et &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[]&lt;/code&gt; ouvrant et
fermant).&lt;/p&gt;

&lt;p&gt;Pour reformater tout le fichier, il faut taper &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gggqG&lt;/code&gt; :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gg&lt;/code&gt; amène le curseur au début du fichier ;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gq&lt;/code&gt; formate jusqu’à… ;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;G&lt;/code&gt; va à la fin du fichier.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:wq&lt;/code&gt;&lt;/p&gt;
</content>
 </entry>
  
 
  
 
  
   
 <entry>
   <title>Utiliser Wireshark sous Debian</title>
   <link href="https://blog.rom1v.com/2012/06/utiliser-wireshark-sous-debian/"/>
   <updated>2012-06-02T12:48:21+02:00</updated>
   <id>https://blog.rom1v.com/2012/06/utiliser-wireshark-sous-debian</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://fr.wikipedia.org/wiki/Wireshark&quot;&gt;Wireshark&lt;/a&gt; est un outil incontournable pour connaître les paquets qui
transitent sur le réseau. Mais on se retrouve vite bloqué à cause d’un problème
de droits.&lt;/p&gt;

&lt;p&gt;En effet, en démarrant &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wireshark&lt;/code&gt; avec un compte utilisateur &lt;em&gt;non-root&lt;/em&gt;,
l’interface graphique s’affiche, mais il est impossible de capturer les trames :
aucune interface réseau n’est disponible.&lt;/p&gt;

&lt;p&gt;Devant ce problème, que fait l’utilisateur pressé ? Il démarre &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wireshark&lt;/code&gt; en
&lt;em&gt;root&lt;/em&gt;, bien sûr &lt;em&gt;(c’est ce que je faisais sous Ubuntu)&lt;/em&gt; ! Eh bien pas de
chance :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo wireshark
No protocol specified

(wireshark:27210): Gtk-WARNING **: cannot open display: :0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Déjà, c’est bien fait pour lui : on n’essaie pas de démarrer une interface
graphique en &lt;em&gt;root&lt;/em&gt; !&lt;/p&gt;

&lt;p&gt;Mais comment faire alors ? En &lt;em&gt;non-root&lt;/em&gt; on ne peut pas capturer, en &lt;em&gt;root&lt;/em&gt; on
ne peut pas démarrer…&lt;/p&gt;

&lt;p&gt;Alors on lit la doc, qui propose deux solutions :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;less /usr/share/doc/wireshark/README.Debian
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;EDIT :&lt;/strong&gt; Une troisième solution, donnée &lt;a href=&quot;/2012/06/utiliser-wireshark-sous-debian/#comment-10&quot;&gt;en commentaire&lt;/a&gt;, me semble encore
meilleure :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;tcpdump &lt;span class=&quot;nt&quot;&gt;-pni&lt;/span&gt; eth0 &lt;span class=&quot;nt&quot;&gt;-s0&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-U&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-w&lt;/span&gt; - | wireshark &lt;span class=&quot;nt&quot;&gt;-k&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; -&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;utiliser-dumpcap-pour-capturer&quot;&gt;Utiliser dumpcap pour capturer&lt;/h2&gt;

&lt;p&gt;Avec cette méthode, il faut d’abord capturer les paquets réseau et les sauver
dans un fichier, grâce à &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dumpcap&lt;/code&gt; (en &lt;em&gt;root&lt;/em&gt;), puis ouvrir ce fichier dans
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wireshark&lt;/code&gt; (&lt;em&gt;non-root&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Pour démarrer la capture de l’interface &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;eth0&lt;/code&gt; dans le fichier
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/tmp/mycapture&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo dumpcap -i eth0 -w /tmp/mycapture
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pour connaître la liste des interfaces réseau capturables :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo dumpcap -D 
1. eth0
2. wlan0
3. nflog (Linux netfilter log (NFLOG) interface)
4. any (Pseudo-device that captures on all interfaces)
5. lo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Ctrl+C&lt;/em&gt; arrête la capture.&lt;/p&gt;

&lt;p&gt;Le fichier généré n’est lisible que par &lt;em&gt;root&lt;/em&gt;. Avant de l’ouvrir dans
&lt;em&gt;Wireshark&lt;/em&gt;, il faut donc changer ses droits :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo chmod +r /tmp/mycapture
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;C’est la méthode configurée par défaut sous &lt;em&gt;Debian&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;autoriser-les-utilisateurs-non-root&quot;&gt;Autoriser les utilisateurs non-root&lt;/h2&gt;

&lt;p&gt;Si on souhaite à la fois capturer et analyser à partir de &lt;em&gt;Wireshark&lt;/em&gt; (et
permettre les captures “en live”), sans passer par &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dumpcap&lt;/code&gt; en ligne de
commande, il faut autoriser les utilisateur &lt;em&gt;non-root&lt;/em&gt; à capturer des paquets.&lt;/p&gt;

&lt;p&gt;Pour cela :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo dpkg-reconfigure wireshark-common
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Ce qui affiche :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; ┌─────────────────────┤ Configuration de wireshark-common ├──────────────────────┐
 │                                                                                │
 │ Dumpcap peut être installé afin d&apos;autoriser les membres du groupe              │
 │ « wireshark » à capturer des paquets. Cette méthode de capture est préférable  │
 │ à l&apos;exécution de Wireshark ou Tshark avec les droits du superutilisateur, car  │
 │ elle permet d&apos;exécuter moins de code avec des droits importants.               │
 │                                                                                │
 │ Pour plus d&apos;informations, veuillez consulter                                   │
 │ /usr/share/doc/wireshark-common/README.Debian.                                 │
 │                                                                                │
 │ Cette fonctionnalité constitue un risque pour la sécurité, c&apos;est pourquoi      │
 │ elle est désactivée par défaut. En cas de doute, il est suggéré de la laisser  │
 │ désactivée.                                                                    │
 │                                                                                │
 │ Autoriser les utilisateurs non privilégiés à capturer des paquets ?            │
 │                                                                                │
 │                      &amp;lt;Oui&amp;gt;                         &amp;lt;Non&amp;gt;                       │
 │                                                                                │
 └────────────────────────────────────────────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Après avoir répondu &lt;em&gt;Oui&lt;/em&gt;, tous les utilisateurs du groupe &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wireshark&lt;/code&gt; (aucun,
par défaut) seront autorisés à capturer les paquets.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Remarque :&lt;/strong&gt; un programme non-root sera donc en théorie capable de savoir
tout ce qui passe sur le réseau (déjà qu’il est capable de &lt;a href=&quot;/2011/11/keylogger-sous-gnulinux-enregistrer-les-touches-tapees-au-clavier/&quot;&gt;connaître tout ce
qui est tapé au clavier&lt;/a&gt;).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Il ne reste donc plus qu’à ajouter son compte utilisateur au groupe
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wireshark&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo addgroup $USER wireshark
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Cette modification ne sera prise en compte qu’après une reconnexion du compte
utilisateur (il faut donc fermer la session et en démarrer une nouvelle).&lt;/p&gt;
</content>
 </entry>
  
 
  
 
  
   
 <entry>
   <title>Configurer le thème des applications GTK sous KDE</title>
   <link href="https://blog.rom1v.com/2012/05/configurer-le-theme-des-applications-gtk-sous-kde/"/>
   <updated>2012-05-15T20:08:19+02:00</updated>
   <id>https://blog.rom1v.com/2012/05/configurer-le-theme-des-applications-gtk-sous-kde</id>
   <content type="html">&lt;p&gt;Après être passé de &lt;a href=&quot;http://fr.wikipedia.org/wiki/KDE&quot;&gt;KDE&lt;/a&gt; à &lt;a href=&quot;http://fr.wikipedia.org/wiki/GNOME&quot;&gt;Gnome&lt;/a&gt; il y a un peu plus de 4 ans, j’ai décidé
de revenir à &lt;em&gt;KDE&lt;/em&gt;. Mais de la même manière que &lt;a href=&quot;/2009/06/configurer-les-applis-kde-sous-gnome/&quot;&gt;les applications prévues pour
KDE ne s’intègrent pas correctement à Gnome&lt;/a&gt;, les applications
prévues pour &lt;em&gt;Gnome&lt;/em&gt; sont horribles sur &lt;em&gt;KDE&lt;/em&gt; : elles n’ont pas de thème du tout
(sauf si vous appelez “thème” l’apparence de &lt;a href=&quot;http://fr.wikipedia.org/wiki/Windows_95&quot;&gt;Windows 95&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Voici par exemple à quoi ressemble &lt;a href=&quot;http://fr.wikipedia.org/wiki/GIMP&quot;&gt;GIMP&lt;/a&gt; :&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;a href=&quot;/assets/gnome_theme/gimp-moche.png&quot;&gt;&lt;img src=&quot;/assets/gnome_theme/gimp-moche.thumb.jpg&quot; alt=&quot;gimp-moche&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Le problème doit être résolu deux fois : une première pour les applications
utilisant &lt;a href=&quot;http://fr.wikipedia.org/wiki/GTK%2B#GTK.2B_2&quot;&gt;GTK2&lt;/a&gt; et une seconde pour celles utilisant &lt;a href=&quot;http://fr.wikipedia.org/wiki/GTK%2B#GTK.2B_3&quot;&gt;GTK3&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;gtk2&quot;&gt;GTK2&lt;/h2&gt;

&lt;p&gt;Pour &lt;em&gt;GTK2&lt;/em&gt;, c’est facile. Sous &lt;a href=&quot;http://fr.wikipedia.org/wiki/Debian&quot;&gt;Debian&lt;/a&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install gtk2-engines-oxygen gtk-chtheme
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;(le nom des paquets peut varier selon votre distribution)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Il ne reste alors plus qu’à exécuter :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gtk-chtheme
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;et choisir le thème &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;oxygen-gtk&lt;/code&gt; :&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/gnome_theme/gtk-chtheme.png&quot; alt=&quot;gtk-chtheme&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Le thème des applications telles que &lt;a href=&quot;http://fr.wikipedia.org/wiki/Mozilla_Firefox&quot;&gt;Firefox&lt;/a&gt;/&lt;a href=&quot;http://fr.wikipedia.org/wiki/Renommage_des_applications_de_Mozilla_par_Debian#Iceweasel&quot;&gt;Iceweasel&lt;/a&gt;, &lt;a href=&quot;http://fr.wikipedia.org/wiki/GIMP&quot;&gt;GIMP&lt;/a&gt;,
&lt;a href=&quot;http://fr.wikipedia.org/wiki/Ario&quot;&gt;Ario&lt;/a&gt; ou &lt;a href=&quot;http://fr.wikipedia.org/wiki/Eclipse_%28logiciel%29&quot;&gt;Eclipse&lt;/a&gt; sera alors totalement cohérent avec celui des
applications prévues pour &lt;em&gt;KDE&lt;/em&gt; :&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;a href=&quot;/assets/gnome_theme/gimp-oxygen.png&quot;&gt;&lt;img src=&quot;/assets/gnome_theme/gimp-oxygen.thumb.jpg&quot; alt=&quot;gimp-oxygen&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pour pousser plus loin l’intégration de &lt;em&gt;Firefox/Iceweasel&lt;/em&gt;, il y a même un
&lt;a href=&quot;https://addons.mozilla.org/fr/firefox/addon/oxygen-kde/&quot;&gt;module complémentaire&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;gtk3&quot;&gt;GTK3&lt;/h2&gt;

&lt;p&gt;Pour &lt;em&gt;GTK3&lt;/em&gt;, ce devrait être presque pareil… sauf que le paquet
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gtk3-engines-oxygen&lt;/code&gt; (ou &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;oxygen-gtk3&lt;/code&gt;) n’est pas encore dans les dépôts
&lt;em&gt;Debian&lt;/em&gt; (il est par contre dans d’autres distributions, comme &lt;a href=&quot;http://fr.wikipedia.org/wiki/Ubuntu&quot;&gt;Ubuntu&lt;/a&gt; ou
&lt;a href=&quot;http://fr.wikipedia.org/wiki/Arch_Linux&quot;&gt;Arch Linux&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Il est bien sûr possible de &lt;a href=&quot;https://projects.kde.org/projects/playground/artwork/oxygen-gtk&quot;&gt;télécharger les sources&lt;/a&gt; pour l’installer
manuellement.&lt;/p&gt;

&lt;p&gt;Mais nous pouvons nous contenter du thème natif de &lt;em&gt;Gnome&lt;/em&gt;. Pour le configurer,
il suffit d’installer &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gnome-themes-standard&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install gnome-themes-standard
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;et de créer un fichier &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.config/gtk-3.0/settings.ini&lt;/code&gt; contenant :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Settings]
gtk-theme-name=Adwaita
gtk-fallback-icon-theme=gnome
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(voir &lt;a href=&quot;http://developer.gnome.org/gtk3/3.4/GtkSettings.html&quot;&gt;GtkSettings&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://fr.wikipedia.org/wiki/Gedit&quot;&gt;Gedit&lt;/a&gt; avant :&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/gnome_theme/gedit-moche.png&quot; alt=&quot;gedit-moche&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Gedit&lt;/em&gt; après :&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/gnome_theme/gedit-adwaita.png&quot; alt=&quot;gedit-adwaita&quot; /&gt;&lt;/p&gt;

&lt;p&gt;En attendant qu’&lt;em&gt;Oxygen GTK3&lt;/em&gt; soit disponible dans les dépôts, c’est mieux que
rien…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EDIT :&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;oxygen-gtk3&lt;/code&gt; est maintenant disponible dans les dépôts.&lt;/p&gt;
</content>
 </entry>
  
 
  
   
 <entry>
   <title>Lire des images et des vidéos sans serveur X (dans un TTY)</title>
   <link href="https://blog.rom1v.com/2012/04/lire-des-images-et-des-videos-sans-serveur-x-dans-un-tty/"/>
   <updated>2012-04-07T23:01:55+02:00</updated>
   <id>https://blog.rom1v.com/2012/04/lire-des-images-et-des-videos-sans-serveur-x-dans-un-tty</id>
   <content type="html">&lt;p&gt;Saviez-vous qu’il était possible de lire des images et des vidéos dans un TTY,
sans &lt;a href=&quot;http://fr.wikipedia.org/wiki/X_Window_System&quot;&gt;serveur X&lt;/a&gt; ? Je ne parle pas de les afficher en &lt;a href=&quot;http://fr.wikipedia.org/wiki/Art_ASCII&quot;&gt;ASCII-art&lt;/a&gt;, mais bien
de les afficher “graphiquement” :&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/videos_tty/bbb-tty.jpg&quot; alt=&quot;bbb-tty&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Je ne le savais pas jusqu’à &lt;a href=&quot;http://forum.ubuntu-fr.org/viewtopic.php?pid=8739471#p8739471&quot;&gt;aujourd’hui&lt;/a&gt;. En fait, c’est possible grâce
à des programmes qui écrivent directement dans le &lt;a href=&quot;http://fr.wikipedia.org/wiki/Framebuffer_Linux&quot;&gt;framebuffer&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Pour tester les outils suivants, lancez un TTY grâce aux raccourcis
&lt;em&gt;Ctrl+Alt+F[1-6]&lt;/em&gt;. Pour revenir à votre session graphique, faites &lt;em&gt;Ctrl+Alt+F7&lt;/em&gt;
(sur certaines distributions, par défaut la session graphique est plutôt
accessible avec &lt;em&gt;Ctrl+Alt+F1&lt;/em&gt;, &lt;em&gt;Ctrl+Alt+F8&lt;/em&gt; ou &lt;em&gt;Ctrl+Alt+F9&lt;/em&gt;, essayez…).&lt;/p&gt;

&lt;h2 id=&quot;images&quot;&gt;Images&lt;/h2&gt;

&lt;p&gt;Pour afficher des images, il faut installer le paquet &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fbi&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f&lt;/code&gt;rame&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;uffer
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;i&lt;/code&gt;mageviewer) :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install fbi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Puis simplement exécuter :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fbi monimage.jpg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;ou même&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fbi *.jpg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(&lt;em&gt;PgUp&lt;/em&gt; et &lt;em&gt;PgDown&lt;/em&gt; permettent de naviguer entre les images)&lt;/p&gt;

&lt;p&gt;Cet outil est vraiment très rapide (sauf pour le zoom). C’est un peu
l’équivalent de &lt;a href=&quot;http://doc.ubuntu-fr.org/feh&quot;&gt;feh&lt;/a&gt; qui, lui, fonctionne en mode graphique.&lt;/p&gt;

&lt;h2 id=&quot;vidéos&quot;&gt;Vidéos&lt;/h2&gt;

&lt;p&gt;Pour les vidéos, nous avons besoin de &lt;a href=&quot;http://fr.wikipedia.org/wiki/MPlayer&quot;&gt;MPlayer&lt;/a&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install mplayer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;En lançant dans un TTY :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mplayer mavidéo.avi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;MPlayer&lt;/em&gt; choisit le pilote &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fbdev&lt;/code&gt;. Nous pouvons aussi le choisir
explicitement :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mplayer -vo fbdev mavidéo.avi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Par contre, la vidéo s’affiche à sa taille originale, alors que nous la voulons
en plein écran. Il faut donc la &lt;em&gt;mettre à l’échelle&lt;/em&gt;, grâce aux paramètres de
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mplayer&lt;/code&gt;. Sur un écran 1680×1050 par exemple :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mplayer -fs -vf scale=1680:-3 mavidéo.avi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-3&lt;/code&gt; permet de calculer la seconde composante à partir de la première et de
l’&lt;em&gt;aspect-ratio&lt;/em&gt;. C’est dans le &lt;a href=&quot;http://man.cx/mplayer%281%29/fr&quot;&gt;man&lt;/a&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; 0: largeur/hauteur dimmensionnées à d_width/d_height
-1: largeur/hauteur originales
-2: Calcule l/h en utilisant l&apos;autre dimension et le rapport hauteur/largeur
    redimensionné.
-3: Calcule l/h en utilisant l&apos;autre dimension et le rapport hauteur/largeur
    original.
-(n+8): Comme -n ci-dessus, mais en arrondissant les dimensions au plus
        proche multiple de 16.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Sur mon pc portable, j’arrive sans problème à lire dans un TTY une vidéo
&lt;a href=&quot;http://fr.wikipedia.org/wiki/1080p&quot;&gt;1080p&lt;/a&gt; (j’ai testé avec &lt;a href=&quot;http://www.bigbuckbunny.org/index.php/download/&quot;&gt;Big Buck Bunny&lt;/a&gt; en MP4, redimensionnée lors de la
lecture à la taille de mon écran, 1680×1050).&lt;/p&gt;

&lt;p&gt;Par contre, sur une machine moins puissante (une &lt;a href=&quot;http://www.asus.fr/event/Eeebox_B202/&quot;&gt;EeeBox&lt;/a&gt;, qui &lt;a href=&quot;/2009/01/nouveau-blog-100-libre/&quot;&gt;hébergeait ce
blog&lt;/a&gt; par le passé), &lt;em&gt;MPlayer&lt;/em&gt; saccade, même sur des vidéos basse
définition, que &lt;em&gt;VLC&lt;/em&gt; lit sans problèmes.  Pour améliorer les performances de
lecture de &lt;em&gt;MPlayer&lt;/em&gt;, il est possible de changer l’algorithme de zoom logiciel,
grâce à l’option &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-sws&lt;/code&gt;. Par exemple, pour utiliser &lt;em&gt;bilinéaire rapide&lt;/em&gt; au lieu
de &lt;em&gt;bicubique&lt;/em&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mplayer -fs -vf scale=1680:-3 -sws 0 mavidéo.avi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Avec ce paramètre, ça ne saccade plus.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cependant, sur la EeeBox, dans ce cas les couleurs sont incorrectes apparemment
à cause d’un bug de pilote vidéo Intel. J’ai donc quand même installé un serveur
X avec un gestionnaire de fenêtres minimaliste,
&lt;a href=&quot;http://awesomewm.org&quot;&gt;awesome&lt;/a&gt;. Mais c’est une autre histoire…&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;ascii-art&quot;&gt;ASCII-art&lt;/h2&gt;

&lt;p&gt;Je vous parlais d’&lt;em&gt;ASCII-art&lt;/em&gt; au début du billet, il est également possible de
lire les images ou les vidéos en &lt;em&gt;ASCII&lt;/em&gt; (c’est juste moins joli), grâce à des
commandes d’une élégance toute particulière.&lt;/p&gt;

&lt;p&gt;Pour les images, nous pouvons installer le paquet &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;caca-utils&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install caca-utils
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Puis utiliser &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cacaview&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cacaview monimage.jpg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pour les vidéos :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mplayer -vo caca mavidéo.avi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/videos_tty/bbb-ascii.png&quot; alt=&quot;bbb-ascii&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Je n’en revenais pas qu’il soit possible de lire des vidéos sans serveur X. Sur
une machine destinée à une utilisation multimédia (branchée sur la TV par
exemple), il n’y a donc nullement besoin d’un serveur X (paradoxalement).&lt;/p&gt;
</content>
 </entry>
  
 
  
   
 <entry>
   <title>Prompt Bash pour GIT</title>
   <link href="https://blog.rom1v.com/2012/04/prompt-bash-pour-git/"/>
   <updated>2012-04-04T23:22:55+02:00</updated>
   <id>https://blog.rom1v.com/2012/04/prompt-bash-pour-git</id>
   <content type="html">&lt;p&gt;J’utilise &lt;a href=&quot;http://fr.wikipedia.org/wiki/Git&quot;&gt;git&lt;/a&gt; depuis quelques mois, et je trouve ça vraiment génial. Si vous
ne connaissez pas, ou peu, vous ne pouvez pas ne pas lire le livre &lt;a href=&quot;https://git-scm.com/book/en/v2&quot;&gt;Pro Git&lt;/a&gt;
(sous licence &lt;a href=&quot;http://creativecommons.org/licenses/by-nc-sa/3.0/fr/&quot;&gt;cc-by-nc-sa&lt;/a&gt;). Les explications très claires permettent en
quelques heures de maîtriser toutes les fonctions de base, et d’être à l’aise
avec la gestion des branches (et bien plus encore).&lt;/p&gt;

&lt;h2 id=&quot;branches-visibles&quot;&gt;Branches visibles&lt;/h2&gt;

&lt;p&gt;Le but de ce billet est de répondre à un problème particulier : par manque
d’attention, il m’est arrivé plusieurs fois de commiter des changements sur une
mauvaise branche (j’étais persuadé d’être sur une branche, en fait j’étais sur
une autre). Ce n’est pas très grave (on peut s’en sortir), mais c’est pénible.&lt;/p&gt;

&lt;p&gt;Je souhaiterais donc avoir le nom de la branche dans le &lt;a href=&quot;http://tldp.org/HOWTO/Bash-Prompt-HOWTO/&quot;&gt;prompt&lt;/a&gt; &lt;a href=&quot;http://fr.wikipedia.org/wiki/Bourne-Again_shell&quot;&gt;bash&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Des solutions existent déjà : le paquet &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt; embarque même &lt;a href=&quot;https://gist.github.com/473838&quot;&gt;un script&lt;/a&gt;
qui répond au besoin. Certains utilisent aussi &lt;a href=&quot;http://blog.nicolargo.com/2012/02/configurer-votre-prompt-bash.html&quot;&gt;des scripts
personnalisés&lt;/a&gt;. Mais aucun de ceux que j’ai trouvés ne me
convenait. J’ai donc écrit mon propre script.&lt;/p&gt;

&lt;h2 id=&quot;mes-prompts&quot;&gt;Mes prompts&lt;/h2&gt;

&lt;h3 id=&quot;version-simple&quot;&gt;Version simple&lt;/h3&gt;

&lt;p&gt;J’ai commencé par une version simple, qui ajoute en couleur &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@nomdelabranche&lt;/code&gt; à
la fin du prompt. Un exemple vaut mieux qu’un long discours :&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;rom@rom-laptop:~/dev$ cd myproject/
rom@rom-laptop:~/dev/myproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;$ git checkout testing
Switched to branch &apos;testing&apos;
rom@rom-laptop:~/dev/myproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@testing&lt;/span&gt;$ cd img
rom@rom-laptop:~/dev/myproject/img&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@testing&lt;/span&gt;$ &lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;Dans une arborescence ayant plusieurs projets &lt;em&gt;GIT&lt;/em&gt; imbriqués (dans le cas de
l’utilisation de &lt;a href=&quot;https://git-scm.com/book/en/v2/Git-Tools-Submodules&quot;&gt;sous-modules&lt;/a&gt;), la branche des projets parents n’est pas
affichée :&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;rom@rom-laptop:~/dev$ cd mybigproject/
rom@rom-laptop:~/dev/mybigproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;$ cd submodule/
rom@rom-laptop:~/dev/mybigproject/submodule&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;$ git checkout exp
Switched to branch &apos;exp&apos;
rom@rom-laptop:~/dev/mybigproject/submodule&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@exp&lt;/span&gt;$ cd ..
rom@rom-laptop:~/dev/mybigproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;$ &lt;/code&gt;
&lt;/pre&gt;

&lt;h3 id=&quot;version-améliorée&quot;&gt;Version améliorée&lt;/h3&gt;

&lt;p&gt;Dans cette version simple, le nom de la branche est toujours affiché à la fin.
Cela ne me convient pas, je le voudrais toujours à la racine du projet en
question. C’est ce que permet la version améliorée.&lt;/p&gt;

&lt;p&gt;Voici le résultat avec les mêmes commandes :&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;rom@rom-laptop:~/dev$ cd myproject/
rom@rom-laptop:~/dev/myproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;$ git checkout testing
Switched to branch &apos;testing&apos;
rom@rom-laptop:~/dev/myproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@testing&lt;/span&gt;$ cd img
rom@rom-laptop:~/dev/myproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@testing&lt;/span&gt;/img$ &lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;Et avec des sous-modules, la branche des projets parents est affichée :&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;rom@rom-laptop:~/dev$ cd mybigproject/
rom@rom-laptop:~/dev/mybigproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;$ cd submodule/
rom@rom-laptop:~/dev/mybigproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;/submodule&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;$ git checkout exp
Switched to branch &apos;exp&apos;
rom@rom-laptop:~/dev/mybigproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;/submodule&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@exp&lt;/span&gt;$ cd ..
rom@rom-laptop:~/dev/mybigproject&lt;span style=&quot;font-family:monospace;color:#3264a3&quot;&gt;@master&lt;/span&gt;$ &lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;En image :&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/gitbashprompt/gitbashprompt.png&quot; alt=&quot;gitbashprompt&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;script&quot;&gt;Script&lt;/h2&gt;

&lt;p&gt;Le script, sous licence &lt;a href=&quot;http://www.wtfpl.net/&quot;&gt;WTFPL&lt;/a&gt;, est disponible sur ce dépôt &lt;em&gt;git&lt;/em&gt; :
[gitbashprompt].&lt;/p&gt;

&lt;p&gt;Une fois cloné, éditez le fichier &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.bashrc&lt;/code&gt; pour remplacer l’initialisation de
la variable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PS1&lt;/code&gt; :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;        &lt;span class=&quot;nv&quot;&gt;PS1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;${debian_chroot:+($debian_chroot)}\u@\h:\w\$ &apos;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;par :&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;        &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; full/path/to/your/gitbashprompt&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;em&gt;Pour tester, ouvrir un nouveau terminal.&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Tout d’abord, je suis content d’avoir exactement le comportement que je
souhaitais pour mon &lt;em&gt;git&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Ensuite, j’ai découvert le fonctionnement du prompt, avec notamment les
subtilités d’&lt;a href=&quot;http://fr.wikipedia.org/wiki/Caract%C3%A8re_d%27%C3%A9chappement&quot;&gt;échappement de caractères&lt;/a&gt; de la variable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PS1&lt;/code&gt; et la
prise en compte des caractères de contrôle &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\[&lt;/code&gt; et &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Enfin, je me suis enfin décidé à étudier la gestion des couleurs de &lt;em&gt;Bash&lt;/em&gt; (qui,
à première vue, est assez repoussante, il faut bien l’avouer). Mes scripts
seront donc plus jolis à l’avenir ;-)&lt;/p&gt;
</content>
 </entry>
  
 
  
 
  
   
 <entry>
   <title>Héberger un serveur Jabber simplement (prosody)</title>
   <link href="https://blog.rom1v.com/2012/01/heberger-un-serveur-jabber-simplement-prosody/"/>
   <updated>2012-01-06T22:12:58+01:00</updated>
   <id>https://blog.rom1v.com/2012/01/heberger-un-serveur-jabber-simplement-prosody</id>
   <content type="html">&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/prosody/jabber.png&quot; alt=&quot;jabber&quot; /&gt;&lt;/p&gt;

&lt;p&gt;J’ai enfin décidé d’héberger mon propre serveur &lt;a href=&quot;http://www.jabberfr.org/&quot;&gt;Jabber&lt;/a&gt;, pour plusieurs raisons :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;la liste de mes contacts est mieux sur mon serveur que sur un autre ;&lt;/li&gt;
  &lt;li&gt;le serveur que j’utilisais (&lt;a href=&quot;https://jabber.apinc.org/&quot;&gt;jabber.fr&lt;/a&gt;) rencontre parfois quelques
difficultés ;&lt;/li&gt;
  &lt;li&gt;mon adresse &lt;em&gt;Jabber&lt;/em&gt; sera ainsi la même que &lt;a href=&quot;/2009/08/hebergez-vos-mails-sur-ubuntu-server-et-liberez-vous/&quot;&gt;mon adresse mail&lt;/a&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rom&lt;/code&gt;
suivi de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@rom1v.com&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Et c’est simple !&lt;/p&gt;

&lt;h2 id=&quot;installation-et-configuration&quot;&gt;Installation et configuration&lt;/h2&gt;

&lt;p&gt;Tout d’abord, installer le paquet &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;prosody&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;apt-get install prosody
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Puis ajouter à la fin du fichier &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/prosody/prosody.cfg.lua&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Host &quot;nom.de.domaine&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pour moi :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Host &quot;rom1v.com&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Créer un utilisateur en ligne de commande et choisir un mot de passe :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;prosodyctl adduser utilisateur@nom.de.domaine
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;certificat&quot;&gt;Certificat&lt;/h2&gt;

&lt;p&gt;Un &lt;a href=&quot;http://fr.wikipedia.org/wiki/Certificat_%C3%A9lectronique#Certificat&quot;&gt;certificat&lt;/a&gt; TLS/SSL est créé par défaut, mais les champs sont renseignés
avec des valeurs non pertinentes (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;localhost&lt;/code&gt; au lieu de &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nom.de.domaine&lt;/code&gt; par
exemple). Il est donc préférable d’en &lt;a href=&quot;http://prosody.im/doc/certificates&quot;&gt;générer un nouveau&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Dans le répertoire &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/prosody/certs&lt;/code&gt;, exécuter :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;openssl req -new -x509 -nodes -out nom.de.domaine.cert -keyout \
    nom.de.domaine.key -days 1000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Renseigner les champs demandés &lt;em&gt;(« &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.&lt;/code&gt; » pour laisser un champ vide)&lt;/em&gt;. En
particulier, indiquer dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Common Name&lt;/code&gt; le nom de domaine pour lequel ce
certificat sera utilisé.&lt;/p&gt;

&lt;p&gt;Remplacer le certificat dans le fichier de configuration :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssl = {
        key = &quot;/etc/prosody/certs/nom.de.domaine.key&quot;;
        certificate = &quot;/etc/prosody/certs/nom.de.domaine.cert&quot;;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;empreinte&quot;&gt;Empreinte&lt;/h3&gt;

&lt;p&gt;Comme c’est un certificat auto-signé, les clients &lt;em&gt;Jabber&lt;/em&gt; ne lui feront pas
confiance : ils demanderont une confirmation, en présentant son empreinte. Il
faudra alors vérifier que le certificat présenté est bien le bon, c’est-à-dire
que l’empreinte est la même.&lt;/p&gt;

&lt;p&gt;Pour la connaître :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;openssl x509 -fingerprint -noout -in nom.de.domaine.cert
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Par exemple :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ openssl x509 -fingerprint -noout -in rom1v.com.cert
SHA1 Fingerprint=C3:6D:9B:65:06:55:C4:84:B4:A5:8D:4B:12:68:2F:08:71:7E:AC:DD
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;ports&quot;&gt;Ports&lt;/h2&gt;

&lt;p&gt;Les &lt;a href=&quot;http://fr.wikipedia.org/wiki/Liste_des_ports_logiciels&quot;&gt;ports&lt;/a&gt; TCP 5222 et 5269 &lt;a href=&quot;http://www.accessgrid.org/agdp/guide/ports/1.03/x112.html&quot;&gt;doivent être ouverts&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;démarrer&quot;&gt;Démarrer&lt;/h2&gt;

&lt;p&gt;Il ne reste plus qu’à démarrer le service.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;service prosody start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;clients&quot;&gt;Clients&lt;/h2&gt;

&lt;p&gt;Il est maintenant possible de se connecter en utilisant le nom d’utilisateur et
le mot de passe créés :&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;/assets/prosody/empathy.png&quot; alt=&quot;empathy&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;backup&quot;&gt;Backup&lt;/h2&gt;

&lt;p&gt;Les données du serveur sont stockées dans &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/lib/prosody&lt;/code&gt;. Il est donc
important de ne pas oublier ce répertoire dans le processus de
&lt;a href=&quot;http://fr.wikipedia.org/wiki/Sauvegarde&quot;&gt;sauvegarde&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Merci à &lt;a href=&quot;http://www.cyrille-borne.com/index.php?post/2011/01/13/Faire-son-serveur-jabber-personnel-en-moins-de-5-minutes&quot;&gt;Cyrille Borne&lt;/a&gt; et &lt;a href=&quot;http://blog.nicolargo.com/2011/01/un-serveur-jabber-en-5-minutes-chronos-sous-debianubuntu.html&quot;&gt;nicolargo&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</content>
 </entry>
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 

</feed>
