<?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>Tuxce &#187; linux</title>
	<atom:link href="http://tuxce.no-ip.org/tag/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://tuxce.no-ip.org</link>
	<description></description>
	<lastBuildDate>Mon, 16 Jan 2012 21:57:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>pacman, générer la clé depuis une session ssh</title>
		<link>http://tuxce.no-ip.org/informatique/pacman-generer-la-cle-depuis-une-session-ssh</link>
		<comments>http://tuxce.no-ip.org/informatique/pacman-generer-la-cle-depuis-une-session-ssh#comments</comments>
		<pubDate>Mon, 16 Jan 2012 21:57:07 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pacman]]></category>

		<guid isPermaLink="false">http://tuxce.no-ip.org/?p=468</guid>
		<description><![CDATA[pacman est passé en version 4.0.1 sur le dépôt [core], du coup, j&#8217;ai mis certaines de mes installations accessibles qu&#8217;en ssh; or là, la génération de la clé reste bloquée : # pacman-key --init gpg: /etc/pacman.d/gnupg/trustdb.gpg: trustdb created gpg: no ultimately trusted keys found gpg: Generating pacman keychain master key... Not enough random bytes available. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.archlinux.org/pacman">pacman</a> est passé en version <code>4.0.1</code> sur le dépôt <code>[core]</code>, du coup, j&#8217;ai mis certaines de mes installations accessibles qu&#8217;en <code>ssh</code>; or là, la <a href="http://wiki.archlinux.fr/Pacman-key#Configuration">génération de la clé</a> reste bloquée :</p>
<pre># pacman-key --init
gpg: /etc/pacman.d/gnupg/trustdb.gpg: trustdb created
gpg: no ultimately trusted keys found
gpg: Generating pacman keychain master key...

Not enough random bytes available.  Please do some other work to give
the OS a chance to collect more entropy! (Need 281 more bytes)
</pre>
<p>Sur un &laquo;&nbsp;desktop&nbsp;&raquo;, il suffira de bouger une fenêtre pendant plus ou moins longtemps afin que ça fonctionne; depuis une session <code>ssh</code>, c&#8217;est moins évident &#8230;<br />
On peut néanmoins y remédier en installant <a href="https://aur.archlinux.org/packages.php?ID=14589">rng-tools</a> puis, modifier le fichier <code>/etc/conf.d/rngd</code> :</p>
<pre>timeout=10</pre>
<p>Lancez dans une session <code>ssh</code> en <code>root</code> :</p>
<pre>rngd -f -r /dev/urandom</pre>
<p>Et dans une autre session <code>ssh</code> :</p>
<pre>pacman-key --init</pre>
<p>Ca devrait fonctionner sans souci.</p>
]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/pacman-generer-la-cle-depuis-une-session-ssh/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Archlinux, un serpent est mort</title>
		<link>http://tuxce.no-ip.org/informatique/archlinux-un-serpent-est-mort</link>
		<comments>http://tuxce.no-ip.org/informatique/archlinux-un-serpent-est-mort#comments</comments>
		<pubDate>Tue, 25 Oct 2011 16:29:06 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pacman]]></category>

		<guid isPermaLink="false">http://tuxce.no-ip.org/?p=448</guid>
		<description><![CDATA[Avec pacman 4.x, on verra la mort d&#8217;un des serpents de mer d&#8217;Arch Linux : la signature des paquets et dépôts. Souvent et de manière récurrente, il fleurissait ici ou là un sujet concernant la sécurité des paquets sous Arch Linux (Dan McGee résume cela dans un article), mais jusqu&#8217;à maintenant, aucune implémentation n&#8217;avait percée, [...]]]></description>
			<content:encoded><![CDATA[<p>Avec <a href="http://projects.archlinux.org/pacman.git/">pacman</a><code> 4.x</code>, on verra la mort d&#8217;un des serpents de mer d&#8217;Arch Linux : la signature des paquets et dépôts.</p>
<p>Souvent et de manière récurrente, il fleurissait ici ou là un sujet concernant la sécurité des paquets sous Arch Linux (<a href="http://www.toofishes.net/about/">Dan McGee</a> résume cela dans un <a href="http://www.toofishes.net/blog/real-story-behind-arch-linux-package-signing/">article</a>), mais jusqu&#8217;à maintenant, aucune implémentation n&#8217;avait percée, désormais, c&#8217;est chose faite.</p>
<p>Il est maintenant possible de signer les dépôts (à l&#8217;aide de <code>repo-add -s</code>) mais aussi les paquets (à l&#8217;aide de <code>makepkg --sign</code>), <code>pacman</code>, lors de la phase de vérification d&#8217;intégrité et selon la configuration, teste les signatures.</p>
<p>Plusieurs niveaux de vérification sont possibles selon la valeur de la directive <code>SigLevel</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">SigLevel</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>Database|Package<span style="">&#93;</span>&lt;Required|Optional|Never&gt; <span style="">&#91;</span>TrustOnly|TrustAll<span style="">&#93;</span></span></span></pre></div></div>

<p>Il est possible de spécifier une configuration globale en plaçant <code>SigLevel</code> dans la section <code>[options]</code> et/ou une configuration par dépôt en la plaçant dans la section du dépôt concerné, par exemple:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>options<span style="">&#93;</span></span>
#...
<span style="color: #000099;">SigLevel</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> Optional TrustOnly</span>
#...
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>mon_depot<span style="">&#93;</span></span>
<span style="color: #000099;">SigLevel</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> DatabaseRequired PackageNever TrustOnly</span></pre></div></div>

<p>Le fonctionnement ensuite, est totalement transparent à moins qu&#8217;une vérification échoue.</p>
<p>Un exemple vaut mieux qu&#8217;un long discours et pour avoir un aperçu de tout le cheminement, je vais créer un mini dépôt contenant <a href="http://git.archlinux.fr/yaourt.git/">yaourt-git</a> et <a href="http://git.archlinux.fr/package-query.git/">package-query-git</a>, les versions stables n&#8217;étant pas compatibles avec <code>pacman</code>, ça tombe bien.</p>
<p>Evidemment, il faut avoir une clé pour procéder aux signatures :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ gpg <span style="color: #660033;">--fingerprint</span>
<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>test<span style="color: #000000; font-weight: bold;">/</span>.gnupg<span style="color: #000000; font-weight: bold;">/</span>pubring.gpg
<span style="color: #660033;">-----------------------------</span>
pub   2048R<span style="color: #000000; font-weight: bold;">/</span>EB671452 <span style="color: #000000;">2011</span>-<span style="color: #000000;">10</span>-<span style="color: #000000;">25</span>
    Empreinte de la clé = <span style="color: #000000;">8002</span> 883C D06C 06BB BDD1  4D24 C2B0 9F4B EB67 <span style="color: #000000;">1452</span>
uid                  tuxce <span style="color: #000000; font-weight: bold;">&lt;</span>tuxce archlinux.fr<span style="color: #000000; font-weight: bold;">&gt;</span>
uid                  tuxce <span style="color: #000000; font-weight: bold;">&lt;</span>tuxce.net gmail.com<span style="color: #000000; font-weight: bold;">&gt;</span>
uid                  <span style="color: #7a0874; font-weight: bold;">&#91;</span>jpeg image of <span style="color: #c20cb9; font-weight: bold;">size</span> <span style="color: #000000;">11842</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
sub   2048R<span style="color: #000000; font-weight: bold;">/</span>DE00D30D <span style="color: #000000;">2011</span>-<span style="color: #000000;">10</span>-<span style="color: #000000;">25</span></pre></div></div>

<p>On récupère les <a href="http://wiki.archlinux.fr/PKGBUILD">PKGBUILD</a> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> pkg repo
<span style="color: #7a0874; font-weight: bold;">cd</span> pkg
<span style="color: #000000; font-weight: bold;">for</span> pkg <span style="color: #000000; font-weight: bold;">in</span> yaourt-git package-query-git; <span style="color: #000000; font-weight: bold;">do</span>
  curl http:<span style="color: #000000; font-weight: bold;">//</span>aur.archlinux.org<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$pkg</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$pkg</span>.tar.gz <span style="color: #000000; font-weight: bold;">|</span> bsdtar <span style="color: #660033;">-xf</span> -
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>On construit les paquets:</p>
<pre>
$ cd ..
$ export PKGDEST="$(pwd)/repo"
$ cd pkg/yaourt-git
$ makepkg --sign
# [...]
==> Signature de(s) paquet(s)…

Vous avez besoin d'une phrase de passe pour déverrouiller la
clé secrète pour l'utilisateur: « tuxce <tuxce archlinux.fr> »
clé de 2048 bits RSA, ID EB671452, créée le 2011-10-25

  -> Le fichier /home/test/pkg/yaourt-git/yaourt-git-20111025-1-any.pkg.tar.xz.sig des signatures a été créé.
==> Quitte l'environnement fakeroot.
==> Création finie : yaourt-git 20111025-1 (mar. oct. 25 17:04:14 CEST 2011)
$ cd ../package-query-git
# [...]
==> Signature de(s) paquet(s)…

Vous avez besoin d'une phrase de passe pour déverrouiller la
clé secrète pour l'utilisateur: « tuxce <tuxce archlinux.fr> »
clé de 2048 bits RSA, ID EB671452, créée le 2011-10-25

  -> Le fichier /home/test/pkg/package-query-git/package-query-git-20111025-1-x86_64.pkg.tar.xz.sig des signatures a été créé.
==> Quitte l'environnement fakeroot.
==> Création finie : package-query-git 20111025-1 (mar. oct. 25 17:06:47 CEST 2011)
</pre>
<p>Création du dépôt:</p>
<pre>$ cd ../../repo
$ ls
package-query-git-20111025-1-x86_64.pkg.tar.xz
yaourt-git-20111025-1-any.pkg.tar.xz
package-query-git-20111025-1-x86_64.pkg.tar.xz.sig
yaourt-git-20111025-1-any.pkg.tar.xz.sig
$ repo-add -s mon_depot.db.tar.gz *.xz
==> Ajoute le paquet 'package-query-git-20111025-1-x86_64.pkg.tar.xz'
  -> Calcul des sommes de contrôle…
  -> Ajout de la signature des paquets…
  -> Création de l'entrée 'desc'...
  -> Création de l'entrée 'depends'...
==> Ajoute le paquet 'yaourt-git-20111025-1-any.pkg.tar.xz'
  -> Calcul des sommes de contrôle…
  -> Ajout de la signature des paquets…
  -> Création de l'entrée 'desc'...
  -> Création de l'entrée 'depends'...
==> Création du nouveau fichier de dépôt 'mon_depot.db.tar.gz'
==> Signature de la base de données…

Vous avez besoin d'une phrase de passe pour déverrouiller la
clé secrète pour l'utilisateur: « tuxce <tuxce archlinux.fr> »
clé de 2048 bits RSA, ID EB671452, créée le 2011-10-25

  -> Le fichier mon_depot.db.tar.gz.sig des signatures a été créé.
$ ls
mon_depot.db
mon_depot.db.tar.gz
package-query-git-20111025-1-x86_64.pkg.tar.xz
yaourt-git-20111025-1-any.pkg.tar.xz
mon_depot.db.sig
mon_depot.db.tar.gz.sig
package-query-git-20111025-1-x86_64.pkg.tar.xz.sig
yaourt-git-20111025-1-any.pkg.tar.xz.sig
</pre>
<p>Rajout du dépôt à <code>/etc/pacman.conf</code> :</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>mon_depot<span style="">&#93;</span></span>
<span style="color: #000099;">Server</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> file:///home/test/repo</span></pre></div></div>

<p>Synchronisation :</p>
<pre># pacman -Sy
Avertissement : database file for 'mon_depot' does not exist
:: Synchronisation des bases de données de paquets...
 testing est à jour ;
 core est à jour ;
 extra est à jour ;
 community-testing est à jour ;
 community est à jour ;
 mon_depot                                     1548,0   B   998K/s 00:00 [#########################################] 100%
 mon_depot.sig                                  286,0   B   150K/s 00:00 [#########################################] 100%
Erreur : mon_depot: key "C2B09F4BEB671452" is unknown
:: Importation de la clé PGP EB671452, « tuxce <tuxce archlinux.fr> », 2011-10-25 créée ? [O/n]
</pre>
<p>Si vous avez mis <code>TrustAll</code> et que votre clé est disponible sur le serveur de clé configuré (cf <a href="http://wiki.archlinux.fr/pacman-key">wiki / pacman-key</a>), il suffit de répondre &laquo;&nbsp;o&nbsp;&raquo;, sinon, il faudra d&#8217;abord importer la clé (que vous auriez par exemple exporté avec <code>gpg --export</code>) :</p>
<pre># pacman-key -a cle_publique.key
==> Mise à jour de la base de données de confiance…
gpg: vérification de la base de confiance inutile
</pre>
<p>Si <code>pacman-key</code> ne possède pas la clé ou si la vérification échoue, <code>pacman</code> retourne :</p>
<pre>Erreur : la base de donnée 'mon_depot' n'est pas valide (base de données invalide ou corrompue (Signature PGP))
</pre>
<p>L&#8217;utilisation est transparente :</p>
<pre># pacman -S yaourt-git package-query-git
</pre>
<hr/>
<p>En plus de la vérification des paquets et des dépôts, <code>pacman 4.x</code> par le biais de <code>makepkg</code> permet en plus de pouvoir vérifier les sources des paquets soumis à <a href="https://aur.archlinux.org">AUR</a> pour peu que l&#8217;auteur fournisse un <code>.sig</code> ou <code>.asc</code>, il suffira alors de le spécifier dans le <code>PKGBUILD</code> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">sources</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span>http:<span style="color: #000000; font-weight: bold;">//</span>example.org<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$pkgname</span>-<span style="color: #007800;">$pkgver</span>.tar.gz<span style="color: #7a0874; font-weight: bold;">&#123;</span>,.sig<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Voilà, en espérant que la transition se passera sans soucis.</p>
<hr/>
<a href="http://allanmcrae.com/2011/08/pacman-package-signing-1-makepkg-and-repo-add/">Pacman Package Signing – 1</a>, <a href="http://allanmcrae.com/2011/08/pacman-package-signing-2-pacman-key/">2</a> et <a href="http://allanmcrae.com/2011/08/pacman-package-signing-3-pacman/">3</a> d&#8217;<a href="http://allanmcrae.com/about/">Allan McRae</a><br />
<a href="http://www.toofishes.net/blog/real-story-behind-arch-linux-package-signing/">Historique</a> par <a href="http://www.toofishes.net/about/">Dan McGee</a><br />
<a href="http://wiki.archlinux.fr/pacman-key">pacman-key</a> sur le wiki .fr.<br />
<a href="https://wiki.archlinux.org/index.php/Package_signing>Package signing</a> sur le wiki .org.</p>
]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/archlinux-un-serpent-est-mort/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gnome Shell Extensions, modifier la zone de statut</title>
		<link>http://tuxce.no-ip.org/informatique/gnome-shell-extensions-modifier-la-zone-de-statut</link>
		<comments>http://tuxce.no-ip.org/informatique/gnome-shell-extensions-modifier-la-zone-de-statut#comments</comments>
		<pubDate>Sun, 08 May 2011 20:18:04 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[gnome-shell]]></category>
		<category><![CDATA[gnome-shell extensions]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://tuxce.selfip.org/?p=426</guid>
		<description><![CDATA[Gnome est sorti il y a peu en version stable, la 3.0 et le peu qu&#8217;on puisse dire, c&#8217;est que ça en fait du changement. Certains sont pour, d&#8217;autres contre, mais peu importe, au final, ça a tendance à s&#8217;équilibrer et chacun y trouve son compte. Ceci dit, ce nouveau Gnome nous vient avec une [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gnome.org">Gnome</a> est sorti il y a peu en version stable, la 3.0 et le peu qu&#8217;on puisse dire, c&#8217;est que ça en fait du changement. Certains sont pour, d&#8217;autres contre, mais peu importe, au final, ça a tendance à s&#8217;équilibrer et chacun y trouve son compte. Ceci dit, ce nouveau Gnome nous vient avec une interface/gestionnaire de fenêtre, <a href="http://live.gnome.org/GnomeShell/Tour">Gnome Shell</a> dont une grande partie du code est écrite en Javascript et utilisant du CSS pour le design. Ce dernier fournit également un système d&#8217;<a href="http://live.gnome.org/GnomeShell/Extensions">extensions</a> qui, combinés au fait que c&#8217;est du Javascript donne une certaine liberté de configuration (si on connaît un peu de Javasciprt).</p>
<p>Revenons à Gnome Shell, ce dernier a une zone de statut (qui remplace l&#8217;ancienne zone de notification qui elle se retrouve en bas et cachée <img src='http://tuxce.no-ip.org/wp-includes/images/smilies/icon_neutral.gif' alt=':|' class='wp-smiley' /> ) dont une des icônes a tendance à m&#8217;agacer, celle nommée &laquo;&nbsp;accès universel&nbsp;&raquo; (déjà, je ne comprend pas le nom). Cette zone n&#8217;est pas configurable, je me fais une raison et en profite pour voir de plus près ces possibilités de modifications de Gnome Shell.</p>
<p>Tout d&#8217;abord, une des premières pages visitées donne une liste assez intéressante des <a href="http://live.gnome.org/GnomeShell/CheatSheet">possibilités de Gnome Shell</a>, entre autre, la console Javascript (et un peu plus) intégrée qu&#8217;on peut lancer avec: <code>Alt+F2</code> puis: <code>lg</code></p>
<p>En cliquant sur la pipette (en haut à gauche), puis sur l&#8217;icône &laquo;&nbsp;accès universel&nbsp;&raquo;, on a 2 lignes qui se rajoutent dans la console:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">&gt;&gt;&gt; &lt;inspect x:901 y:18&gt;
r(0) = [0x953d340 StBin.panel-button]</pre></div></div>

<p>En cliquant sur le résultat (le 0&#215;9&#8230;), on peut inspecter l&#8217;objet et entre autre voir qu&#8217;il y a 2 fonctions aux noms assez évocateurs, <code>hide()</code> et <code>show()</code>. Il n&#8217;y a plus qu&#8217;à tester:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">&gt;&gt;&gt; r(0).hide()
r(2) = undefined</pre></div></div>

<p>L&#8217;icône a disparu; parfait. Et il se trouve que vous pouvez inspecter tout objet affiché.</p>
<p>Ceci dit, c&#8217;est bien beau, mais comment rendre ça permanent ? Il est temps de jeter un coup d&#8217;oeil aux extensions.</p>
<p>Gnome Shell fournit un outil pour créer une extension:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">$ gnome-shell-extension-tool --create
&nbsp;
Name should be a very short (ideally descriptive) string.
Examples are: &quot;Click To Focus&quot;,  &quot;Adblock&quot;, &quot;Shell Window Shrinker&quot;.
&nbsp;
Name: test
&nbsp;
Description is a single-sentence explanation of what your extension does.
Examples are: &quot;Make windows visible on click&quot;, &quot;Block advertisement popups&quot;
              &quot;Animate windows shrinking on minimize&quot;
&nbsp;
Description: pour tester
&nbsp;
Uuid is a globally-unique identifier for your extension.
This should be in the format of an email address (foo.bar@extensions.example.com), but
need not be an actual email address, though it's a good idea to base the uuid on your
email address.  For example, if your email address is janedoe@example.com, you might
use an extension title clicktofocus@janedoe.example.com.
Uuid [test@host]: test@home.lan
Created extension in '/home/test/.local/share/gnome-shell/extensions/test@home.lan'
$</pre></div></div>

<p>Cet utilitaire crée un répertoire sous <code>$XDG_DATA_HOME/gnome-shell/extensions</code> contenant:
<ul>
<li><code>metadata.json</code> : Informations sur votre extension.</li>
<li><code>stylesheet.css</code> : Design de votre extension</li>
<li><code>extension.js</code> : Le code à proprement dit.</li>
</ul>
<p><code>extension.js</code> contient déjà du code, c&#8217;est un exemple. Pour voir ce que ça fait: <code>Alt+F2</code> puis <code>r</code> (juste &laquo;&nbsp;r&nbsp;&raquo;), puis cliquez sur le panel, Gnome Shell devrait vous dire bonjour.</p>
<p>Bien, mais c&#8217;est pas ce qu&#8217;on veut, voyons voir comment ça fonctionne&#8230; </p>
<ul>
<li>Gnome Shell charge l&#8217;extension puis exécute la fonction <code>main()</code></li>
<li>Les éléments de l&#8217;interface sont accessibles depuis l&#8217;objet <code>imports.ui</code> qui correspond au répertoire <code>js/ui</code> de l&#8217;installation de Gnome shell. Sous Archlinux : <code>/usr/share/gnome-shell/js/ui</code></li>
</ul>
<p>En jetant un coup d&#8217;oeil au fichier <code>/usr/share/gnome-shell/js/ui/panel.js</code>, on remarque la présence d&#8217;une constante:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">const</span> STANDARD_TRAY_ICON_ORDER <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'a11y'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'display'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'keyboard'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'volume'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'bluetooth'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'network'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'battery'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>En fait, ça correspond aux icônes de statut dans l&#8217;ordre d&#8217;apparition (si elles sont disponibles) et <code>a11y</code> correspond à l&#8217;icône <emphase>accès universel</emphase> (a .. 11 lettres .. y pour accessibility). Pour chaque icône, il existe une implémentation définie dans le même fichier:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">const</span> STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">'a11y'</span><span style="color: #339933;">:</span> imports.<span style="color: #660066;">ui</span>.<span style="color: #000066;">status</span>.<span style="color: #660066;">accessibility</span>.<span style="color: #660066;">ATIndicator</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'volume'</span><span style="color: #339933;">:</span> imports.<span style="color: #660066;">ui</span>.<span style="color: #000066;">status</span>.<span style="color: #660066;">volume</span>.<span style="color: #660066;">Indicator</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'battery'</span><span style="color: #339933;">:</span> imports.<span style="color: #660066;">ui</span>.<span style="color: #000066;">status</span>.<span style="color: #660066;">power</span>.<span style="color: #660066;">Indicator</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'keyboard'</span><span style="color: #339933;">:</span> imports.<span style="color: #660066;">ui</span>.<span style="color: #000066;">status</span>.<span style="color: #660066;">keyboard</span>.<span style="color: #660066;">XKBIndicator</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Modifions <code>extension.js</code> :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">const</span> Panel <span style="color: #339933;">=</span> imports.<span style="color: #660066;">ui</span>.<span style="color: #660066;">panel</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	Panel.<span style="color: #660066;">STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'a11y'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Les extensions se chargeant avant la construction de la zone de statut, cette dernière sera chargée sans cette icône.</p>
<p>Le but de départ est atteint, mais ça fait peu pour une extension (qui modifie une constante en plus). Quitte à découvrir, je me suis dit pourquoi ne pas aussi modifier l&#8217;ordre d&#8217;apparition des icônes et de fil en aiguille, j&#8217;ai fait une extension un peu plus conséquente: <a href="http://tuxce.no-ip.org/~tuxce/archlinux/gnome-shell/gnome-shell-msa-1-1.src.tar.gz">gnome-shell-msa</a></p>
<p>L&#8217;archive contient un <a href="http://wiki.archlinux.fr/PKGBUILD">PKGBUILD</a> et les fichiers composant l&#8217;extension:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">wget http://tuxce.no-ip.org/~tuxce/archlinux/gnome-shell/gnome-shell-msa-1-1.src.tar.gz
tar xzxvf gnome-shell-msa-1-1.src.tar.gz
cd gnome-shell-msa-1-1
makepkg -i</pre></div></div>

<p>Elle a besoin d&#8217;être installée parce que pour le moment, je n&#8217;ai pas trouvé comment faire accepter à GSettings un schéma en dehors de <code>/usr/share/glib-2.0/schemas</code>.</p>
<p>Redémarrer <code>gnome-shell</code>.</p>
<p>Quelques essais:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Placer le bluetooth et la batterie en premiers</span>
gsettings <span style="color: #000000; font-weight: bold;">set</span> org.gnome.shell.extensions.msa icon-order <span style="color: #ff0000;">&quot;['bluetooth', 'battery']&quot;</span>
<span style="color: #666666; font-style: italic;"># Cacher l'accès universel</span>
gsettings <span style="color: #000000; font-weight: bold;">set</span> org.gnome.shell.extensions.msa icons-hide <span style="color: #ff0000;">&quot;['a11y']&quot;</span>
<span style="color: #666666; font-style: italic;"># Remttre à 0</span>
gsettings reset org.gnome.shell.extensions.msa icons-hide
gsettings reset org.gnome.shell.extensions.msa icons-order
<span style="color: #666666; font-style: italic;"># Désactiver l'icône de l'accès universel (nécessite un redémarrage de gnome-shell)</span>
gsettings <span style="color: #000000; font-weight: bold;">set</span> org.gnome.shell.extensions.msa icons-disable <span style="color: #ff0000;">&quot;['a11y']&quot;</span></pre></div></div>

<blockquote><p>
L&#8217;extension était juste un moyen de voir un peu ce que permet Gnome Shell, et étant donné qu&#8217;une extension contient un fichier <code>metadata.json</code> contenant la version exacte de Gnome Shell, elle sera périmée dès la première mise à jour.
</p></blockquote>
<hr style="width: 50%"/>
<p>La documentation n&#8217;étant pas si simple à trouver, voici les ressources que j&#8217;ai utilisé:</p>
<ul>
<li><a href="http://blog.fpmurphy.com/tag/gnome-shell">Musings of an OS plumber</a>, un ensemble d&#8217;article couvrant la personalisation de Gnome Shell</li>
<li><a href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/">API Gjs</a>. Il existe 2 implémentation Javascript sous Gnome <a href="https://live.gnome.org/Seed">Seed</a> étant l&#8217;implémentation Javascript basée sur le moteur <a href="http://www.webkit.org/">Webkit</a> alors que <a href="https://live.gnome.org/Gjs">Gjs</a> est basé sur <a href="http://www.mozilla.org/js/spidermonkey/">SpiderMonkey</a>, Gnome n&#8217;a pas encore tranché entre les deux même si Gnome Shell utilise Gjs.</li>
<li><a href="http://git.gnome.org/browse/gnome-shell-extensions/tree/extensions">gnome-shell-extensions</a> qui sont disponibles sur <a href="https://aur.archlinux.org">AUR</a> pour Archlinux.</li>
<li>Les fichiers sources de <a href="http://git.gnome.org/browse/gnome-shell/tree/js/ui">gnome-shell, js/ui</a></li>
<li>+ l&#8217;ensemble des liens de l&#8217;article</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/gnome-shell-extensions-modifier-la-zone-de-statut/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fuseaux horaire sous GNU/Linux.</title>
		<link>http://tuxce.no-ip.org/informatique/fuseaux-horaire-sous-gnulinux</link>
		<comments>http://tuxce.no-ip.org/informatique/fuseaux-horaire-sous-gnulinux#comments</comments>
		<pubDate>Sun, 31 Oct 2010 18:50:13 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[timezone]]></category>

		<guid isPermaLink="false">http://tuxce.selfip.org/?p=420</guid>
		<description><![CDATA[A l&#8217;origine, un fuseau horaire est une zone géographique avec une heure unique, ceci dit, pour des raisons propres (ou communes), un pays peut avoir son propre fuseau horaire qui de plus change au cours de l&#8217;année pour des questions d&#8217;économie d&#8217;énergie (DST: Day light saving time). GNU/Linux utilise le fichier /etc/locatime pour connaître le [...]]]></description>
			<content:encoded><![CDATA[<p>A l&#8217;origine, un <a href="http://fr.wikipedia.org/wiki/Fuseau_horaire">fuseau horaire</a> est une zone géographique avec une heure unique, ceci dit, pour des raisons propres (ou communes), un pays peut avoir son propre fuseau horaire qui de plus change au cours de l&#8217;année pour des questions d&#8217;économie d&#8217;énergie (DST: Day light saving time).</p>
<p>GNU/Linux utilise le fichier <code>/etc/locatime</code> pour connaître le fuseau horaire en fonction sur le système. Ce fichier est souvent une copie ou lien vers un fichier de la base de données <code>tzdata</code> fourni par le paquet du même nom (sous la plupart des distributions).</p>
<p>Ces fichiers ne sont pas lisibles, mais on peut avoir des informations dessus avec l&#8217;utilitaire <code>zdump</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">zdump</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>localtime <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>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>Paris <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>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>London 
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>localtime                     Sun Oct <span style="color: #000000;">31</span> <span style="color: #000000;">20</span>:<span style="color: #000000;">44</span>:<span style="color: #000000;">43</span> <span style="color: #000000;">2010</span> CET
<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>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>Paris   Sun Oct <span style="color: #000000;">31</span> <span style="color: #000000;">20</span>:<span style="color: #000000;">44</span>:<span style="color: #000000;">43</span> <span style="color: #000000;">2010</span> CET
<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>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>London  Sun Oct <span style="color: #000000;">31</span> <span style="color: #000000;">19</span>:<span style="color: #000000;">44</span>:<span style="color: #000000;">43</span> <span style="color: #000000;">2010</span> GMT</pre></div></div>

<p>On peut aussi avoir la liste des changements d&#8217;heure selon le fuseau horaire:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">zdump</span> <span style="color: #660033;">-v</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>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>Paris <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000;">2010</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>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>Paris  Sun Mar <span style="color: #000000;">28</span> 00:<span style="color: #000000;">59</span>:<span style="color: #000000;">59</span> <span style="color: #000000;">2010</span> UTC = Sun Mar <span style="color: #000000;">28</span> 01:<span style="color: #000000;">59</span>:<span style="color: #000000;">59</span> <span style="color: #000000;">2010</span> CET <span style="color: #007800;">isdst</span>=<span style="color: #000000;">0</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>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>Paris  Sun Mar <span style="color: #000000;">28</span> 01:00:00 <span style="color: #000000;">2010</span> UTC = Sun Mar <span style="color: #000000;">28</span> 03:00:00 <span style="color: #000000;">2010</span> CEST <span style="color: #007800;">isdst</span>=<span style="color: #000000;">1</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>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>Paris  Sun Oct <span style="color: #000000;">31</span> 00:<span style="color: #000000;">59</span>:<span style="color: #000000;">59</span> <span style="color: #000000;">2010</span> UTC = Sun Oct <span style="color: #000000;">31</span> 02:<span style="color: #000000;">59</span>:<span style="color: #000000;">59</span> <span style="color: #000000;">2010</span> CEST <span style="color: #007800;">isdst</span>=<span style="color: #000000;">1</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>zoneinfo<span style="color: #000000; font-weight: bold;">/</span>Europe<span style="color: #000000; font-weight: bold;">/</span>Paris  Sun Oct <span style="color: #000000;">31</span> 01:00:00 <span style="color: #000000;">2010</span> UTC = Sun Oct <span style="color: #000000;">31</span> 02:00:00 <span style="color: #000000;">2010</span> CET <span style="color: #007800;">isdst</span>=<span style="color: #000000;">0</span></pre></div></div>

<p>GNU/linux utilise une horloge système et une matérielle (celle du <a href="http://fr.wikipedia.org/wiki/Basic_Input_Output_System">BIOS</a>).</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">$ hwclock --debug
hwclock de util-linux-ng 2.18
Utilisant /dev interface to clock.
Le dernier ajustement de dérive a été fait 1288551786 secondes après 1969
La dernière calibration a été faite 1288300319 secondes après 1969
L'horloge matérielle fonctionne selon le temps UTC
On assume que l'horloge matérielle est conservée dans le temps de UTC.
En attente d'un tic d'horloge...
...a obtenu un tic d'horloge
Heure lu de l'horloge matérielle: 2010/10/31 19:06:52
Heure de l'horloge matérielle : 2010/10/31 19:06:52 = 1288552012 secondes depuis 1969
dim. 31 oct. 2010 20:06:52 CET  -0.307298 secondes</pre></div></div>

<p>Si elle est configurée comme étant le <a href="http://fr.wikipedia.org/wiki/Temps_universel_coordonn%C3%A9">temps universel</a> (UTC), le résultat d&#8217;une demande d&#8217;heure est en fait l&#8217;heure UTC + le décalage du fuseau, donc du moment que le fichier <code>/etc/localtime</code> est bien configuré, le système suivra les changements d&#8217;heure sans souci.</p>
<p>Par contre, si votre horloge matérielle est configurée pour correspondre à l&#8217;heure locale, le système ne fait pas grand chose et le changement d&#8217;heure ne se fait pas automatiquement. Mais comme on règle l&#8217;heure matérielle sur l&#8217;heure locale seulement quand on a un Microsoft Windows en dual boot, l&#8217;heure sera réglée par ce dernier.</p>
<p>Sinon il faut le faire manuellement:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">date 10312008</pre></div></div>

<p>Et comme le système garde une trace du <a href="http://en.wikipedia.org/wiki/Clock_drift">décalage de l&#8217;heure</a> matérielle, il serait bon de la régler pour ne pas faire croire au système que le matériel dérive d&#8217;une heure:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">hwclock --noadjfile --localtime -w</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/fuseaux-horaire-sous-gnulinux/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Soumis au bon vouloir de ConsoleKit.</title>
		<link>http://tuxce.no-ip.org/informatique/soumis-au-bon-vouloir-de-consolekit</link>
		<comments>http://tuxce.no-ip.org/informatique/soumis-au-bon-vouloir-de-consolekit#comments</comments>
		<pubDate>Thu, 28 Oct 2010 14:45:19 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[consolekit]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pam]]></category>

		<guid isPermaLink="false">http://tuxce.selfip.org/?p=404</guid>
		<description><![CDATA[Pour ceux à qui ConsoleKit ne dit rien du tout, vous pouvez vous référer aux pages wiki archlinux.fr (les explications étant génériques): wiki consolekit. En bref, ConsoleKit s&#8217;occupe de traquer l&#8217;état des sessions de l&#8217;utilisateur en suivant des données parmi lesquelles: l&#8217;état actif de la session.ex: vous avez lancé X et avez changé vers un [...]]]></description>
			<content:encoded><![CDATA[<p>Pour ceux à qui <a href="http://freedesktop.org/wiki/Software/ConsoleKit">ConsoleKit</a> ne dit rien du tout, vous pouvez vous référer aux pages wiki archlinux.fr (les explications étant génériques): <a href="http://wiki.archlinux.fr/systeme/consolekit">wiki consolekit</a>.</p>
<p>En bref, <strong>ConsoleKit</strong> s&#8217;occupe de traquer l&#8217;état des sessions de l&#8217;utilisateur en suivant des données parmi lesquelles:</p>
<ul>
<li>l&#8217;état actif de la session.<br/>ex: vous avez lancé X et avez changé vers un terminal (ctrl-alt-f1), votre session X n&#8217;est plus active.</li>
<li>l&#8217;emplacement de la session<br />ex: une connexion depuis ssh n&#8217;est pas &laquo;&nbsp;locale&nbsp;&raquo;.</li>
<li>&#8230;</li>
</ul>
<p>Ces deux informations influencent directement toutes les actions sur les périphériques (si gérés par des programmes compatibles), par exemple, <a href="http://pcmanfm.sourceforge.net/">PCManFm</a> ou <a href="http://live.gnome.org/Nautilus">Nautilus</a> passent par <a href="http://freedesktop.org/wiki/Software/PolicyKit">PolicyKit</a> (<a href="http://wiki.archlinux.fr/systeme/policykit">wiki</a>) pour savoir s&#8217;ils ont la permission de monter un périphérique ou pas.</p>
<p>Cette introduction pour dire qu&#8217;à partir de la version 0.4.2 de ConsoleKit, qui est notamment celle disponible sur le dépôt [testing] d&#8217;Arch Linux, la détection d&#8217;une session locale change de méthode.</p>
<p>Avant, c&#8217;était plus en devinant que le programme déterminait l&#8217;état &laquo;&nbsp;locale&nbsp;&raquo; ou non de la session, il suffisait d&#8217;avoir un:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">exec</span> ck-launch-session openbox-session
<span style="color: #666666; font-style: italic;"># ou autre environnement de bureau</span></pre></div></div>

<p>dans le <code>$HOME/.xinitrc</code>, et suite au <code>startx</code>, la session était locale et les droits étaient donnés à l&#8217;utilisateur.</p>
<p>A partir de la 0.4.2, seul le <code>root</code> peut définir l&#8217;état &laquo;&nbsp;locale&nbsp;&raquo;, et adieu les permissions pour les utilisateurs n&#8217;utilisant pas de gestionnaire de connexions compatibles tel <a href="http://projects.gnome.org/gdm/">GDM</a>. PCManFm ou Nautilus nous sortent une belle fenêtre &laquo;&nbsp;Not authorized&nbsp;&raquo; à chaque tentative de montage.</p>
<p>La solution consiste à ajouter un connecteur <a href="http://www.kernel.org/pub/linux/libs/pam/">PAM</a> pour que ce soit le <code>root</code> qui crée la session en lui donnant pour le coup le bon état.</p>
<p>Pour une connexion depuis le terminal (par le programme &laquo;&nbsp;login&nbsp;&raquo;), il faut avoir:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">session		optional	pam_ck_connector.so</pre></div></div>

<p>dans <code>/etc/pam.d/login</code>.</p>
<p>Si vous utilisez un gestionnaire de connexions tel que <a href="http://slim.berlios.de/">SLiM</a>, il faut faire pareil dans <code>/etc/pam.d/slim</code>.</p>
<hr/>
<a href="https://bugs.archlinux.org/task/21391">FS#21391</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/soumis-au-bon-vouloir-de-consolekit/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Page forum archlinux.fr sur votre mobile</title>
		<link>http://tuxce.no-ip.org/informatique/page-forum-archlinux-fr-sur-votre-mobile</link>
		<comments>http://tuxce.no-ip.org/informatique/page-forum-archlinux-fr-sur-votre-mobile#comments</comments>
		<pubDate>Tue, 26 Oct 2010 16:30:20 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpbb]]></category>

		<guid isPermaLink="false">http://tuxce.selfip.org/?p=400</guid>
		<description><![CDATA[Suivant pas mal le forum archlinux.fr, il m&#8217;arrive de vouloir y accéder depuis mon mobile, mais le format de la page est tout sauf compatible avec un mobile, alors pour faire simple, j&#8217;ai fait un petit script de pas grand chose pour afficher la liste des derniers posts accessible ici Source: archforum.php]]></description>
			<content:encoded><![CDATA[<p>Suivant pas mal le forum <a href="http://forums.archlinux.fr">archlinux.fr</a>, il m&#8217;arrive de vouloir y accéder depuis mon mobile, mais le format de la page est tout sauf compatible avec un mobile, alors pour faire simple, j&#8217;ai fait un petit script de pas grand chose pour afficher la liste des derniers posts accessible <a href="http://tuxce.no-ip.org/~tuxce/archforum.php">ici</a></p>
<p>Source: <a href="http://tuxce.no-ip.org/~tuxce/archforum.phps">archforum.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/page-forum-archlinux-fr-sur-votre-mobile/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Installer un paquet Arch linux directement depuis firefox</title>
		<link>http://tuxce.no-ip.org/informatique/installer-un-paquet-arch-linux-directement-depuis-firefox</link>
		<comments>http://tuxce.no-ip.org/informatique/installer-un-paquet-arch-linux-directement-depuis-firefox#comments</comments>
		<pubDate>Mon, 12 Jul 2010 15:04:54 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pacman]]></category>

		<guid isPermaLink="false">http://tuxce.selfip.org/?p=381</guid>
		<description><![CDATA[C&#8217;est sûrement le genre de chose qui va finir aux oubliettes parce qu&#8217;il va être utilisé qu&#8217;une fois, mais peu importe, c&#8217;est aussi par curiosité. De temps en temps, après une mise à jour à problème comme celle d&#8217;autoconf 2.66 actuellement, je voudrais réinstaller l&#8217;ancienne version du paquet, en théorie, il suffit d&#8217;aller dans le [...]]]></description>
			<content:encoded><![CDATA[<p>C&#8217;est sûrement le genre de chose qui va finir aux oubliettes parce qu&#8217;il va être utilisé qu&#8217;une fois, mais peu importe, c&#8217;est aussi par curiosité.</p>
<p>De temps en temps, après une mise à jour à problème comme celle d&#8217;<a href="http://bugs.archlinux.org/task/20060">autoconf 2.66</a> actuellement, je voudrais réinstaller l&#8217;ancienne version du paquet, en théorie, il suffit d&#8217;aller dans le cache: <code>/var/cache/pacman/pkg</code>, mais si on l&#8217;a effacé, il faut se rabattre sur l&#8217;une des <a href="http://wiki.archlinux.fr/arch/downgrade">méthodes décrites dans le wiki</a>. J&#8217;avais fait un script il y a longtemps pour <a href="http://tuxce.no-ip.org/informatique/les-mises-a-jour-magiques">revenir en arrière</a>, mais encore faut il connaître la date du dernier paquet voulu.</p>
<p>Une autre méthode est de naviguer sur <a href="http://arm.kh.nu/">http://arm.kh.nu/</a> puis télécharger, lancer <code>pacman</code> etc&#8230;</p>
<p>Pour automatiser le téléchargement et lancement de <code>pacman</code>, je vais créer un protocole du genre d&#8217;<a href="http://doc.ubuntu-fr.org/apturl">apt://</a> et utiliser le script <a href="http://www.greasespot.net/">greasemonkey</a> suivant:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// ==UserScript==</span>
<span style="color: #006600; font-style: italic;">// @name           Pacman package</span>
<span style="color: #006600; font-style: italic;">// @namespace      http://tuxce.no-ip.org</span>
<span style="color: #006600; font-style: italic;">// @description    Install a pacman package</span>
<span style="color: #006600; font-style: italic;">// @include        http://arm.kh.nu/*</span>
<span style="color: #006600; font-style: italic;">// ==/UserScript==</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> allElements<span style="color: #339933;">,</span> thisElement<span style="color: #339933;">;</span>
allElements <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pkg_re<span style="color: #339933;">=</span><span style="color: #009966; font-style: italic;">/\.pkg\.tar\./</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> allElements.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	thisElement <span style="color: #339933;">=</span> allElements<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>thisElement.<span style="color: #660066;">href</span>.<span style="color: #660066;">match</span> <span style="color: #009900;">&#40;</span>pkg_re<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> a_custom <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		a_custom.<span style="color: #660066;">setAttribute</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'pacman://'</span> <span style="color: #339933;">+</span> thisElement.<span style="color: #660066;">href</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		a_custom.<span style="color: #660066;">appendChild</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">createTextNode</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		thisElement.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">insertBefore</span> <span style="color: #009900;">&#40;</span>a_custom<span style="color: #339933;">,</span> thisElement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		thisElement.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">insertBefore</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">createTextNode</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> thisElement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		i<span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Cliquer sur le lien suivant pour l&#8217;installer si vous avez <code>Greasemonkey</code>: <a href="http://tuxce.no-ip.org/contents/greasemonkey/pacman_package.user.js">pacman_package.user.js</a></p>
<p>On crée un script pour prendre en charge l&#8217;url:</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;
urxvtc <span style="color: #660033;">-e</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> pacman <span style="color: #660033;">-U</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${1:9}</span>&quot;</span></pre></div></div>

<p><code>urxvtc -e</code> à modifier selon le terminal que vous utilisez.</p>
<p>Il ne reste plus qu&#8217;à ajouter la prise en compte du protocole par <a href="http://www.mozilla-europe.org/fr/firefox/">firefox</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">gconftool-2 -s -t string /desktop/gnome/url-handlers/pacman/command &quot;chemin_vers_le_script '%s'&quot;
gconftool-2 -s -t boolean /desktop/gnome/url-handlers/pacman/enable true</pre></div></div>

<p>Aller sur <a href="http://arm.kh.nu/">http://arm.kh.nu/</a>, si vous avez <code>Greasemonkey</code> d&#8217;activé, vous devriez voir apparaître &laquo;&nbsp;<code># </code>&nbsp;&raquo; devant chaque paquet, cliquez sur celui que vous voulez, au premier clic, il faudra donner le script avec lequel firefox gérera le lien, et c&#8217;est bon.</p>
]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/installer-un-paquet-arch-linux-directement-depuis-firefox/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trouver les capacités (capabilities) d&#8217;un programme</title>
		<link>http://tuxce.no-ip.org/informatique/trouver-les-capacites-capabilities-dun-programme</link>
		<comments>http://tuxce.no-ip.org/informatique/trouver-les-capacites-capabilities-dun-programme#comments</comments>
		<pubDate>Tue, 09 Feb 2010 22:02:30 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[capabilities]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[posix]]></category>

		<guid isPermaLink="false">http://tuxce.selfip.org/?p=362</guid>
		<description><![CDATA[Suite à , il restait une question en suspens. Pouvoir trouver les capacités nécéssaire à un programme; pour cela, on peut utiliser la capacité qu&#8217;offre le noyau pour &#171;&#160;court circuiter&#160;&#187; des fonctions: Kernel Probes Le principe est simple si on connaît la fonction appellée, on crée un module ayant une fonction similaire (même prototype) qui [...]]]></description>
			<content:encoded><![CDATA[<p>Suite à <a href="http://tuxce.no-ip.org/informatique/posix-capabilities">l&#8217;article précédent sur les capacités POSIX</a>, il restait une question en suspens. Pouvoir trouver les capacités nécéssaire à un programme; pour cela, on peut utiliser la capacité qu&#8217;offre le noyau pour &laquo;&nbsp;court circuiter&nbsp;&raquo; des fonctions: <a href="http://www.mjmwired.net/kernel/Documentation/kprobes.txt">Kernel Probes</a> </p>
<p>Le principe est simple si on connaît la fonction appellée, on crée un module ayant une fonction similaire (même prototype) qui log les demandes de capacités selon un nom de programme passé en paramètre au module. Ce dernier nécessite que le noyau ait certaines options d&#8217;activées (<code>CONFIG_KPROBES, CONFIG_KALLSYMS_ALL, CONFIG_KALLSYMS</code> entre autres) ce qui n&#8217;est pas le cas par défaut sur Arch Linux par exemple, vous pouvez télécharger une version modifiée du PKGBUILD du paquet <code>kernel26</code> version 2.6.32.7-1: <a href='http://tuxce.no-ip.org/wp-content/uploads/2010/02/kernel26-2.6.32.7-1.src.tar.gz'>kernel26-2.6.32.7-1.src.tar.gz</a></p>
<p>Le module est celui de l&#8217;article de Serge E. Hallyn [<a href="#ressource2_1">1</a>], j&#8217;y ai juste rajouté le paramètre pour le nom du programme à surveiller ainsi qu&#8217;un tableau pour me sortir directement la capacité en texte.<br />
Archive: <a href='http://tuxce.no-ip.org/wp-content/uploads/2010/02/capable_probe.tar.gz'>capable_probe.tar.gz</a><br />
<code>capable_probe.c</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Original taken from http://www.ibm.com/developerworks/library/l-posixcap.html</span>
<span style="color: #666666; font-style: italic;">// By Serge E. Hallyn (sergeh at us.ibm.com)</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Modified by tuxce &lt;tuxce.net at gmail.com&gt;</span>
<span style="color: #666666; font-style: italic;">//</span>
&nbsp;
<span style="color: #339933;">#include &lt;linux/kernel.h&gt;</span>
<span style="color: #339933;">#include &lt;linux/module.h&gt;</span>
<span style="color: #339933;">#include &lt;linux/kprobes.h&gt;</span>
<span style="color: #339933;">#include &lt;linux/sched.h&gt;</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">char</span> progname<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">255</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
module_param_string<span style="color: #009900;">&#40;</span>progname<span style="color: #339933;">,</span> progname<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>progname<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #208080;">0644</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
MODULE_PARM_DESC<span style="color: #009900;">&#40;</span>progname<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Program name.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>probed_func <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;cap_capable&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>cr_cap<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #ff0000;">&quot;CAP_CHOWN&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_DAC_OVERRIDE&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_DAC_READ_SEARCH&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_FOWNER&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_FSETID&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_KILL&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #ff0000;">&quot;CAP_SETGID&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SETUID&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SETPCAP&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_LINUX_IMMUTABLE&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_NET_BIND_SERVICE&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_NET_BROADCAST&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_NET_ADMIN&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_NET_RAW&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_IPC_LOCK&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_IPC_OWNER&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SYS_MODULE&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_SYS_RAWIO&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SYS_CHROOT&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SYS_PTRACE&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_SYS_PACCT&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SYS_ADMIN&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SYS_BOOT&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_SYS_NICE&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SYS_RESOURCE&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SYS_TIME&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_SYS_TTY_CONFIG&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_MKNOD&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_LEASE&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_AUDIT_WRITE&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_AUDIT_CONTROL&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_SETFCAP&quot;</span><span style="color: #339933;">,</span> 
	<span style="color: #ff0000;">&quot;CAP_MAC_OVERRIDE&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;CAP_MAC_ADMIN&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> cr_capable <span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> task_struct <span style="color: #339933;">*</span>tsk<span style="color: #339933;">,</span> <span style="color: #993333;">const</span> <span style="color: #993333;">struct</span> cred <span style="color: #339933;">*</span>cred<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> cap<span style="color: #339933;">,</span> 
	<span style="color: #993333;">int</span> audit<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>strcmp<span style="color: #009900;">&#40;</span>tsk<span style="color: #339933;">-&gt;</span>comm<span style="color: #339933;">,</span>progname<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>cap <span style="color: #339933;">&gt;=</span><span style="color: #0000dd;">0</span> <span style="color: #339933;">&amp;&amp;</span> cap <span style="color: #339933;">&lt;=</span> <span style="color: #0000dd;">33</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			printk<span style="color: #009900;">&#40;</span>KERN_NOTICE <span style="color: #ff0000;">&quot;%s: asking for capability %s for %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
				__FUNCTION__<span style="color: #339933;">,</span> cr_cap<span style="color: #009900;">&#91;</span>cap<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> tsk<span style="color: #339933;">-&gt;</span>comm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			printk<span style="color: #009900;">&#40;</span>KERN_NOTICE <span style="color: #ff0000;">&quot;%s: asking for capability %d for %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
				__FUNCTION__<span style="color: #339933;">,</span> cap<span style="color: #339933;">,</span> tsk<span style="color: #339933;">-&gt;</span>comm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	jprobe_return<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> jprobe jp <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	.<span style="color: #202020;">entry</span> <span style="color: #339933;">=</span> JPROBE_ENTRY<span style="color: #009900;">&#40;</span>cr_capable<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> __init kprobe_init<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">int</span> ret<span style="color: #339933;">;</span>
	jp.<span style="color: #202020;">kp</span>.<span style="color: #202020;">symbol_name</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>probed_func<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ret <span style="color: #339933;">=</span> register_jprobe<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>jp<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		printk<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s: register_jprobe failed, returned %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
			__FUNCTION__<span style="color: #339933;">,</span> ret<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">void</span> __exit kprobe_exit<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	unregister_jprobe<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>jp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	printk<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;capable kprobes unregistered<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
module_init<span style="color: #009900;">&#40;</span>kprobe_init<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
module_exit<span style="color: #009900;">&#40;</span>kprobe_exit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
MODULE_LICENSE<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;GPL&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><code>Makefile</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="make" style="font-family:monospace;"><span style="color: #339900; font-style: italic;"># Taken from http://www.ibm.com/developerworks/library/l-posixcap.html</span>
obj<span style="color: #004400;">-</span>m <span style="color: #004400;">:=</span> capable_probe<span style="color: #004400;">.</span>o
KDIR <span style="color: #004400;">:=</span> <span style="color: #004400;">/</span>lib<span style="color: #004400;">/</span>modules<span style="color: #004400;">/$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">shell</span> uname <span style="color: #004400;">-</span>r<span style="color: #004400;">&#41;</span><span style="color: #004400;">/</span>build
PWD <span style="color: #004400;">:=</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">shell</span> pwd<span style="color: #004400;">&#41;</span>
default<span style="color: #004400;">:</span>
	<span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">MAKE</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">-</span>C <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">KDIR</span><span style="color: #004400;">&#41;</span> SUBDIRS<span style="color: #004400;">=$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">PWD</span><span style="color: #004400;">&#41;</span> modules
install<span style="color: #004400;">:</span> default
	install <span style="color: #004400;">-</span>d <span style="color: #004400;">/</span>lib<span style="color: #004400;">/</span>modules<span style="color: #004400;">/$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">shell</span> uname <span style="color: #004400;">-</span>r<span style="color: #004400;">&#41;</span><span style="color: #004400;">/</span>kernel<span style="color: #004400;">/</span>misc<span style="color: #004400;">/</span>
	install capable_probe<span style="color: #004400;">.</span>ko <span style="color: #004400;">/</span>lib<span style="color: #004400;">/</span>modules<span style="color: #004400;">/$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">shell</span> uname <span style="color: #004400;">-</span>r<span style="color: #004400;">&#41;</span><span style="color: #004400;">/</span>kernel<span style="color: #004400;">/</span>misc<span style="color: #004400;">/</span>
	depmod <span style="color: #004400;">-</span>a
clean<span style="color: #004400;">:</span>
	rm <span style="color: #004400;">-</span>f <span style="color: #004400;">*.</span>mod<span style="color: #004400;">.</span>c <span style="color: #004400;">*.</span>ko <span style="color: #004400;">*.</span>o</pre></div></div>

<p>On compile:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>2.6.32-ARCH<span style="color: #000000; font-weight: bold;">/</span>build <span style="color: #007800;">SUBDIRS</span>=<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>tuxce<span style="color: #000000; font-weight: bold;">/</span>posix<span style="color: #000000; font-weight: bold;">/</span>capable modules
<span style="color: #c20cb9; font-weight: bold;">make</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: entrant dans le répertoire « <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>linux-2.6.32-ARCH »
  CC <span style="color: #7a0874; font-weight: bold;">&#91;</span>M<span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>tuxce<span style="color: #000000; font-weight: bold;">/</span>posix<span style="color: #000000; font-weight: bold;">/</span>capable<span style="color: #000000; font-weight: bold;">/</span>capable_probe.o
  Building modules, stage <span style="color: #000000;">2</span>.
  MODPOST <span style="color: #000000;">1</span> modules
  CC      <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>tuxce<span style="color: #000000; font-weight: bold;">/</span>posix<span style="color: #000000; font-weight: bold;">/</span>capable<span style="color: #000000; font-weight: bold;">/</span>capable_probe.mod.o
  LD <span style="color: #7a0874; font-weight: bold;">&#91;</span>M<span style="color: #7a0874; font-weight: bold;">&#93;</span>  <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>tuxce<span style="color: #000000; font-weight: bold;">/</span>posix<span style="color: #000000; font-weight: bold;">/</span>capable<span style="color: #000000; font-weight: bold;">/</span>capable_probe.ko
<span style="color: #c20cb9; font-weight: bold;">make</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: quittant le répertoire « <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>linux-2.6.32-ARCH »
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> insmod capable_probe.ko <span style="color: #007800;">progname</span>=<span style="color: #c20cb9; font-weight: bold;">ping</span></pre></div></div>

<p>Si tout se passe bien, vous devrez pouvoir récuperer les capacités demandées dans le log, <code>/var/log/messages.log</code> pour Arch Linux:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ping</span> <span style="color: #660033;">-c</span> <span style="color: #000000;">1</span> 127.0.0.1
PING 127.0.0.1 <span style="color: #7a0874; font-weight: bold;">&#40;</span>127.0.0.1<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">56</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">84</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> bytes of data.
<span style="color: #000000;">64</span> bytes from 127.0.0.1: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">64</span> <span style="color: #007800;">time</span>=<span style="color: #000000;">0.064</span> ms
&nbsp;
<span style="color: #660033;">---</span> 127.0.0.1 <span style="color: #c20cb9; font-weight: bold;">ping</span> statistics <span style="color: #660033;">---</span>
<span style="color: #000000;">1</span> packets transmitted, <span style="color: #000000;">1</span> received, <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> packet loss, <span style="color: #000000; font-weight: bold;">time</span> 0ms
rtt min<span style="color: #000000; font-weight: bold;">/</span>avg<span style="color: #000000; font-weight: bold;">/</span>max<span style="color: #000000; font-weight: bold;">/</span>mdev = <span style="color: #000000;">0.064</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.064</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.064</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.000</span> ms
$ <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #660033;">-2</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>messages.log
Feb  <span style="color: #000000;">8</span> <span style="color: #000000;">17</span>:<span style="color: #000000;">30</span>:<span style="color: #000000;">44</span> host kernel: cr_capable: asking <span style="color: #000000; font-weight: bold;">for</span> capability CAP_NET_RAW <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">ping</span>
Feb  <span style="color: #000000;">8</span> <span style="color: #000000;">17</span>:<span style="color: #000000;">30</span>:<span style="color: #000000;">44</span> host kernel: cr_capable: asking <span style="color: #000000; font-weight: bold;">for</span> capability CAP_SETUID <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">ping</span></pre></div></div>

<p>Dans le log, on voit que <code>ping</code> demande <code>CAP_NET_RAW</code> (qu&#8217;on a utilisé dans l&#8217;exemple de l&#8217;article précédent), de même que <code>CAP_SETUID</code>, cette dernière est utilisée pour passer de <code>root</code> à l&#8217;utilisateur exécutant la commande, mais comme on a supprimé le <code>setuid</code>, ce n&#8217;est plus nécessaire.</p>
<p>L&#8217;utilisation du module est assez simple, ou bien on le décharge puis charge avec le bon paramètre, ou on modifie le paramètre en cours de fonctionnement:</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;">cp</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>crontab<span style="color: #7a0874; font-weight: bold;">&#123;</span>,.x<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> crontab.x <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">tee</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>module<span style="color: #000000; font-weight: bold;">/</span>capable_probe<span style="color: #000000; font-weight: bold;">/</span>parameters<span style="color: #000000; font-weight: bold;">/</span>progname
crontab.x <span style="color: #660033;">-e</span></pre></div></div>

<p>Et voyons voir ce que demande crontab:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Feb  <span style="color: #000000;">8</span> <span style="color: #000000;">18</span>:<span style="color: #000000;">18</span>:<span style="color: #000000;">33</span> host kernel: cr_capable: asking <span style="color: #000000; font-weight: bold;">for</span> capability CAP_SETGID <span style="color: #000000; font-weight: bold;">for</span> crontab.x
Feb  <span style="color: #000000;">8</span> <span style="color: #000000;">18</span>:<span style="color: #000000;">18</span>:<span style="color: #000000;">33</span> host kernel: cr_capable: asking <span style="color: #000000; font-weight: bold;">for</span> capability CAP_DAC_OVERRIDE <span style="color: #000000; font-weight: bold;">for</span> crontab.x
Feb  <span style="color: #000000;">8</span> <span style="color: #000000;">18</span>:<span style="color: #000000;">18</span>:<span style="color: #000000;">33</span> host kernel: cr_capable: asking <span style="color: #000000; font-weight: bold;">for</span> capability CAP_DAC_OVERRIDE <span style="color: #000000; font-weight: bold;">for</span> crontab.x</pre></div></div>

<p>Là, on a exécuté la commande <code>"crontab -e"</code> car elle demande plus de privilèges que par exemple <code>"crontab -l"</code>.<br />
Selon la sortie du log, pour se débarasser du <code>setuid</code> de <code>crontab</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> setcap CAP_DAC_OVERRIDE,<span style="color: #007800;">CAP_SETGID</span>=ep crontab</pre></div></div>

<hr/>
<br/><br />
Ressources:<br />
<a id="ressource2_1" href="http://www.ibm.com/developerworks/aix/library/l-posixcap.html">POSIX file capabilities: Parceling the power of root</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/trouver-les-capacites-capabilities-dun-programme/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Posix Capabilities</title>
		<link>http://tuxce.no-ip.org/informatique/posix-capabilities</link>
		<comments>http://tuxce.no-ip.org/informatique/posix-capabilities#comments</comments>
		<pubDate>Tue, 09 Feb 2010 22:02:21 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[capabilities]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[posix]]></category>

		<guid isPermaLink="false">http://tuxce.selfip.org/?p=344</guid>
		<description><![CDATA[Donner plus ou moins de privilèges à un utilisateur a et est toujours un casse tête sur un système d&#8217;exploitation. Autant, le fait que certaines actions nécessitent d&#8217;être root ne gène pas, autant certaines autres, la plupart du temps effectués par l&#8217;utilisateur, font paraître le passage en root comme une action supplémentaire superflue. La méthode [...]]]></description>
			<content:encoded><![CDATA[<p>Donner plus ou moins de privilèges à un utilisateur a et est toujours un casse tête sur un système d&#8217;exploitation. Autant, le fait que certaines actions nécessitent d&#8217;être <code>root</code> ne gène pas, autant certaines autres, la plupart du temps effectués par l&#8217;utilisateur, font paraître le passage en <code>root</code> comme une action supplémentaire superflue.</p>
<p>La méthode classique est d&#8217;avoir ces programmes en <code>setuid root</code> (+s):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-al</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;">ping</span>
<span style="color: #660033;">-rwsr-xr-x</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">31020</span>  <span style="color: #000000;">4</span> oct.   <span style="color: #000000;">2008</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;">ping</span></pre></div></div>

<p>Le souci, c&#8217;est qu&#8217;une vulnérabilité de <code>ping</code> peut devenir problèmatique, les <a href="http://ftp.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.4/capfaq-0.2.txt">Posix Capabilities</a> permettent d&#8217;affiner un peu plus les droits donnés à un programme.</p>
<p>Installons tout d&#8217;abord le paquet fournissant les outils nécessaires, sous Arch Linux:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">pacman -S libcap</pre></div></div>

<p>Faisons un essai:<br />
Copions l&#8217;exécutable (il perd son <code>setuid</code> lors de la copie):</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;">cp</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;">ping</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ping.x</pre></div></div>

<p>Un test échouera au vu du manque de permission:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ping.x <span style="color: #660033;">-c</span> <span style="color: #000000;">1</span> 127.0.0.1
<span style="color: #c20cb9; font-weight: bold;">ping</span>: icmp open socket: Operation not permitted</pre></div></div>

<p>Rajoutons à l&#8217;exécutable la capacité <code>CAP_NET_RAW</code> (en <code>root</code>)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> setcap <span style="color: #007800;">cap_net_raw</span>=ep <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ping.x</pre></div></div>

<p>Un autre essai:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ ping.x <span style="color: #660033;">-c</span> <span style="color: #000000;">1</span> 127.0.0.1
PING 127.0.0.1 <span style="color: #7a0874; font-weight: bold;">&#40;</span>127.0.0.1<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">56</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">84</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> bytes of data.
<span style="color: #000000;">64</span> bytes from 127.0.0.1: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">64</span> <span style="color: #007800;">time</span>=<span style="color: #000000;">0.064</span> ms
&nbsp;
<span style="color: #660033;">---</span> 127.0.0.1 <span style="color: #c20cb9; font-weight: bold;">ping</span> statistics <span style="color: #660033;">---</span>
<span style="color: #000000;">1</span> packets transmitted, <span style="color: #000000;">1</span> received, <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> packet loss, <span style="color: #000000; font-weight: bold;">time</span> 0ms
rtt min<span style="color: #000000; font-weight: bold;">/</span>avg<span style="color: #000000; font-weight: bold;">/</span>max<span style="color: #000000; font-weight: bold;">/</span>mdev = <span style="color: #000000;">0.064</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.064</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.064</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.000</span> ms</pre></div></div>

<p>Les capacités disponibles sont détaillées dans <code>man capabilities</code>.<br />
Les capacités peuvent être assignées à un processus et/ou un fichier (exécutable) en trois ensembles:</p>
<ul>
<li><strong>Permises (p)</strong>: Capacités pouvant être acquises </li>
<li><strong>Héritées (i)</strong>: Capacités léguées</li>
<li><strong>Effectives (e)</strong>: Capacités acquises</li>
</ul>
<p>En partant de ces trois ensembles, les capacités sont calculées pour chaque processus selon la logique suivante:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">'=capacités calculées
p=capacités du processus
f=capacités du fichier
I=héritées, P=permises, E=effectives
&nbsp;
pI' = pI
pP' = fP | (fI &amp; pI)
pE' = pP' &amp; fE</pre></div></div>

<p>Un processus ne peut utiliser une capacité que si elle existe dans l&#8217;ensemble permis et effectif (d&#8217;où le <code>"ep"</code> sur l&#8217;exemple du <code>ping.x</code>)</p>
<p>Imaginons qu&#8217;on veuille restreindre le <code>ping</code> à certains utilisateurs, on a besoin de la capacité <code>"cap_net_raw=ep"</code> mais seulement à l&#8217;exécution de <code>ping</code>. D&#8217;après la logique de calcul:</p>
<ul>
<li><code>ping.x</code> doit avoir <code>"cap_net_raw=ie"</code></li>
<li>Le processus appelant <code>ping.x</code> doit avoir <code>"cap_net_raw=i"</code></li>
</ul>
<p>Ainsi, <code>pP'</code> et <code>pE'</code> auront tous deux <code>cap_net_raw</code>.</p>
<p>Un test:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">$ sudo setcap -r /bin/ping.x
$ getcap -v /bin/ping.x
/bin/ping.x
$ sudo setcap cap_net_raw=ie /bin/ping.x
$ getpcaps $$
Capabilities for `6263': =
$ ping.x -c 1 127.0.0.1
ping: icmp open socket: Operation not permitted
$ sudo capsh --caps=&quot;cap_net_raw=i&quot; -- -c &quot;su - $USER&quot;
$ getpcaps $$
Capabilities for `6350': = cap_net_raw+i
$ ping.x -c 1 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.048 ms
&nbsp;
--- 127.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.048/0.048/0.048/0.000 ms
$</pre></div></div>

<p>Là, on a exécuté un shell en lui affectant une capacité (en utilisant le <code>root</code>), mais si on doit faire ceci à chaque fois, ça ne sert pas à grand chose&#8230; Ça tombe bien, c&#8217;était juste pour tester la faisabilité, voyons voir comment donner des permissions à un utilisateur.</p>
<p>Les capacités sont héritées par les processus fils, il suffit donc de doter le premier processus lancé par l&#8217;utilisateur des capactiés voulues, c&#8217;est là que rentre en action <a href="http://www.kernel.org/pub/linux/libs/pam/">PAM</a> [<a href="#ressource1_1">1</a>] le module d&#8217;authentification sous linux.</p>
<p>Le paquet <code>libcap</code> sous Arch Linux apporte un module nommé <code>pam_cap.so</code> permettant de configurer ceci. Dans <code>/etc/security/capability.conf</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">cap_net_raw	tuxce
none *</pre></div></div>

<p>Il faut aussi rajouter le module en question dans la configuration <code>pam</code>, <code>/etc/pam.d/login</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">auth		required	pam_cap.so</pre></div></div>

<p>On teste en se loguant depuis une console texte:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">host login: tuxce
Password: 
Last login: Tue Feb  9 14:08:55 CET 2010 on pts/2
[tuxce@host ~]$ getpcaps $$
Capabilities for `7601': = cap_net_raw+i
[tuxce@host ~]$ logout</pre></div></div>

<p>Une alternative à <code>pam_cap.so</code> serait d&#8217;utiliser un soft comparable à <code>sudo</code> mais spécifique aux capacités, ça tombe bien, un des développeurs d&#8217;Arch Linux, Thomas Bächler alias brain0 a developpé l&#8217;outil <a href="http://projects.archlinux.org/users/thomas/capsudo.git/">capsudo</a> qui permet en le configurant d&#8217;attribuer des droits à certains utilisateurs [<a href="#ressource1_2">2</a>].</p>
<p>Vous pouvez télécharger le PKGBUILD suivant: <a href='http://tuxce.no-ip.org/wp-content/uploads/2010/02/capsudo-git-20100209-1.src.tar.gz'>capsudo-git-20100209-1.src.tar.gz</a><br />
En prenant toujours l&#8217;exemple de <code>ping</code>, rajoutons ce qui suit à <code>/etc/capsudoers</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>ping.x<span style="">&#93;</span></span>
	<span style="color: #000099;">command</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> /bin/ping.x</span>
	<span style="color: #000099;">allow_user_args</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> true</span>
	<span style="color: #000099;">caps</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> cap_net_raw</span>
	<span style="color: #000099;">users</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> tuxce</span></pre></div></div>

<p>Assurons nous que <code>/bin/ping.x</code> ait <code>"cap_net_raw+ei"</code>, puis:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">$ capsudo ping.x -c 1 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.045 ms
&nbsp;
--- 127.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.045/0.045/0.045/0.000 ms</pre></div></div>

<p>Voilà, avec un mélange de tout ceci, on devrait être capable de donner des droits plus restreints aux exécutables sans pour autant leur permettre de prendre l&#8217;identité du <code>root</code>.</p>
<p>Reste la difficulté de deviner les capacités qu&#8217;il faut pour les programmes, deux possibilités, écumer le net pour trouver les capacités utilisées par tel ou tel programme, ou bien utiliser un module (nécéssitant certaines options du noyau) qui permet de logguer les demandes d&#8217;autorisations, ça fera l&#8217;objet d&#8217;un <a href="http://tuxce.no-ip.org/informatique/trouver-les-capacites-capabilities-dun-programme">autre article</a>, vous pouvez vous référer au <a href="http://wiki.archlinux.org/index.php/Using_File_Capabilities_Instead_Of_Setuid">wiki anglophone sur les capacités</a> pour une liste non exhaustive.</p>
<hr/>
<br/><br />
Ressources:<br />
<a id="ressource1_1" href="http://artisan.karma-lab.net/node/1690">Petite introduction à PAM</a> (Artisan Numérique)<br />
<a href="http://www.ibm.com/developerworks/aix/library/l-posixcap.html">POSIX file capabilities: Parceling the power of root</a><br />
<a href="http://ftp.kernel.org/pub/linux/libs/security/linux-privs/kernel-2.4/capfaq-0.2.txt">Linux kernel capabilities FAQ</a><br />
<a id="ressource1_2" href="http://archlinux.me/brain0/2010/01/05/using-posix-capabilities-in-linux-part-two/">Using POSIX capabilities in Linux, part two</a> (brain0)</p>
]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/posix-capabilities/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Archlinux, un live CD/USB non figé.</title>
		<link>http://tuxce.no-ip.org/informatique/archlinux-un-live-cdusb-non-fige</link>
		<comments>http://tuxce.no-ip.org/informatique/archlinux-un-live-cdusb-non-fige#comments</comments>
		<pubDate>Mon, 11 Jan 2010 17:24:03 +0000</pubDate>
		<dc:creator>tuxce</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Informatique]]></category>
		<category><![CDATA[archiso]]></category>
		<category><![CDATA[archlinux]]></category>
		<category><![CDATA[aufs]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[live]]></category>

		<guid isPermaLink="false">http://tuxce.selfip.org/?p=321</guid>
		<description><![CDATA[Il faut avoir lu le wiki pour créer un live d&#8217;Archlinux (ou savoir comment faire) pour suivre cet article. AUFS est un système de fichier permettant d&#8217;unifier plusieurs répertoires en un seul, c&#8217;est une réécriture d&#8217;unionfs 1.x Certains projets propres à Archlinux l&#8217;utilisent comme par exemple devtools (makechrootpkg qui permet de construire un paquet dans [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Il faut avoir lu le <a href="http://wiki.archlinux.fr/howto/live">wiki pour créer un live d&#8217;Archlinux</a> (ou savoir comment faire) pour suivre cet article</strong>.</p>
<p><a href="http://aufs.sourceforge.net/">AUFS</a> est un système de fichier permettant d&#8217;unifier plusieurs répertoires en un seul, c&#8217;est une réécriture d&#8217;<a href="http://www.filesystems.org/project-unionfs.html">unionfs</a> 1.x</p>
<p>Certains projets propres à Archlinux l&#8217;utilisent comme par exemple <a href="http://projects.archlinux.org/devtools.git/">devtools</a> (makechrootpkg qui permet de construire un paquet dans un chroot) ou encore <a href="http://projects.archlinux.org/archiso.git/">archiso</a> (<a href="http://wiki.archlinux.fr/howto/live">création d&#8217;un live</a>).</p>
<p>AUFS permet donc de fusionner plusieurs répertoires en un seul, la priorité étant donnée au premier dans la liste si deux fichiers portent le même nom; par défaut, le premier répertoire de la liste est en lecture/écriture et le reste est en lecture seule, tout ajout ou modification sont répercutés sur le premier répertoire.<br />
Voyons voir un exemple en prenant l&#8217;arborescence suivante:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># tree
.
|-- a
|   |-- fichier_1
|   `-- fichier_2
|-- b
|   |-- fichier_1
|   `-- fichier_3
|-- c
`-- result
&nbsp;
4 directories, 4 files
# more a/fichier_1 b/fichier_1 
::::::::::::::
a/fichier_1
::::::::::::::
1
::::::::::::::
b/fichier_1
::::::::::::::
2</pre></div></div>

<p>Montons <strong>a/</strong> et <strong>b/</strong> dans <strong>result/</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-t</span> aufs <span style="color: #660033;">-o</span> br:<span style="color: #007800;">a</span>=ro:b none result<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>On le monte en lecture seule, ça nous donne comme résultat:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># tree result
result
|-- fichier_1
|-- fichier_2
`-- fichier_3
&nbsp;
0 directories, 3 files
# cat result/fichier_1 
1</pre></div></div>

<p>Ainsi, on se retrouve avec l&#8217;ensemble des fichiers et comme <strong>fichier_1</strong> était en double, le premier répertoire (<strong>a/</strong>) a la priorité.</p>
<p>Maintenant, disons, qu&#8217;on veut modifier un élément, comme le répertoire est monté en lecture seule, on ne peut pas, il suffit pour y remédier de changer ou rajouter une branche en lecture/écriture:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;"># mount -t aufs -o remount,prepend:c none result/
# echo 4 &gt; result/fichier_1
# umount result/
# cat c/fichier_1 
4
# cat a/fichier_1 
1
# cat b/fichier_1 
2</pre></div></div>

<p>On a modifié le contenu de <strong>result/fichier_1</strong>, ce qui a laissé intact les fichiers du même nom sur <strong>a/</strong> et <strong>b/</strong> mais a créé un nouveau fichier dans la branche avec possibilité d&#8217;écriture : <strong>c/</strong>.</p>
<p>C&#8217;est exactement le même principe qui est appliqué au liveCD servant à l&#8217;installation d&#8217;Archlinux ou tout autre live construit avec <strong>archiso</strong> (en tout cas, jusqu&#8217;à cet instant), une partition <a href="http://wiki.archlinux.fr/howto/kernel/ramfs">tmpfs</a> est monté en premier, ainsi, on peut écrire, les différentes couches composant le live sont montées par la suite.</p>
<p>Au cas où, on peut avoir des informations sur un répertoire monté avec AUFS dans <strong>/sys/fs/aufs/si_X</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="non" style="font-family:monospace;"># mount -l -t aufs
none on /tmp/aufs_test/result type aufs (rw,relatime,si=f55ed40b26bb76b5)
# cat /sys/fs/aufs/si_f55ed40b26bb76b5/br*
/tmp/aufs_test/c=rw
/tmp/aufs_test/a=ro
/tmp/aufs_test/b=ro</pre></div></div>

<p>Partant de là et en supposant que vous avez lu le <a href="http://wiki.archlinux.fr/howto/live">wiki pour créer un live d&#8217;Archlinux</a>, créons un live qui ne sera pas figé et qu&#8217;on peut un minimum personnaliser.</p>
<p>Le principe est simple, il nous faut une partition indépendante qui fera office de couche lecture/écriture pour notre live, pour la détecter et l&#8217;utiliser, on va se baser sur la méthode de détection du support par le hook <strong>archiso</strong>, lors de la création du live, une étiquette est donnée à l&#8217;image <strong>iso</strong> créée et cette étiquette est fournie comme paramètre du noyau dans la configuration de <a href="http://syslinux.zytor.com/wiki/index.php/ISOLINUX">isolinux</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">append <span style="color: #007800;">initrd</span>=<span style="color: #000000; font-weight: bold;">/</span>boot<span style="color: #000000; font-weight: bold;">/</span>archiso.img  <span style="color: #007800;">lang</span>=fr <span style="color: #007800;">locale</span>=fr_FR.UTF-<span style="color: #000000;">8</span> <span style="color: #007800;">ramdisk_size</span>=<span style="color: #000000;">75</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #007800;">archisolabel</span>=ARCH_201001</pre></div></div>

<p>(par défaut, l&#8217;étiquette est ARCH_ + année + mois)</p>
<p>On choisit par exemple <strong>rootrw</strong> comme étiquette à donner à notre partition et le paramètre <strong>rootlabel</strong> pour le noyau.<br />
Prenons le cas le plus simple, une clé usb reconnue en tant que <strong>/dev/sdb</strong> dont on va utiliser la première partition préalablement créée:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mkfs.ext2 <span style="color: #660033;">-L</span> rootrw <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb1</pre></div></div>

<p>C&#8217;est censé être du live, ext2 est largement suffisant.</p>
<p>La détection et le montage de la racine se fait dans les hooks <strong>archiso-early</strong> et <strong>archiso</strong>, modifions un peu ces hooks pour détecter notre partition, le patch (par rapport à <a href="http://projects.archlinux.org/archiso.git/commit/?id=4071a39fd10c7e8ba95961682b1d993c5c050a0e">ce commit</a>): <a href="http://tuxce.no-ip.org/wp-content/uploads/2010/01/archiso_rootrw.patch">archiso_rootrw.patch</a><br />
Le patch peut sûrement être meilleur, mais là, en pleins dans les phases de tests, il fonctionne, c&#8217;est le principal.</p>
<p>Pour tester:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">wget http://tuxce.no-ip.org/wp-content/uploads/2010/01/archiso-git-20100111-1.src.tar.gz
tar zxvf archiso-git-20100111-1.src.tar.gz
cd archiso-git
makepkg --skipinteg -i</pre></div></div>

<p>Le PKGBUILD télécharge un snapshot d&#8217;archiso et ce dernier change le md5sum (une subtilité de cgit sûrement ou une histoire de timestamp, j&#8217;ai pas cherché), d&#8217;où le skipinteg.</p>
<p>Une fois cette version d&#8217;archiso installée, il nous faut modifier <strong>isolinux.cfg</strong>, recréer l&#8217;<strong>initrd</strong> et le <strong>.iso</strong>. En se basant sur le wiki, on rajoute les lignes suivantes à isolinux.cfg:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">label perso
kernel <span style="color: #000000; font-weight: bold;">/</span>boot<span style="color: #000000; font-weight: bold;">/</span>vmlinuz26
append <span style="color: #007800;">initrd</span>=<span style="color: #000000; font-weight: bold;">/</span>boot<span style="color: #000000; font-weight: bold;">/</span>archiso.img  <span style="color: #007800;">lang</span>=fr <span style="color: #007800;">locale</span>=fr_FR.UTF-<span style="color: #000000;">8</span> <span style="color: #007800;">ramdisk_size</span>=<span style="color: #000000;">75</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #007800;">archisolabel</span>=ARCH_201001 <span style="color: #007800;">rootlabel</span>=rootrw</pre></div></div>

<p>On refait l&#8217;étape <a href="http://wiki.archlinux.fr/howto/live#image_initrd">mkinitcpio</a> puis on recrée l&#8217;image:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">rm exemple.iso
mkarchiso iso traitement exemple.iso</pre></div></div>

<p>On s&#8217;assure que la clé usb est insérée et on lance un qemu en démarrant sur l&#8217;entrée <strong>perso</strong> pour tester:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">qemu-kvm -k fr -m 512 -hda exemple.iso -hdb /dev/sdb</pre></div></div>

<p>Il n&#8217;y a plus qu&#8217;à faire des modifications et redémarrer l&#8217;image.</p>
<p>En théorie, le test devrait être concluant (en tout cas chez moi <img src='http://tuxce.no-ip.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ), mais ce qui serait mieux, c&#8217;est d&#8217;avoir le live et la partition de modification sur le même périphérique, en supposant que votre clé usb est reconnue en tant que <strong>/dev/sdb</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">dd if=exemple.iso of=/dev/sdb
fdisk /dev/sdb &lt;&lt; EOF
n
p
2
&nbsp;
&nbsp;
p
w
EOF
mkfs.ext2 -L rootrw /dev/sdb2</pre></div></div>

<p>Ceci devrait être suffisant pour avoir un live pouvant être modifié.</p>
<p>Pour plus de détails n&#8217;hésitez pas à jeter un coup d&#8217;oeil aux scripts composant <strong>archiso</strong>, à <strong>mkarchroot</strong> (pour par exemple mettre à jour le live) ainsi qu&#8217;à <strong >man aufs</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://tuxce.no-ip.org/informatique/archlinux-un-live-cdusb-non-fige/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

