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

<channel>
	<title>BlueIcefield</title>
	<atom:link href="http://www.blueicefield.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blueicefield.com</link>
	<description>Le savoir n&#039;a de valeur que s&#039;il est partagé</description>
	<lastBuildDate>Sat, 03 Dec 2011 16:45:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Scan&#8217;Mail : un générateur de QR code intégré à Thunderbird</title>
		<link>http://www.blueicefield.com/2011/05/05/scanmail-un-generateur-de-qr-code-integre-a-thunderbird/</link>
		<comments>http://www.blueicefield.com/2011/05/05/scanmail-un-generateur-de-qr-code-integre-a-thunderbird/#comments</comments>
		<pubDate>Thu, 05 May 2011 20:02:45 +0000</pubDate>
		<dc:creator>Nassim</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mes créations]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[qr code]]></category>
		<category><![CDATA[scan]]></category>
		<category><![CDATA[smartphone]]></category>
		<category><![CDATA[thunderbird]]></category>

		<guid isPermaLink="false">http://www.blueicefield.com/?p=807</guid>
		<description><![CDATA[J'ai dernièrement profité de mes temps libres pour développer un module pour le client de messagerie Mozilla Thunderbird,  j'ai nommé celui-ci Scan'Mail. Il permet d'un simple clique droit sur une adresse email, un lien, une image ou une sélection de texte de générer un QR code que vous pourrez scanner à l'aide de votre smartphone [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.blueicefield.com/wp-content/uploads/2011/05/thunderbird.jpg" rel="lightbox[807]"><img class="aligncenter size-full wp-image-808" title="thunderbird" src="http://www.blueicefield.com/wp-content/uploads/2011/05/thunderbird.jpg" alt="" width="600" height="250" /></a></p>
<p>J'ai dernièrement profité de mes temps libres pour développer un module pour le client de messagerie Mozilla Thunderbird,  j'ai nommé celui-ci Scan'Mail. Il permet d'un simple clique droit sur une adresse email, un lien, une image ou une sélection de texte de générer un QR code que vous pourrez scanner à l'aide de votre smartphone (iPhone, Android ou autre) pour récupérer ses informations. C'est un moyen rapide et original de copier des données contenues dans vos emails sans risquer une erreur de retranscription.</p>
<p>J'ai pris beaucoup de plaisir à coder ce petit greffon même si j'ai trouvé la documentation en ligne peu conviviale et parfois incomplète. Je compte améliorer ce premier plugin en ajoutant, dans la prochaine version, le support du format vCard pour pouvoir transférer des contacts.</p>
<p>Je invite à télécharger Scan'Mail via son espace dédié sur le site de Thunderbird et à me laisser vos commentaires :</p>
<p><a href="https://addons.mozilla.org/fr/thunderbird/addon/scanmail/">https://addons.mozilla.org/fr/thunderbird/addon/scanmail/</a></p>
<p>&nbsp;</p>
<div id="crp_related"><h3>Billets similaires:</h3><ul><li><a href="http://www.blueicefield.com/2010/02/11/swissdisk-et-iphone-vos-fichiers-toujours-sous-la-main/" rel="bookmark" class="crp_title">Swissdisk et iphone : Vos fichiers toujours sous la main !</a></li><li><a href="http://www.blueicefield.com/2010/01/13/nouvelle-annee-nouveau-blog/" rel="bookmark" class="crp_title">Nouvelle année, nouveau blog !</a></li><li><a href="http://www.blueicefield.com/2009/08/11/php-generateur-de-documentation/" rel="bookmark" class="crp_title">[PHP] Générateur de documentation</a></li><li><a href="http://www.blueicefield.com/2010/02/11/iphone-et-le-wifi-de-luniversite-nancy2/" rel="bookmark" class="crp_title">iPhone et le wifi de l&#8217;université Nancy2</a></li><li><a href="http://www.blueicefield.com/2010/02/15/securite-culturalnetwork-asso-dz-le-mauvais-exemple/" rel="bookmark" class="crp_title">[Sécurité] CulturalNetwork.asso.dz : le mauvais exemple.</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.blueicefield.com/2011/05/05/scanmail-un-generateur-de-qr-code-integre-a-thunderbird/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>De retour d&#8217;Afrique du sud</title>
		<link>http://www.blueicefield.com/2011/02/21/de-retour-dafrique-du-sud/</link>
		<comments>http://www.blueicefield.com/2011/02/21/de-retour-dafrique-du-sud/#comments</comments>
		<pubDate>Mon, 21 Feb 2011 11:59:57 +0000</pubDate>
		<dc:creator>Nassim</dc:creator>
				<category><![CDATA[Non classé]]></category>
		<category><![CDATA[afrique]]></category>
		<category><![CDATA[afruqie du sud]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[travail]]></category>
		<category><![CDATA[voyage]]></category>

		<guid isPermaLink="false">http://www.blueicefield.com/?p=680</guid>
		<description><![CDATA[Me voilà donc de retour d'un voyage professionnel en Afrique du sud. Que dire de ce pays si ce n'est que je l'ai adoré. Temps radieux, paysages merveilleux, population accueillante... Tout ce qu'il faut pour passer un bon séjour, à noter toutefois, quelques problèmes d'insécurité. Bref, ce retour annonce aussi la publication très rapidement de [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.blueicefield.com/wp-content/uploads/2011/02/afrique_du_sud.jpg" rel="lightbox[680]"><img class="aligncenter size-full wp-image-681" title="afrique_du_sud" src="http://www.blueicefield.com/wp-content/uploads/2011/02/afrique_du_sud.jpg" alt="" width="800" height="300" /></a></p>
<p style="text-align: justify;">Me voilà donc de retour d'un voyage professionnel en Afrique du sud. Que dire de ce pays si ce n'est que je l'ai adoré. Temps radieux, paysages merveilleux, population accueillante... Tout ce qu'il faut pour passer un bon séjour, à noter toutefois, quelques problèmes d'insécurité.</p>
<p style="text-align: justify;">Bref, ce retour annonce aussi la publication très rapidement de nouveaux billets.</p>
<div id="crp_related"><h3>Billets similaires:</h3><ul><li><a href="http://www.blueicefield.com/2010/03/04/most-than-less/" rel="bookmark" class="crp_title">Most than less</a></li><li><a href="http://www.blueicefield.com/2009/11/03/linux-fork-bombing-lart-de-faire-crasher-linux/" rel="bookmark" class="crp_title">[Linux] Fork bombing, l&#8217;art de faire crasher Linux !</a></li><li><a href="http://www.blueicefield.com/2010/02/11/iphone-et-le-wifi-de-luniversite-nancy2/" rel="bookmark" class="crp_title">iPhone et le wifi de l&#8217;université Nancy2</a></li><li><a href="http://www.blueicefield.com/2009/07/03/enregister-une-web-radio/" rel="bookmark" class="crp_title">Enregister une web radio</a></li><li><a href="http://www.blueicefield.com/2008/07/12/installation-de-wvdial-sous-backtrackslackware/" rel="bookmark" class="crp_title">Installation de WVDIAL sous BackTrack/Slackware</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.blueicefield.com/2011/02/21/de-retour-dafrique-du-sud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accélérer vos applications PHP à l&#8217;aide d&#8217;APC</title>
		<link>http://www.blueicefield.com/2010/09/07/accelerer-vos-applications-php-a-laide-dapc/</link>
		<comments>http://www.blueicefield.com/2010/09/07/accelerer-vos-applications-php-a-laide-dapc/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 20:55:53 +0000</pubDate>
		<dc:creator>Nassim</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Internet/Reseaux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[bsd]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[chargement]]></category>
		<category><![CDATA[opcode]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.blueicefield.com/?p=622</guid>
		<description><![CDATA[Le PHP est un langage compilé à la volée, à chaque appel d'une page il y a compilation du code PHP en un code intermédiaire que l'on nomme opcode. Ce mécanisme de compilation systématique est lourd et rallonge sensiblement la durée de traitement des pages PHP. APC (Alternative PHP Cache) est ce qu'on appèle  un [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.blueicefield.com/wp-content/uploads/2010/09/php-optimizer.jpg" rel="lightbox[622]"><img class="aligncenter size-full wp-image-623" title="php-optimizer" src="http://www.blueicefield.com/wp-content/uploads/2010/09/php-optimizer.jpg" alt="" width="650" height="250" /></a></p>
<p>Le <strong><a href="http://fr.wikipedia.org/wiki/PHP" target="_blank">PHP</a></strong> est un langage compilé à la volée, à chaque appel d'une page il y a compilation du code PHP en un code intermédiaire que l'on nomme <strong>opcode</strong>. Ce mécanisme de compilation systématique est lourd et rallonge sensiblement la durée de traitement des pages PHP.</p>
<p>APC (Alternative PHP Cache) est ce qu'on appèle  un cache d'OPCodes. Celui-ci permet donc de stocker en mémoire vive le code compilé des pages PHP et nous épargne ainsi la fastidieuse phase de compilation, les performances générales se retrouvent de ce fait nettement améliorées.</p>
<p>En plus d'être une solution fiable et robuste, APC est gratuit, opensource et relativement simple à installer et à utiliser. Alors pourquoi s'en priver ?</p>
<p>Tout d'abord commençons par préparer l'environnement :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Installation des paquets nécessaires à la compilation d'APC</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-dev php-pear apache2-prefork-dev
&nbsp;
<span style="color: #666666; font-style: italic;"># Création d'un lien symbolique pour éviter un message d'erreur sur certains environnements</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>apxs2 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>apxs</pre></div></div>

<p>Maintenant que nous avons l'ensemble des paquets requis, procédons à l'installation d'APC :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> pecl <span style="color: #c20cb9; font-weight: bold;">install</span> apc
<span style="color: #666666; font-style: italic;"># Répondez 'yes' à la question qui vous sera posée</span></pre></div></div>

<p>Maintenant créons le fichier de configuration d'APC :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>config.d<span style="color: #000000; font-weight: bold;">/</span>apc.ini</pre></div></div>

<p>Et mettez y ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>APC<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Permet de charger le module APC</span>
<span style="color: #007800;">extension</span>=apc.so
&nbsp;
<span style="color: #666666; font-style: italic;"># Permet d'activer le module APC</span>
apc.enabled=<span style="color: #000000;">1</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Taille de l'espace mémoire alloué à APC (en Mo)</span>
apc.shm_size=<span style="color: #000000;">30</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># Taille maximale des fichiers mis en cache</span>
apc.max_file_size=1M 
&nbsp;
<span style="color: #666666; font-style: italic;"># Vérification des modifications de fichiers</span>
apc.stat=<span style="color: #000000;">0</span></pre></div></div>

<p>Il est important de s'attarder un peu sur l'option <em>apc.stat</em>. Si sa valeur est à 1, APC vérifiera à chaque appel d'une page si celle-ci a été modifiée depuis sa mise en cache, ces vérifications systématiques affaiblissent les performances. Sur un serveur de production sur lequel les fichiers sont modifiés rarement, il est préférable de désactiver cette option pour gagner en performances. Dès lors, si un fichier est modifié il faudra vider le cache pour que les modifications soient prises en compte.</p>
<p>Vous pouvez trouver la description complète des options disponibles sur <a href="http://www.php.net/manual/fr/apc.configuration.php" target="_blank">cette page</a>.</p>
<p>Il reste maintenant à redémarrer Apache pour achever l'installation d'APC.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></div></div>

<p>Une fois APC installé, son cache se remplira au fur et à mesure des chargements des pages PHP améliorant ainsi progressivement les performances générales.</p>
<p>Il est possible d'obtenir des informations sur l'état de ce cache via une page web spéciale. Celle-ci n'est pas déployée par défaut sur votre serveur, pour se faire il suffit de la rendre accessible depuis le répertoire de votre serveur web :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Le répertoire de destination peut différer selon la configuration de votre serveur web</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>apc.php <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>apc.php</pre></div></div>

<p>Finissons ce billet avec un petit <a href="http://fr.wikipedia.org/wiki/Benchmark" target="_blank">benchmark</a> histoire d'avoir un aperçu du gain réel apporté par l'utilisation d'APC. Sur la même machine je vais tester, à l'aide de l'utilitaire <em>ab</em> fourni avec <em>apache</em>, les performances d'accès à la page d'accueil d'un site sous <a href="http://fr.wikipedia.org/wiki/Joomla!" target="_blank">Joomla</a> sans puis avec APC d'activé.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Je simule dix utilisateurs qui effectuent dix requêtes chacun</span>
ab <span style="color: #660033;">-n</span> <span style="color: #000000;">10</span> <span style="color: #660033;">-c</span> <span style="color: #000000;">10</span> http:<span style="color: #000000; font-weight: bold;">//</span>127.0.0.1<span style="color: #000000; font-weight: bold;">/</span>joomla<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Le résultat obtenu avant l'activation d'APC :</p>
<p><a href="http://www.blueicefield.com/wp-content/uploads/2010/09/avant_apc.jpg" rel="lightbox[622]"><img class="aligncenter size-full wp-image-645" title="avant_apc" src="http://www.blueicefield.com/wp-content/uploads/2010/09/avant_apc.jpg" alt="" width="526" height="397" /></a></p>
<p>Sans APC il est possible de traiter près de 14 requêtes par seconde.</p>
<p>Le résultat obtenu après l'activation d'APC et le chargement de la page dans le cache :</p>
<p><a href="http://www.blueicefield.com/wp-content/uploads/2010/09/apres_apc.jpg" rel="lightbox[622]"><img class="aligncenter size-full wp-image-647" title="apres_apc" src="http://www.blueicefield.com/wp-content/uploads/2010/09/apres_apc.jpg" alt="" width="524" height="503" /></a></p>
<p>Avec APC activé (avec la page mise en cache ce qui implique une première visite de celle-ci), il devient possible de traiter près de 31 requêtes par seconde soit un gain de performance de facteur deux.</p>
<p>Vous l'aurez compris, APC apporte une véritable amélioration des performances tout en restant simple à déployer. De plus, il offre aussi une fonctionnalité de cache utilisateur que je n'ai pas traité dans ce billet.</p>
<div id="crp_related"><h3>Billets similaires:</h3><ul><li><a href="http://www.blueicefield.com/2010/08/15/geolocalisation-dip-sous-apache2/" rel="bookmark" class="crp_title">Géolocalisation d&#8217;adresses IP sous Apache2</a></li><li><a href="http://www.blueicefield.com/2010/08/19/modifiersupprimer-le-mots-de-passe-dun-compte-windows-depuis-linux/" rel="bookmark" class="crp_title">Réinitialiser le mot de passe d&#8217;un compte Windows depuis Linux</a></li><li><a href="http://www.blueicefield.com/2010/03/04/most-than-less/" rel="bookmark" class="crp_title">Most than less</a></li><li><a href="http://www.blueicefield.com/2010/08/11/tuning-serveur-mysql/" rel="bookmark" class="crp_title">Tuning de serveur MySQL</a></li><li><a href="http://www.blueicefield.com/2010/08/23/sysadmins-friends-screen/" rel="bookmark" class="crp_title">[Sysadmin's friends] Screen</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.blueicefield.com/2010/09/07/accelerer-vos-applications-php-a-laide-dapc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[SysAdmin] Safe-iptables</title>
		<link>http://www.blueicefield.com/2010/09/03/sysadmin-safe-iptables/</link>
		<comments>http://www.blueicefield.com/2010/09/03/sysadmin-safe-iptables/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 22:46:14 +0000</pubDate>
		<dc:creator>Nassim</dc:creator>
				<category><![CDATA[Internet/Reseaux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mes créations]]></category>
		<category><![CDATA[Sécurité]]></category>
		<category><![CDATA[commande]]></category>
		<category><![CDATA[confirmation]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shorewall]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.blueicefield.com/?p=607</guid>
		<description><![CDATA[Lorsqu'on est administrateur systèmes et réseaux spécialisé dans le logiciel libre, on bosse la majorité du temps sur des serveurs GNU/Linux ou BSD, ce qui implique une utilisation privilégiée de la console ainsi que du protocole SSH pour les accès distants. L'un des risques que l'ont encoure est de perdre cet accès SSH suite à [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.blueicefield.com/wp-content/uploads/2010/09/networking.jpg" rel="lightbox[607]"><img class="aligncenter size-full wp-image-608" title="networking" src="http://www.blueicefield.com/wp-content/uploads/2010/09/networking.jpg" alt="" width="650" height="250" /></a></p>
<p>Lorsqu'on est administrateur systèmes et réseaux spécialisé dans le logiciel libre, on bosse la majorité du temps sur des serveurs GNU/Linux ou BSD, ce qui implique une utilisation privilégiée de la console ainsi que du protocole <a href="http://fr.wikipedia.org/wiki/Secure_Shell" target="_blank">SSH</a> pour les accès distants.</p>
<p>L'un des risques que l'ont encoure est de perdre cet accès SSH suite à une fausse manipulation, plus particulièrement lors de l'ajout d'une règle de <a href="http://fr.wikipedia.org/wiki/Pare-feu_%28informatique%29" target="_blank">firewall</a>.</p>
<p>Personnellement, je travaille essentiellement sur des serveurs localisés en Afrique du sud, une telle erreur serait donc dramatique car je perdrais mon unique voie d'accès. Pour éviter de me retrouver dans une telle situation, j'ai codé en <a href="http://fr.wikipedia.org/wiki/Bourne-Again_shell" target="_blank">Bash</a> une petite commande pour adapter à <a href="http://fr.wikipedia.org/wiki/Iptables">iptables</a> le mécanisme de confirmation qui existe sur <a href="http://www.shorewall.net" target="_blank">Shorewall</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Safe-iptables</span>
<span style="color: #666666; font-style: italic;"># Author  : Nassim Kacha</span>
<span style="color: #666666; font-style: italic;"># License : GNU GPL2</span>
<span style="color: #666666; font-style: italic;"># Date    : 30/08/2010</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Exit codes</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># O Normal execution</span>
<span style="color: #666666; font-style: italic;"># 1 Can't save previous firewalling rules</span>
<span style="color: #666666; font-style: italic;"># 2 Bad arguments</span>
<span style="color: #666666; font-style: italic;"># 3 Missing root privileges</span>
<span style="color: #666666; font-style: italic;"># 4 Changements aborted by user</span>
&nbsp;
<span style="color: #007800;">TIME</span>=<span style="color: #000000;">5</span> <span style="color: #666666; font-style: italic;"># Can be customized</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$TMPDIR</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
     <span style="color: #007800;">TMPDIR</span>=<span style="color: #ff0000;">'/tmp'</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">TMPFILE</span>=<span style="color: #000000; font-weight: bold;">`/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">mktemp</span> <span style="color: #660033;">--tmpdir</span>=<span style="color: #007800;">$TMPDIR</span> iptables_XXXXX<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
privilege_checking<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">id</span> -u<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
		<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Sorry, you must run the command as root !&quot;</span>
		<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">3</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
main<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-t</span> <span style="color: #007800;">$TIME</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;Are you sure ? [y/N]&quot;</span> key
	<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$key</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
  		y<span style="color: #000000; font-weight: bold;">|</span>Y <span style="color: #7a0874; font-weight: bold;">&#41;</span>
				<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$TMPFILE</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;n+ Rule applied&quot;</span>
				<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
		n<span style="color: #000000; font-weight: bold;">|</span>N<span style="color: #000000; font-weight: bold;">|</span><span style="color: #ff0000;">''</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span>
				<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables-restore <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TMPFILE</span>
				<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$TMPFILE</span>
				<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;n- Rule not applied&quot;</span>
			  	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#41;</span> 	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">''</span>
				main<span style="color: #000000; font-weight: bold;">;;</span>
	<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Main ###</span>
privilege_checking
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables-save <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$TMPFILE</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Error : not possible to save the previous firewall rules&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #007800;">$*</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	main
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">2</span></pre></div></div>

<p>Cette commande fonctionne exactement de la même manière que la commande <em><strong>iptables</strong></em> à ceci près qu'elle vous demande une confirmation après avoir appliqué la nouvelle règle de pare-feu. Ainsi, si votre règle est mauvaise et qu'elle vous coupe votre liaison SSH, elle sera annulée après cinq seconde faute d'avoir pu confirmer la commande. Cela apporte donc une sécurité non négligeable lors de l'édition de vos règles de firewalling.</p>
<p>Je vous recommande d'enregistrer le code ci-dessus sous un fichier<em> /usr/sbin/safe-iptables</em>, de l'attribuer à l'utilisateur <em>root</em> et de lui donner les permissions 755. Il est aussi  judicieux d'insérer un alias dans votre fichier <strong>.bashrc</strong> qui remplacerait la commande <strong><em>iptables</em></strong> par <strong><em>safe-iptables</em></strong>.</p>
<p>Je compte packager ce script en <a href="http://fr.wikipedia.org/wiki/Deb" target="_blank">DEB</a> et en <a href="http://fr.wikipedia.org/wiki/RPM_Package_Manager" target="_blank">RPM</a> dès que possible. Pour finir, je vous encourage à reprendre et à améliorer ce script si vous avez des idées supplémentaires.</p>
<p>EDIT 04/09/2010 : Modification du script suite aux excellentes remarques de TixxDZ.</p>
<div id="crp_related"><h3>Billets similaires:</h3><ul><li><a href="http://www.blueicefield.com/2010/08/19/modifiersupprimer-le-mots-de-passe-dun-compte-windows-depuis-linux/" rel="bookmark" class="crp_title">Réinitialiser le mot de passe d&#8217;un compte Windows depuis Linux</a></li><li><a href="http://www.blueicefield.com/2009/10/04/securitelinux-chroot-break/" rel="bookmark" class="crp_title">[Sécurité/Linux] Chroot Break</a></li><li><a href="http://www.blueicefield.com/2010/02/12/capivara-gestionnaire-de-fichiers-supportant-le-ftp-et-le-sftp/" rel="bookmark" class="crp_title">Capivara : Gestionnaire de fichiers supportant le FTP et le SFTP</a></li><li><a href="http://www.blueicefield.com/2010/03/01/richard-stallman-et-la-revolution-du-logiciel-libre/" rel="bookmark" class="crp_title">Richard Stallman et la révolution du logiciel libre</a></li><li><a href="http://www.blueicefield.com/2010/08/15/geolocalisation-dip-sous-apache2/" rel="bookmark" class="crp_title">Géolocalisation d&#8217;adresses IP sous Apache2</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.blueicefield.com/2010/09/03/sysadmin-safe-iptables/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[Sysadmin&#039;s friends] Screen</title>
		<link>http://www.blueicefield.com/2010/08/23/sysadmins-friends-screen/</link>
		<comments>http://www.blueicefield.com/2010/08/23/sysadmins-friends-screen/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 21:49:28 +0000</pubDate>
		<dc:creator>Nassim</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[commande]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[partagé]]></category>
		<category><![CDATA[planetlibre]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.blueicefield.com/?p=588</guid>
		<description><![CDATA[Ce billet inaugure une toute nouvelle rubrique baptisée : Sysadmin's  friends (en français : les amis de l'admin sys). Non...non... mon intention n'est pas de vous présenter un pote à moi chaque semaine, il n'y aurait pas de quoi tenir un mois, nooooon je déconne ! Plus sérieusement, l'idée est donc de vous présenter régulièrement [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.blueicefield.com/wp-content/uploads/2010/08/friends.jpg" rel="lightbox[588]"><img class="aligncenter size-full wp-image-589" title="friends" src="http://www.blueicefield.com/wp-content/uploads/2010/08/friends.jpg" alt="" width="650" height="250" /></a></p>
<p>Ce billet inaugure une toute nouvelle rubrique baptisée : Sysadmin's  friends (en français : les amis de l'admin sys). Non...non... mon intention n'est pas de vous présenter un pote à moi chaque semaine, il n'y aurait pas de quoi tenir un mois, nooooon je déconne !</p>
<p>Plus sérieusement, l'idée est donc de vous présenter régulièrement un petit outil qui apporte énormément au quotidien d'un administrateur système et réseau.</p>
<p>Pour cette première, j'ai choisi de vous présenter <strong>screen</strong>, un multiplexeur de terminaux en mode texte (réflexion personnelle :  voilà, j'ai largué la moitié de mon audiance rien qu'avec cette phrase).  Pour faire plus simple, <strong>screen</strong> permet  en quelque sorte d'avoir plusieurs terminaux dans une seule fenêtre.</p>
<p>Trêve de bavardages, passons aux choses pratiques :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Installation de screen sous Debian/Ubuntu</span>
<span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">screen</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Installation de screen sous CentOS/Fedora/RHEL</span>
yum <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">screen</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Installation de screen sous Archlinux</span>
pacman <span style="color: #660033;">-S</span> <span style="color: #c20cb9; font-weight: bold;">screen</span></pre></div></div>

<p><strong>Lesson number one :</strong></p>
<p>Pour lancer screen depuis votre terminal, il suffit de taper</p>

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

<p>(ouahhh comment il est fort lui !).</p>
<p><strong>Lesson number two :</strong></p>
<p>Pour afficher le numéro de fenêtre (de terminal, de shell) sur lequel nous sommes, il suffit de presser CTRL+A puis W. Vous verrez normalement s'afficher dans le coin inférieur gauche de votre terminal la mention suivante : 0*$ bash. Le nombre zéro suivi d'une étoile signifie que nous sommes sur la première session (ou premier terminal).</p>
<p><strong>Lesson number three :</strong></p>
<p>Avant d'aller plus loin, lançons la commande <strong><em>top</em></strong> qui affiche des statistiques systèmes. Maintenant, faites CTRL+A puis C, vous devriez vous retrouvez à nouveau avec un terminal vide. Faites CTRL+A puis W, que remarquez vous ? Oui oui, c'est bien cela, vous êtes passés à une seconde session.</p>
<p><strong>Lesson number four :</strong></p>
<p>Maintenant je pense que vous aimeriez bien savoir comment retourner à votre session précédente non ? Et bien diverses possibilités s'offrent à vous.</p>
<p><em>CTRL+A puis P</em> : Permet de passer à la session précédente.</p>
<p><em>CTRL+A puis N</em> : Permet de passer à la session suivante.</p>
<p><em>CTRL+A puis n</em> : n étant numéro de session que l'on désire atteindre.</p>
<p><strong>Lesson number five :</strong></p>
<p>Bon là, je vous vois dubitatif compte à l'intérêt de cette commande étant donné que les onglets existent déjà sur le shell de votre Gnome ou de votre KDE.</p>
<p>C'est là qu'intervient cette avant dernière leçon ! Quand vous utilisez le terminal de KDE ou de Gnome avec différents onglets, si vous fermez votre terminal et bien vous perdez logiquement l'ensemble de vos onglets... et inévitablement les commandes qui étaient lancées sont interrompues.</p>
<p>Et bien... petite démo !</p>
<p>Positionnez-vous sur la première session où la commande top a été lancée : CTRL+A puis 0 (c'est un zéro et non la lettre o de l'alphabet). Puis faites, CTRL+A puis D. Oupsss ! Tout a disparu ! C'est normal ne paniquez pas ! Maintenant, fermez complètement votre fenêtre de terminal (si vous êtes en environnement graphique bien entendu).</p>
<p>Re-ouvrez une fenêtre terminal et tapez : <strong>screen -r</strong>. Et là comme par miracle, vous vous retrouvez sur votre première session avec la commande <strong>top</strong> qui tourne toujours. Grâce à cette spécificité, vous pouvez utiliser screen lors d'une connexion SSH pour pouvoir lancer une commande sur une machine distante puis vous en déconnecter tout en laissant la commande continuer son exécution, il vous sera même possible de vous reconnecter par la suite en SSH et de reprendre votre session pour vérifier l'état d'exécution de la commande précédemment lancée.</p>
<p><strong>Lesson number six : </strong></p>
<p>Une dernière petite leçon en guise de "pompon sur la gâteau", en effet, je ne pouvais pas clore cet article sans parler du partage de session via SSH à l'aide de <strong>screen</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Admettons que titi veut partager l'écran de sa machine avec toto qui possède un accès SSH sur celle-ci.</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Sur la machine de titi</span>
<span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-S</span> nom_de_session
&nbsp;
<span style="color: #666666; font-style: italic;"># Faites CTRL+A puis</span>
:multiuser on
&nbsp;
<span style="color: #666666; font-style: italic;"># Faites CTRL+A puis</span>
:acladd toto
&nbsp;
<span style="color: #666666; font-style: italic;"># Depuis la machine de toto :</span>
<span style="color: #c20cb9; font-weight: bold;">ssh</span> toto<span style="color: #000000; font-weight: bold;">@</span>ip_machine_titi
<span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-x</span> titi<span style="color: #000000; font-weight: bold;">/</span>nom_de_session</pre></div></div>

<p>Voilà, maintenant vous savez comment partager vos sessions entre deux machines via SSH. A très bientôt les zouzous !</p>
<div id="crp_related"><h3>Billets similaires:</h3><ul><li><a href="http://www.blueicefield.com/2010/03/04/most-than-less/" rel="bookmark" class="crp_title">Most than less</a></li><li><a href="http://www.blueicefield.com/2007/11/25/linux-installation-des-modems-huawei-ets207722772288/" rel="bookmark" class="crp_title">[Linux] Installation des modems HUAWEI ETS2077/2277/2288</a></li><li><a href="http://www.blueicefield.com/2007/11/25/opensuse-103-installation-du-driver-des-cartes-graphiques-nvidia/" rel="bookmark" class="crp_title">[OpenSuSE 10.3] Installation du driver des cartes graphiques Nvidia</a></li><li><a href="http://www.blueicefield.com/2009/10/20/linux-securiser-grub/" rel="bookmark" class="crp_title">[Linux] Sécuriser GRUB</a></li><li><a href="http://www.blueicefield.com/2007/11/25/opensuse-103-installation-de-virtualbox/" rel="bookmark" class="crp_title">[OpenSuSE 10.3] Installation de VirtualBox</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.blueicefield.com/2010/08/23/sysadmins-friends-screen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

