Archive by Author

Défi geek

Ce défi est une expérience, il n'y aucun prix pour le moment. Si la sauce prend, il est envisagé d'organiser des concours dans un cadre plus intéressant.

Ce problème a été soulevé par une grosse entreprise. La solution est déjà connue, je ne le pose ici que pour le jeu. Bien entendu le problème a été ramené à un cas d'école pour faciliter la compréhension et la réflexion.

Il est inutile de tester votre solution et vous pouvez en proposer plusieurs via les commentaires. Ces derniers sont modérés pour garder le secret quelques jours. Bien sûr cela ne vous empêche pas de commenter que je suis une personne excécrable ou que le multicast marche mieux sous NetBSD. Quiconque laisse un commentaire sera averti par E-mail de la mise en ligne de la solution.

Une version de ce problème correspondant à l'environnement réel de l'entreprise arrivera peu après la résolution de ce premier problème. La complexité et la difficulté seront supérieures.

Objectif :

Les clients envoient des requêtes en broadcast, un service déjà configuré sur le serveur doit y répondre.

Contexte :

  • Serveur Linux avec une carte Ethernet, configuré comme suit :
    • Distribution moderne générique (Debian, Ubuntu, Fedora, etc.) dont noyau Linux 2.6 ;
    • La carte Ethernet est configurée avec ifconfig eth0 10.0.0.1 netmask 255.255.255.0, addresse de broadcast par défaut soit 10.0.0.255 ;
    • L'interface de loopback (lo) est disponible ;
    • Chaînes netfilter vides, politique par défaut ACCEPT, le reste de la configuration est celle de l'installation par défaut de la distribution ;
  • Les clients sont sur le même segment Ethernet (i.e. aucun routeur), sur 10.0.0.0/16, addresse broadcast par défaut soit 10.0.255.255 ;
  • Les ports utilisés ne sont pas connus (par exemple rpc.bootparamd).

Contraintes :

  • Le serveur ne peut écouter que sur 10.0.0.0/24 et 10.0.255.255, ne peut émettre que sur 10.0.0.0/24 (les raisons pour ce type de contraintes seront plus claires dans la version complexe) ;
  • La configuration réseau du serveur est librement modifiable tant que la règle précédente est respectée et assurée dans l'espace noyau ;
  • La configuration réseau des clients ne peut pas être changée ;
  • Pas de patchs ou de paquets ésotériques ;
  • La solution tient sur 3 commandes exécutées en root. Elles ne peuvent reposer que sur des outils disponibles sur toute distribution moderne générique. Inutile de faire en sorte que les changements persistent après un redémarrage, de toute façon un serveur ne crashe pas et n'a pas besoin de redémarrer.

Si vous autorisez le serveur à émettre sur 10.0.255.255 et acceptez d'êtres crades (mais compatibles avec au moins Solaris et Linux), une commande suffit.

Edit du 17 avril 2010, aka « La soluce »

Xav l'emporte avec sauf erreur de ma part 2 fautes d'étourderie sur iptables (il faudrait utiliser -A au lieu de -l et –to-destination au lieu de -to) !

Je préfère ne pas créer de VLAN et reposer sur du SNAT pour que les logiciels « voient » l'adresse de destination des requêtes, c'est plus transparent et ça pourrait jouer un rôle avec une implémentation de bootparamd par exemple (puisque le client demande entre autres quel routeur utiliser).

On peut attacher des IP individuelles à une interface existante sans créer d'interface virtuelle (eg eth0:1) et avec un masque implicite de /32 avec ip addr add.

Ma solution favorite est donc (avec :0-1023 pour désactiver le mécanisme de changement de ports) :

# ip addr add 10.0.255.255 dev eth0
# iptables -t nat -A POSTROUTING -s 10.0.255.255 -j SNAT –-to-source 10.0.0.1:0-1023

Synchronize desktop launchers’ position in RHEL5

This is a simple snippet written for a customer.

#!/usr/bin/env ruby

