<?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>blog.nicolas.pawlak.fr</title>
	<atom:link href="http://blog.nicolas.pawlak.fr/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nicolas.pawlak.fr</link>
	<description>Tux ne sait pas voler, c&#039;est normal : ce n&#039;est pas un pingouin...</description>
	<lastBuildDate>Sun, 31 Jul 2011 14:56:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Script shell vérifiant la disponibilité d&#8217;un nom de domaine</title>
		<link>http://blog.nicolas.pawlak.fr/2011/07/11/script-shell-verifiant-la-disponibilite-dun-nom-de-domaine/</link>
		<comments>http://blog.nicolas.pawlak.fr/2011/07/11/script-shell-verifiant-la-disponibilite-dun-nom-de-domaine/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 21:15:27 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[disponible]]></category>
		<category><![CDATA[domaine]]></category>
		<category><![CDATA[nom]]></category>
		<category><![CDATA[script]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1442</guid>
		<description><![CDATA[Un petit script pour déterminer si un nom de domaine est libre ou déjà déposé. Les serveurs whois des différents registres de premier niveau renvoyant des réponses structurées différemment, il faut déterminer pour chaque TLD la réponse-type correspondant à un nom de domaine libre et l&#8217;inclure dans le script. Voici ce que retourne une requête [...]]]></description>
			<content:encoded><![CDATA[<p>Un petit script pour déterminer si un <a href="http://fr.wikipedia.org/wiki/Nom_de_domaine" title="nom de domaine" target="_blank">nom de domaine</a> est libre ou déjà déposé. </p>
<p>Les serveurs <a href="http://fr.wikipedia.org/wiki/Whois" title="whois" target="_blank">whois</a> des différents <a href="http://fr.wikipedia.org/wiki/Registre_(Noms_de_domaine)" title="registres" target="_blank">registres de premier niveau</a> renvoyant des réponses structurées différemment, il faut déterminer pour chaque <a href="http://fr.wikipedia.org/wiki/Domaine_de_premier_niveau" title="TLD" target="_blank">TLD</a> la réponse-type correspondant à un nom de domaine libre et l&#8217;inclure dans le script. </p>
<p>Voici ce que retourne une requête whois sur &laquo;&nbsp;domainequinexistesurementpas.fr&nbsp;&raquo; :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@pc-linux]# whois domainequinexistesurementpas.fr
[Requête en cours whois.nic.fr]
[whois.nic.fr]
%%
%% This is the AFNIC Whois server.
%%
%% complete date format : DD/MM/YYYY
%% short date format    : DD/MM
%% version              : FRNIC-2.5
%%
%% Rights restricted by copyright.
%% See http://www.afnic.fr/afnic/web/mentions-legales-whois_en
%%
%% Use '-h' option to obtain more information about this service.
%%
%% [XX.XX.XX.XX REQUEST] &gt;&gt; domainequinexistesurementpas.fr
%%
%% RL Net [##########] - RL IP [#########.]
%%
&nbsp;
%% No entries found in the AFNIC Database.</pre></div></div>
<p>A présent, la même requête sur &laquo;&nbsp;domainequinexistesurementpas.it&nbsp;&raquo; :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@pc-linux]# whois domainequinexistesurementpas.it
[Requête en cours whois.nic.it]
[whois.nic.it]
Domain:             domainequinexistesurementpas.it
Status:             AVAILABLE</pre></div></div>
<p>Les deux réponses sont totalement différentes (&laquo;&nbsp;No entries found in the AFNIC Database&nbsp;&raquo; pour le .fr, &laquo;&nbsp;Status: AVAILABLE&nbsp;&raquo; pour le .it). Il est donc indispensable de prendre en compte, pour chaque TLD, la réponse-type correspondant à un nom de domaine libre.</p>
<p>En cas d&#8217;interrogation sur un TLD qui n&#8217;a pas été prévu dans le script, ce dernier retourne : &laquo;&nbsp;TLD NON PRIS EN COMPTE&nbsp;&raquo;.</p>
<p>Une particularité du script : placer dans une variable dans une autre variable. Cette particularité apparaît au moment de filtrer la réponse avec la réponse-type correspondant au TLD : la commande <em>grep</em> doit prendre en paramètre le contenu de la variable correspondant à la réponse-type du TLD, mais le nom de cette variable n&#8217;est pas fixe.</p>
<p><strong>Le script :</strong></p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># On place dans une variable le TLD du domaine interrogé.</span>
<span style="color: #666666; font-style: italic;"># Le . est remplacé par _ (cas du .co.uk notamment) pour des raisons de noms de variables.</span>
<span style="color: #007800;">tld</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$1</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-f</span> <span style="color: #000000;">2</span>- <span style="color: #660033;">-d</span> . <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;s/\./_/&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># On place pour chaque TLD la réponse-type d'un domaine libre dans une variable.</span>
<span style="color: #666666; font-style: italic;"># La variable porte le nom du TLD, avec le _ remplaçant le . si nécessaire.</span>
<span style="color: #007800;">fr</span>=<span style="color: #ff0000;">&quot;No entries found&quot;</span>
<span style="color: #007800;">be</span>=<span style="color: #ff0000;">&quot;Status:      FREE&quot;</span>
<span style="color: #007800;">ch</span>=<span style="color: #ff0000;">&quot;We do not have an entry&quot;</span>
<span style="color: #007800;">de</span>=<span style="color: #ff0000;">&quot;Status: free&quot;</span>
<span style="color: #007800;">it</span>=<span style="color: #ff0000;">&quot;Status:             AVAILABLE&quot;</span>
<span style="color: #007800;">pl</span>=<span style="color: #ff0000;">&quot;No information available&quot;</span>
<span style="color: #007800;">pt</span>=<span style="color: #ff0000;">&quot;no match&quot;</span>
<span style="color: #007800;">fi</span>=<span style="color: #ff0000;">&quot;Domain not found&quot;</span>
<span style="color: #007800;">no</span>=<span style="color: #ff0000;">&quot;No match&quot;</span>
<span style="color: #007800;">nl</span>=<span style="color: #ff0000;">&quot;is free&quot;</span>
<span style="color: #007800;">dk</span>=<span style="color: #ff0000;">&quot;No entries found&quot;</span>
<span style="color: #007800;">ru</span>=<span style="color: #ff0000;">&quot;No entries found&quot;</span>
<span style="color: #007800;">at</span>=<span style="color: #ff0000;">&quot;nothing found&quot;</span>
<span style="color: #007800;">co_uk</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">net_uk</span>=<span style="color: #ff0000;">&quot;Not match for&quot;</span>
<span style="color: #007800;">org_uk</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">uk</span>=<span style="color: #ff0000;">&quot;Error for&quot;</span>
<span style="color: #007800;">com</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">net</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">org</span>=<span style="color: #ff0000;">&quot;NOT FOUND&quot;</span>
<span style="color: #007800;">info</span>=<span style="color: #ff0000;">&quot;NOT FOUND&quot;</span>
<span style="color: #007800;">biz</span>=<span style="color: #ff0000;">&quot;Not found&quot;</span>
<span style="color: #007800;">ws</span>=<span style="color: #ff0000;">&quot;No match for&quot;</span>
<span style="color: #007800;">edu</span>=<span style="color: #ff0000;">&quot;No Match&quot;</span>
<span style="color: #007800;">xxx</span>=<span style="color: #ff0000;">&quot;No match for&quot;</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;">$1</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;PARAMETRE MANQUANT&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <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;">$2</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <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: #ff0000;">&quot;<span style="color: #007800;">${!tld}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                        <span style="color: #666666; font-style: italic;"># Aucune variable n'est nommée comme le TLD : pas de réponse-type</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;TLD NON PRIS EN COMPTE&quot;</span>
                <span style="color: #000000; font-weight: bold;">else</span>
                        <span style="color: #666666; font-style: italic;"># On filtre la réponse du whois avec la réponse-type du TLD.</span>
                        <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: #ff0000;">&quot;<span style="color: #780078;">`whois $1 | grep &quot;${!tld}&quot;`</span>&quot;</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;ENREGISTRE&quot;</span>
                        <span style="color: #000000; font-weight: bold;">else</span>
                                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;LIBRE&quot;</span>
                        <span style="color: #000000; font-weight: bold;">fi</span>
                <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;PARAMETRE EN TROP&quot;</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>
<p>Le script en action :</p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./dispo_ndd.sh domaine.fr</span>
ENREGISTRE
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./dispo_ndd.sh domaine-existepas.fr</span>
LIBRE
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>pc-linux<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./dispo_ndd.sh domaine.ca</span>
DOMAINE NON DISPONIBLE</pre></div></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2011/07/11/script-shell-verifiant-la-disponibilite-dun-nom-de-domaine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Manipulations sur les adresses e-mail d&#8217;une table sur MySQL</title>
		<link>http://blog.nicolas.pawlak.fr/2011/03/05/manipulations-sur-les-adresses-e-mail-dune-table-sur-mysql/</link>
		<comments>http://blog.nicolas.pawlak.fr/2011/03/05/manipulations-sur-les-adresses-e-mail-dune-table-sur-mysql/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 18:30:38 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1374</guid>
		<description><![CDATA[Supposons un intranet d&#8217;entreprise sur un domaine &#171;&#160;domaine.fr&#160;&#187;, avec messagerie électronique en @domaine.fr pour tous les utilisateurs. Arrive le jour où l&#8217;architecture de l&#8217;intranet fait l&#8217;objet d&#8217;une évolution passant par le changement de domaine : domaine.fr devient intranet.nom.fr. Il va falloir, sur nombre de tables, modifier toutes les adresses e-mail de tous les utilisateurs. Il [...]]]></description>
			<content:encoded><![CDATA[<p>Supposons un <a href="http://www.commentcamarche.net/contents/entreprise/intranet.php3">intranet</a> d&#8217;entreprise sur un domaine &laquo;&nbsp;domaine.fr&nbsp;&raquo;, avec messagerie électronique en @domaine.fr pour tous les utilisateurs. </p>
<p>Arrive le jour où l&#8217;architecture de l&#8217;intranet fait l&#8217;objet d&#8217;une évolution passant par le changement de domaine : <em>domaine.fr</em> devient <em>intranet.nom.fr</em>. Il va falloir, sur nombre de tables, modifier toutes les adresses e-mail de tous les utilisateurs. Il faudra peut-être gérer, pour certains cas, des adresses e-mail mal orthographiées (domiane.fr), avec une <a href="http://fr.wikipedia.org/wiki/Sensibilité_à_la_casse">casse</a> différente (DOMAINE.FR), ou, comme j&#8217;ai pu le constater récemment sur un <a href="http://fr.wikipedia.org/wiki/Logiciel_de_suivi_de_problèmes"><em>bug tracker</em></a> où les utilisateurs s&#8217;inscrivaient eux-mêmes, des domaines totalement différents de celui mis en place (gmail.com)&#8230; voire pas de domaine du tout (simple nom d&#8217;utilisateur sous la forme prenom.nom) !</p>
<p>La simplicité voudrait que l&#8217;on édite le <a href="http://fr.wikipedia.org/wiki/Dump">dump</a> de la base de données avec son éditeur de texte favori (<a href="http://notepad-plus-plus.org/">Notepad++</a> sur Windows, <a href="http://fr.wikipedia.org/wiki/Vi">vi</a> sous Linux&#8230; en ce qui me concerne) et que l&#8217;on fasse les modifications avec une fonction de remplacement de texte. Seulement, l&#8217;hétérogénéité des adresses e-mail enregistrées et surtout la taille du dump sont deux freins non négligeables à cette solution. Ouvrir un dump de 1 Go avec Notepad++ ? Impensable ! Exporter uniquement les tables où figurent les adresses e-mail, puis ensuite les réinjecter ? Pourquoi pas, mais en fonction des outils mis en place sur l&#8217;intranet, cette méthode peut se réveler fastidieuse. Modifier manuellement dans la table les adresses e-mail ? Oui pour quelques utilisateurs, non pour plusieurs dizaines voire centaines d&#8217;utilisateurs.</p>
<p>Il y a une solution simple, efficace et rapide avec MySQL. Démonstration :</p>
<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">DESC</span> users;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------+-------------+------+-----+---------+-------+ </span>
<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">FIELD</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TYPE</span>        <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #66cc66;">|</span> Extra <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------+-------------+------+-----+---------+-------+ </span>
<span style="color: #66cc66;">|</span> email <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span> YES  <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span>    <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------+-------------+------+-----+---------+-------+ </span>
<span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">ROW</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.05</span> sec<span style="color: #66cc66;">&#41;</span>
&nbsp;
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> users;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------------------------+ </span>
<span style="color: #66cc66;">|</span> email                         <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------------------------+ </span>
<span style="color: #66cc66;">|</span> sergent<span style="color: #66cc66;">.</span>bellec                <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> capitaine<span style="color: #66cc66;">.</span>flamme@DOMAINE<span style="color: #66cc66;">.</span>FR   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> lieutenant<span style="color: #66cc66;">.</span>columbo@domaine<span style="color: #66cc66;">.</span>fr <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> colonel<span style="color: #66cc66;">.</span>moutarde@youpi<span style="color: #66cc66;">.</span>fr     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-------------------------------+ </span>
<span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">ROWS</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.05</span> sec<span style="color: #66cc66;">&#41;</span>
&nbsp;
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">UPDATE</span> users <span style="color: #993333; font-weight: bold;">SET</span> email<span style="color: #66cc66;">=</span>concat<span style="color: #66cc66;">&#40;</span>substring_index<span style="color: #66cc66;">&#40;</span>email<span style="color: #66cc66;">,</span><span style="color: #ff0000;">'@'</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">'@intranet.nom.fr'</span><span style="color: #66cc66;">&#41;</span>;
Query OK<span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">ROWS</span> affected <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">ROWS</span> matched: <span style="color: #cc66cc;">4</span>  Changed: <span style="color: #cc66cc;">4</span>  Warnings: <span style="color: #cc66cc;">0</span>
&nbsp;
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> users;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">------------------------------------+ </span>
<span style="color: #66cc66;">|</span> email                              <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">------------------------------------+ </span>
<span style="color: #66cc66;">|</span> sergent<span style="color: #66cc66;">.</span>bellec@intranet<span style="color: #66cc66;">.</span>nom<span style="color: #66cc66;">.</span>fr     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> capitaine<span style="color: #66cc66;">.</span>flamme@intranet<span style="color: #66cc66;">.</span>nom<span style="color: #66cc66;">.</span>fr   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> lieutenant<span style="color: #66cc66;">.</span>columbo@intranet<span style="color: #66cc66;">.</span>nom<span style="color: #66cc66;">.</span>fr <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> colonel<span style="color: #66cc66;">.</span>moutarde@intranet<span style="color: #66cc66;">.</span>nom<span style="color: #66cc66;">.</span>fr   <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">------------------------------------+ </span>
<span style="color: #cc66cc;">4</span> <span style="color: #993333; font-weight: bold;">ROWS</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.00</span> sec<span style="color: #66cc66;">&#41;</span></pre></div></div>
<p>Explications :</p>
<p>- La fonction <em><a href="http://dev.mysql.com/doc/refman/5.0/fr/string-functions.html">substring_index</a></em> permet de découper la valeur d&#8217;un champ avec un délimiteur ;<br />
- La fonction <em><a href="http://dev.mysql.com/doc/refman/5.0/fr/string-functions.html">concat</a></em> permet de concaténer (ah bon ?) deux éléments.</p>
<p>Grâce à ces deux fonctions, la requête récupère pour chaque utilisateur la partie avant l&#8217;arobase, y ajoute la valeur &laquo;&nbsp;@intranet.nom.fr&nbsp;&raquo; et met à jour le champ. Tout simplement.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2011/03/05/manipulations-sur-les-adresses-e-mail-dune-table-sur-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Censure dans les noms de pages Facebook : un cache-misère</title>
		<link>http://blog.nicolas.pawlak.fr/2010/12/03/censure-dans-les-noms-de-pages-facebook-un-cache-misere/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/12/03/censure-dans-les-noms-de-pages-facebook-un-cache-misere/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 07:00:34 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Sécurité informatique]]></category>
		<category><![CDATA[censure]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[faille]]></category>
		<category><![CDATA[filtre]]></category>
		<category><![CDATA[groupes]]></category>
		<category><![CDATA[pages]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1336</guid>
		<description><![CDATA[Note importante : La page présentée n&#8217;a été créée que dans l&#8217;unique but de servir d&#8217;illustration à cet article. Elle n&#8217;existe plus, et a été initiée depuis un compte créé lui aussi à cet effet. Par ailleurs, son intitulé ne reflète en rien la pensée de l&#8217;auteur de cet article. Il est volontairement &#171;&#160;choquant&#160;&#187; pour [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
<p align="center">Note importante :</p>
<p>La page présentée n&#8217;a été créée que dans l&#8217;unique but de servir d&#8217;illustration à cet article. Elle n&#8217;existe plus, et a été initiée depuis un compte créé lui aussi à cet effet. Par ailleurs, son intitulé ne reflète en rien la pensée de l&#8217;auteur de cet article. Il est volontairement &laquo;&nbsp;choquant&nbsp;&raquo; pour permettre de ne pas passer, dans un premier temps, les mailles de la censure Facebook.</p>
</blockquote>
<p>L&#8217;une des fonctionnalités de <a href="http://www.facebook.com">Facebook</a>, très prisée par une certaine tranche d&#8217;âge des utilisateurs, est le système de <a href="http://www.facebook.com/pages/">pages</a> / <a href="http://www.facebook.com/groups/">groupes</a>. Une page ou un groupe fédère des utilisateurs autour d&#8217;un point commun, qu&#8217;il soit sérieux (une enseigne de magasin, un artiste) ou totalement absurde.</p>
<p>Par mesure de précaution, une censure est mise en place au moment de créer une page ou un groupe, afin d&#8217;empêcher l&#8217;existence de pages telles que &laquo;&nbsp;j&#8217;aime la cocaïne&nbsp;&raquo; ou &laquo;&nbsp;Vive Marc Dutroux !&nbsp;&raquo;. Tout ceci est parfaitement normal.</p>
<p>Toutefois, cette censure a ses limites, bien vite atteintes. Le but de cet article est d&#8217;en faire la démonstration, afin de &laquo;&nbsp;dénoncer&nbsp;&raquo; le manque de professionnalisme de la société Facebook dans ses obligations de sécurisation du site.</p>
<p><strong>1. Première tentative de création d&#8217;une page</strong></p>
<p><a href="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb1.jpg"><img src="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb1.jpg" alt="" title="fb1" width="500px" class="aligncenter size-full wp-image-1338" /></a></p>
<p>Ici, le nom &laquo;&nbsp;Faire l&#8217;apologie de crimes de guerre&nbsp;&raquo; est clairement refusé.</p>
<p>&nbsp;</p>
<p><strong>2. Seconde tentative de création d&#8217;une page</strong></p>
<p><a href="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb2.jpg"><img src="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb2.jpg" alt="" title="fb2" width="500px" class="aligncenter size-full wp-image-1345" /></a></p>
<p>Le nom de la page demandée est &laquo;&nbsp;FAIRE L&#8217;APOLOGIE DE CRIMES DE GUERRE&nbsp;&raquo;. Encore une fois, refus. A noter que le nom, dans le champ, a une <a href="http://fr.wikipedia.org/wiki/Sensibilité_à_la_casse">casse</a> différente : le changement provient de Facebook, qui semble ne pas aimer les noms intégralement rédigés en majuscules.</p>
<p>&nbsp;</p>
<p><strong>3. Troisième tentative de création d&#8217;une page</strong></p>
<p><a href="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb3.jpg"><img src="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb3.jpg" alt="" title="fb3" width="500px" class="aligncenter size-full wp-image-1346" /></a></p>
<p>Et bien oui ! En changeant le nom de la page demandée pour &laquo;&nbsp;FaiRe L&#8217;aPoLoGie De CRiMeS De GueRRe&nbsp;&raquo;, le filtre n&#8217;y voit que du feu et valide la création. Rien n&#8217;a changé par rapport aux deux tentatives précédentes&#8230; si ce n&#8217;est la casse particulière de celle-ci.</p>
<p>&nbsp;</p>
<p><strong>4. Conséquence</strong></p>
<p><a href="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb4.jpg"><img src="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb4.jpg" alt="" title="fb4" class="aligncenter size-full wp-image-1347" /></a></p>
<p>Grâce à Facebook, n&#8217;importe quel utilisateur peut désormais déclarer aimer l&#8217;apologie de crimes de guerre, malgré le semblant de protection mis en place.</p>
<p>&nbsp;</p>
<p><strong>5. Tentative post-création</strong></p>
<p><a href="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb6.jpg"><img src="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb6.jpg" alt="" title="fb6" width="500px" class="aligncenter size-full wp-image-1349" /></a></p>
<p>Cerise sur le gâteau : grâce à l&#8217;interface de gestion de la page, il est possible de demander le changement de nom pour celui qui nous avait été refusé à la première étape de cette démonstration. Où est le filtre ?</p>
<p>&nbsp;</p>
<p><strong>6. Résultat final</strong></p>
<p><a href="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb7.jpg"><img src="http://blog.nicolas.pawlak.fr/wp-content/uploads/2010/12/fb7.jpg" alt="" title="fb7" width="500px" class="aligncenter size-full wp-image-1351" /></a></p>
<p>Malgré le filtre présent à la création de la page, il est tout à fait possible de nommer une page sans contrainte sur les termes choisis. Il est inquiétant de constater que Facebook semble prendre, une fois de plus, la question de la sécurité à la légère.</p>
<p>Il est à noter cependant qu&#8217;un nom propre, très fortement lié aux heures les plus sombres de la France durant la Seconde Guerre Mondiale, soit refusé à chaque étape de cette démonstration ; pourquoi seulement ce nom ? Le filtrage des pages Facebook est décidement bien étonnant.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/12/03/censure-dans-les-noms-de-pages-facebook-un-cache-misere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firesheep : alerte sur vos données personnelles !</title>
		<link>http://blog.nicolas.pawlak.fr/2010/10/27/firesheep-alerte-sur-vos-donnees-personnelles/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/10/27/firesheep-alerte-sur-vos-donnees-personnelles/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 22:30:50 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Actualité informatique]]></category>
		<category><![CDATA[Sécurité informatique]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1326</guid>
		<description><![CDATA[Une extension Firefox vient de voir le jour, nommée &#171;&#160;Firesheep&#160;&#187;. Son but est de permettre le vol de cookies, ces petits fichiers utilisés pour vous &#171;&#160;reconnaître&#160;&#187; sur un site et vous dispenser de l&#8217;étape d&#8217;authentification. L&#8217;intérêt de les voler ? Pouvoir s&#8217;authentifier à votre place sur un site, sans aucun identifiant ou mot de passe. [...]]]></description>
			<content:encoded><![CDATA[<p>Une <a href="https://addons.mozilla.org/fr/firefox/extensions/">extension</a> <a href="http://www.mozilla-europe.org/fr/firefox/">Firefox</a> vient de voir le jour, nommée &laquo;&nbsp;Firesheep&nbsp;&raquo;.</p>
<p>Son but est de permettre le vol de <a href="http://fr.wikipedia.org/wiki/Cookie_(informatique)">cookies</a>, ces petits fichiers utilisés pour vous &laquo;&nbsp;reconnaître&nbsp;&raquo; sur un site et vous dispenser de l&#8217;étape d&#8217;<a href="http://fr.wikipedia.org/wiki/Authentification">authentification</a>. L&#8217;intérêt de les voler ? Pouvoir s&#8217;authentifier à votre place sur un site, sans aucun identifiant ou mot de passe.</p>
<p>L&#8217;utilisation de cette extension est enfantine et démontre à quel point il est <strong>urgent</strong> que certains sites (au hasard&#8230; Facebook) prennent enfin les mesures nécessaires pour garantir à ses utilisateurs un niveau de sécurité acceptable, ce qui n&#8217;est pas le cas à l&#8217;heure actuelle.</p>
<p>Parmi les sites concernés : Facebook, Twitter, Google, Flickr, Windows Live, Amazon, Yahoo&#8230;</p>
<p>Tant que les communications ne passeront pas systématiquement par le protocole <a href="http://www.commentcamarche.net/contents/crypto/ssl.php3">SSL</a> (adresses en https:// et <a href="http://img49.xooimage.com/files/b/c/7/portail---la-banq...-firefox-1f499e0.png">petit cadenas</a> affiché sur votre navigateur) de bout en bout,<strong> il est fortement recommandé de ne plus s&#8217;authentifier sur ces sites à partir d&#8217;une connexion non-sûre</strong> (réseau WiFi ouvert ou peu protégé). A l&#8217;heure actuelle, la protection SSL mise en place ne concerne bien souvent que l&#8217;étape d&#8217;authentification, et laisse le flux en clair pour le reste de la navigation. </p>
<p><strong>Notez enfin que Firefox n&#8217;est pas responsable de cette extension, et que l&#8217;utilisation de cette dernière est réellement à la portée de n&#8217;importe quel pirate en herbe, qui aurait alors un accès total à vos données dans le cas où vous en seriez victime.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/10/27/firesheep-alerte-sur-vos-donnees-personnelles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script de relance automatique du serveur SSH</title>
		<link>http://blog.nicolas.pawlak.fr/2010/09/21/script-de-relance-automatique-du-serveur-ssh/</link>
		<comments>http://blog.nicolas.pawlak.fr/2010/09/21/script-de-relance-automatique-du-serveur-ssh/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 18:00:53 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[dedibox]]></category>
		<category><![CDATA[dédié]]></category>
		<category><![CDATA[ovh]]></category>
		<category><![CDATA[relance]]></category>
		<category><![CDATA[restart]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[serveur]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sshd]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[stop]]></category>
		<guid isPermaLink="false">http://blog.nicolas.pawlak.fr/?p=1267</guid>
		<description><![CDATA[Lorsque l&#8217;on administre un serveur à distance sans accès physique sur la machine, bien souvent, l&#8217;accès au serveur tient à un fil : celui du SSH. Si, pour une raison ou une autre, le serveur SSH s&#8217;arrête&#8230; les ennuis commencent pour l&#8217;administrateur et les utilisateurs. Même si les connexions SSH actives ne sont pas interrompues [...]]]></description>
			<content:encoded><![CDATA[<p>Lorsque l&#8217;on administre un serveur à distance sans accès physique sur la machine, bien souvent, l&#8217;accès au serveur tient à un fil : celui du <a href="http://fr.wikipedia.org/wiki/SSH">SSH</a>. Si, pour une raison ou une autre, le serveur SSH s&#8217;arrête&#8230; les ennuis commencent pour l&#8217;administrateur et les utilisateurs.</p>
<p>Même si les connexions SSH actives ne sont pas interrompues lors de l&#8217;arrêt du serveur (à condition de ne pas tout stopper avec un <a href="http://pwet.fr/man/linux/commandes/killall"><i>killall</i></a> !), il suffit d&#8217;un peu de malchance pour que celles-ci le soient : un plantage de votre système, une coupure électrique, une déconnexion de votre <a href="http://fr.wikipedia.org/wiki/Fournisseur_d%27acc%C3%A8s_%C3%A0_Internet">FAI</a> juste après l&#8217;arrêt du serveur SSH et vous voilà coincé à la porte de votre serveur distant.</p>
<p>Pour éviter cela, j&#8217;ai imaginé un script qui vérifierait régulièrement l&#8217;état du serveur SSH et le relancerait si besoin, avec restauration d&#8217;une sauvegarde du fichier <a href="http://pwet.fr/man/linux/formats/sshd_config">sshd_config</a> en cas d&#8217;échec lors du redémarrage. Ce script est évidemment à placer dans la <a href="http://fr.wikipedia.org/wiki/Crontab">crontab</a> d&#8217;un utilisateur ayant les droits requis pour travailler dans le répertoire de configuration de SSH et redémarrer le service&#8230; c&#8217;est à dire <a href="http://fr.wikipedia.org/wiki/Utilisateur_root"><i>root</i></a>, pour faire simple.</p>
<p><strong>Attention :</p>
<p>- Vérifiez bien votre configuration pour les variables déclarées en entête du fichier. Par exemple, le service se nomme &laquo;&nbsp;ssh&nbsp;&raquo; sur Debian / Ubuntu, et &laquo;&nbsp;sshd&nbsp;&raquo; sur Red Hat / Fedora.</p>
<p>- Testez le script sur un environnement de test dans un premier temps, pour éviter de faire des erreurs sur un environnement de production.</strong></p>
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">n_service</span>=<span style="color: #ff0000;">&quot;ssh&quot;</span>                      <span style="color: #666666; font-style: italic;"># Nom du service</span>
<span style="color: #007800;">f_exe</span>=<span style="color: #ff0000;">&quot;/usr/sbin/sshd&quot;</span>               <span style="color: #666666; font-style: italic;"># Exécutable du service</span>
<span style="color: #007800;">f_origine</span>=<span style="color: #ff0000;">&quot;/etc/ssh/sshd_config&quot;</span>     <span style="color: #666666; font-style: italic;"># Fichier de configuration actuelle</span>
<span style="color: #007800;">f_secours</span>=<span style="color: #ff0000;">&quot;/var/scripts/sshd_config&quot;</span> <span style="color: #666666; font-style: italic;"># Sauvegarde de la configuration</span>
<span style="color: #007800;">f_log</span>=<span style="color: #ff0000;">&quot;/var/log/restart_ssh&quot;</span>         <span style="color: #666666; font-style: italic;"># Fichier de log</span>
&nbsp;
<span style="color: #007800;">now</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date +%d/%m/%Y' - '%H:%M)</span>&quot;</span>    <span style="color: #666666; font-style: italic;"># Date et heure pour le log</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #c20cb9; font-weight: bold;">ps</span> ax <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$f_exe</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000; font-weight: bold;">then</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><span style="color: #007800;">$n_service</span> start <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">ps</span> ax <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$f_exe</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
        <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[<span style="color: #007800;">$now</span>] <span style="color: #007800;">$n_service</span> redémarré automatiquement&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$f_log</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$f_origine</span>
                <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #007800;">$f_secours</span> <span style="color: #007800;">$f_origine</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><span style="color: #007800;">$n_service</span> start <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">ps</span> ax <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$f_exe</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000; font-weight: bold;">&amp;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
                <span style="color: #000000; font-weight: bold;">then</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[<span style="color: #007800;">$now</span>] <span style="color: #007800;">$n_service</span> redémarré après restauration&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$f_log</span>
                <span style="color: #000000; font-weight: bold;">else</span>
                        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;[<span style="color: #007800;">$now</span>] <span style="color: #007800;">$n_service</span> arrêté, restauration inefficace&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$f_log</span>
                <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>
<p>Crontab root (à adapter selon vos souhaits, ici un lancement du script toutes les minutes) :</p>
<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">#       minute (de 0 à 59)
&nbsp;
#       |       heure (de 0 à 23)
&nbsp;
#       |       |       jour (de 1 à 31)
&nbsp;
#       |       |       |       mois (de 1 à 12)
&nbsp;
#       |       |       |       |       jour de la semaine (de 0 à 6, 0 = dimanche)
&nbsp;
#       |       |       |       |       |       commande
&nbsp;
        */1     *       *       *       *       /bin/bash /var/scripts/restart_ssh.sh</pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.nicolas.pawlak.fr/2010/09/21/script-de-relance-automatique-du-serveur-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