=begin
=======================================
Synchronize desktop launchers' position
    Ruby prototype for Gnome, RHEL5
******* Not endorsed by Red Hat *******
=======================================

WARNING
-------

This script will NOT work with a recent nautilus.
It should work nautilus 2.16.
Icons positions are stored in gconf in last releases.

LICENSE
-------

Copyright (c) 2010, Pierre Carrier <pcarrier@redhat.com>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

EXAMPLE
-------

To synchronize from $SRCUSER to $DSTUSER, use:

script.rb /home/${SRCUSER}/.nautilus/metafiles/file:%2F%2F%2Fhome%2F${SRCUSER}%2FDesktop.xml \
          /home/${DSTUSER}/.nautilus/metafiles/file:%2F%2F%2Fhome%2F${DSTUSER}%2FDesktop.xml

=end

require "rexml/document"
include REXML

srcfile = File.new(ARGV[0])
srcdoc = REXML::Document.new srcfile
srcfile.close

dstfile = File.new(ARGV[1])
dstdoc = REXML::Document.new dstfile
dstfile.close

XPath.each srcdoc, "//directory/file"  do |s|
  d = XPath.first dstdoc, "//directory/file[@name='#{s.attributes['name']}']"
  if d != nil then
    unless d.attributes['icon_position'] == s.attributes['icon_position'] then
      d.attributes['icon_position'] = s.attributes['icon_position']
      print "updated position for #{s.attributes['name']}\n"
    end
  else
    dstdoc.root.add_element 'file', s.attributes
    print "added info for #{s.attributes['name']}\n"
  end
end

dstdoc.write File.new(ARGV[1],'w')

Incoming…

I am currently working on a new architecture for my server based on OpenVZ. After all, I need a reason for my new piece of hardware which features 24GB of RAM and a few terabytes of storage…

It will rely on LDAP and NFS for pretty much everything.

I've also been playing with redis a lot lately. I absolutely love it.

I want most service, PHP or Ruby app to have its own container (most of them based on Arch Linux, with nice hacks I might document later). The base container is currently 120MB.

For all those reasons and because life can be fun, I am writing my own mail sending & receiving, Twitter posting, logging and IRC communication framework. The concept is to expose a clean API through redis and implement the corresponding "gateways" in their own virtual machines. I also intend to provide alternatives to standard tools; for example, I wrote a sendmail-compliant client. All this code will be open-sourced soon. I'll keep you updated!

On an unrelated note, I am currently following the RH300 "RHCE Rapid Track Course" and might be a Red Hat Certified Technician and Red Hat Certified Engineer by the end of the week… I will also be in Munich from Sunday to Tuesday. If a friendly face wants to see me there, here's my E-mail!

HOWTO autofs via OpenLDAP on RHEL5, Fedora Core 12

Please provide feedback in the comments, specially about other versions/distributions.

Server (hostname server.example.com)

  • # yum install openldap-servers openldap-clients
  • NFS:
    # mkdir -p /export/foo; touch /export/foo/demofile
    # echo "/export/foo *(ro)" >> /etc/exports
    # chkconfig nfs on; service nfs start
  • LDAP:
    • Modify /etc/openldap/slapd.conf:
      • Add line 8:
        include /etc/openldap/schema/redhat/autofs.schema
      • Modify suffix and rootdn by replacing dc=my-domain,dc=com by dc=example,dc=com
      • Define a rootpw by uncommenting:
        rootpw secret
      • Give read-only access to everyone by adding:
        access to * by * read
    • # chkconfig ldap on; service ldap start
    • Populate the directory:
      # ldapadd -c -x -D cn=Manager,dc=example,dc=com -w secret << EOF
      dn: dc=example,dc=com
      dc: example
      objectClass: top
      objectClass: domain
      objectClass: domainRelatedObject
      associatedDomain: example.com
      
      dn: ou=auto.master, dc=example, dc=com
      objectClass: top
      objectClass: automountMap
      ou: auto.master
      
      dn: cn=/home, ou=auto.master, dc=example, dc=com
      objectClass: automount
      cn: /home
      automountInformation: ldap server.example.com:ou=auto.home,dc=example,dc=com
      
      dn: ou=auto.home, dc=example, dc=com
      objectClass: top
      objectClass: automountMap
      ou: auto.home
      
      dn: cn=foo, ou=auto.home, dc=example, dc=com
      objectClass: automount
      cn: foo
      automountInformation: -fstype=nfs,hard,intr,nodev,nosuid server.example.com:/export/foo
      EOF

Client

  • Check connectivity & name resolution:
    # ping server.example.com
  • # yum install autofs
  • Add ldap to the automount line in /etc/nsswitch.conf:
    automount: files ldap
  • In /etc/sysconfig/autofs:
    • Uncomment:
      MAP_OBJECT_CLASS="automountMap"
      ENTRY_OBJECT_CLASS="automount"
      MAP_ATTRIBUTE="automountMapName"
      ENTRY_ATTRIBUTE="automountKey"
      VALUE_ATTRIBUTE="automountInformation"
    • Set those variables:
      BROWSE_MODE="yes"
      LDAP_URI="ldap://server.example.com"
      SEARCH_BASE="dc=example,dc=com"
  • # service autofs start
  • Final check:
    # ls -l /home/foo/demofile

Looking for a job in UK

Hello Community!

Sorry to invade planets with a classified…

After numerous random events, I moved to UK. I am now looking for a job. If you think you can help with my search, please have a look at my CV. Please contact me if anything comes to your mind!

By the way, I love UK websites. They’re cleaner, lighter & more intuitive than most of the French ones.

Quick update: Thanks everyone! Opportunities you helped me find were all very interesting. Decision was harsh. I finally went with Red Hat and will start there on Monday as a Technical Support Engineer.

Cleanup your Google Chrome/Chromium history

Just wanted to share this with you.

#!/bin/zsh
if [ a$(uname) = aDarwin ]
  then dbfile="$HOME/Library/Application Support/Google/Chrome/Default/History"
  else dbfile="$HOME/.chromium/???"; fi
blacklistfile=$HOME/.config/history-blacklist

if [ ! -f $dbfile ]
  then echo "oops! history db '$dbfile' not found!";
  exit -1; fi
if [ ! -f $blacklistfile ]
  then echo "oops! blacklist not found! please create '$blacklistfile' (see doc).";
  exit -2; fi
filter=""
while read i; do filter="\n  url like '$i' or ${filter}"; done < $blacklistfile
request="delete from urls where ${filter% or };"

echo -n "Do you want to execute:\n'${request}'\nin your chrome history db? [y/N] "
read answer; case $answer in
  y|Y) echo $request | sqlite3 $dbfile; return $?;;
  *) echo "mission abort, pu\$\$y!";; esac

And in $HOME/.config/history-blacklist, use something like:

%4chan.org%
%4chanarchive.org%
%piratebay.org%
%youtube.com%

You need to close Chromium/Chrome before running this script (else you’ll hit a permanent db lock).

Distributing packages

Distributing data can be an issue in FLOSS projects. One day, some IPv6-P2P-multicast-awesome-featured technology will solve all our problems. Internet will be made of undistinguished nodes, and the concept of client and server will disappear. Oops, that’s not my point (for French readers)!

ftp.archlinux.org, the default mirror for Arch, uses too much bandwidth. Even if the installer proposes to change this, it seems that a awful lot of persons don’t use it. That’s why devs chose to limit each connection to 50kbytes/s on it.

I wrote two small PHP scripts to allow geographic, cached distribution of clients to other mirrors.

On the first connection of an IP, it uses GeoIP to choose its “nearest” mirror (random choice in the country mirrors list), and stores it in a memcached (for up to 1 month). Caching is necessary to avoid switching too often from a mirror to another, which might be serving different versions.

It gets the per-country mirrors lists through an annotated /etc/pacman.d/mirrorlist. For now we have to maintain, if I understood correctly, rsync, website and pacman databases, but are moving to a centralized database (maintained through django), so this should change later.

I didn’t get many opinions for now; feel free to react in comments! I’d also love to hear about other distros policy, and/or get contributions.

P.S.: That’s my first post since I got promoted as a dev in Arch Linux. Thanks to the whole team for letting me in. I don’t have much time these weeks, but should get a lot done next week.

Internet mobile « illimité » en 3G, pas cher, sans engagement !

OrangeVous aussi, bénéficiez d’un accès à Internet partout en France pour pas cher ! Bien sûr, l’« illimité » de mon titre est à prendre au sens opérateur : pas d’interruption stricte du service en cas de dépassement d’un quota. Par contre, Orange vous interdit la voix sur IP, le partage de documents de pair à pair, se réserve le droit de brider (encore plus) la connexion si vous l’utilisez trop, y tutti quanti. Il faudra que je vérifie personnellement pour ce contrat précis, mais le contraire m’étonnerait.

Vous êtes prêts à braver le géant de la télécommunication en utilisant la connexion sur un écran autre que celui d’un téléphone ? Bravo. Après tout, que l’écran fasse 2,5 ou 10 pouces ne les regarde absolument pas.

Rendez-vous donc en agence, achetez une clef USB 3G (maintenant gérée facilement sous Arch Linux, j’y reviendrai très prochainement), une Mobicarte, puis souscrivez à l’option internet max à 9 euros par mois et ça glisse (hors CGV) !

Le coût initial est alors de 69 euros pour la clef, sur lesquels 30 euros sont remboursés jusqu’au 12 novembre, auxquels s’ajoutent 30 euros pour la mobicarte (ou 35 euros avec un mobile des moins chers). Les frais mensuels s’élèvent dès lors à 10 euros par mois (prix des recharges valables 15 jours à acheter peu avant chaque échéance). La reconduction est tacite, mais aucun engagement.

Apparemment, le débit est actuellement bridé à 50 ko/s (observé chez yam). Décevant pour une 3G au débit maximal théorique de 3,6mbit/s (avec ce dongle), beaucoup moins en EDGE ou pire, GPRS… Je vous en dirais plus quand j’aurais moi-même investi.

Pour un étudiant à fort besoin de mobilité (programme d’échange international, stage, etc.), ce peut être une solution intéressante pour relever son courrier, se documenter, etc.

Je ne vais pas vous énumérer davantage les utilisations possibles d’Internet, d’autant qu’il serait préférable de s’en tenir à ce genre de « classiques » peu consommateurs de bande passante et proches de ce qui se fait sur un quelconque mobile. Reste à déterminer la tolérance d’Orange vis-à-vis de ce détournement, pour éventuellement pouvoir se faire plus plaisir…

Je ne suis bien entendu pas responsable des conséquences que pourrait avoir la lecture de ce billet, désobéissance civique, vandalisme et mensonges relatif au gateau compris.

100 packages!

Image representing Boštjan Špetič as depicted ...

As I don’t write a lot on this blog, I thought a good excuse for a new post could be this new step: by counting both unsupported and [community] packages, I have now 100 packages in Arch Linux! It’s not simply a symbolic number: I won’t be able to see more packages in one page on AUR! It is a real pleasure to contribute to this great distribution, even if I started working on Fedora for some of my extravagant expectations. Something else: I started using Zemanta. I’m pretty proud to know one of the founders of Zemanta Ltd., Boštjan Špetič: I worked with the kiberpipa crew on the OpenOffice.org conferences video streaming and he seemed a very competent and available person. I might write on Zemanta another time, but for now, I can see both huge benefits and a few disapointments.

Soirée BDE Arsh

_IGP3928Après quelques tentatives avec les diaporamas Flash de flickr, je reviens à quelque chose de plus propre.

Voici donc les photos d’une soirée ma foi fort sympathique.