URL: https://linuxfr.org/users/freem/journaux/systemd-identifiant-unique-world-readable Title: systemd: identifiant unique, world-readable? Authors: freem Date: 2020年07月31日T08:25:31+02:00 License: CC By-SA Tags: debian et firefox Score: 27 Salut. En voulant connaître l'heure à laquelle j'ai lancé une commande sudo sur ma machine, je me suis aperçu qu'il me manquait un syslog. Bon, c'est juste une machine de bricolage, donc pas grave, je fais mon p'tit fichier `/etc/sv/syslogd/run` qui invoque `exec chpst -b syslogd busybox -t -n -O -`, je fais mon habituel symlink de `/etc/runit/log.run` vers `/etc/sv/syslogd/log/run`, je symlink le tout dans le dossier `service` qui va bien, et pour vérifier que tout roule, je me cale un p'tit `tail -f /var/log/syslogd/current`. Je balance une commande `sudo -i` pour voir si l'info se retrouve bien, c'est le cas. Nickel. Puis, comme je bricole pépère en discutant sur IRC, je lance mon navigateur web pour vérifier un truc, navigateur basé sur chrome. À ma surprise, un truc s'ajoute dans le syslog: ``` 2020年07月31日_05:29:12.42271 Jul 31 07:29:12 styx user.err chrome[3227]: [3227:3227:0731/072912.422613:ERROR:browser_dm_token_storage_linux.cc(100)] Error: /etc/machine-id contains 0 characters (32 were expected). ``` Huh? Mais qu'est-ce que? Pourquoi un navigateur web vient-il logguer la-dedans? Et surtout, qu'est-ce que c'est que ce fichier `/etc/machine-id` au juste? Lisons [la doc](https://www.man7.org/linux/man-pages/man5/machine-id.5.html)... ``` DESCRIPTION The /etc/machine-id file contains the unique machine ID of the local system that is set during installation or boot. The machine ID is a single newline-terminated, hexadecimal, 32-character, lowercase ID. When decoded from hexadecimal, this corresponds to a 16-byte/128-bit value. This ID may not be all zeros. The machine ID is usually generated from a random source during system installation or first boot and stays constant for all subsequent boots. Optionally, for stateless systems, it is generated during runtime during early boot if necessary. The machine ID may be set, for example when network booting, with the systemd.machine_id= kernel command line parameter or by passing the option --machine-id= to systemd. An ID specified in this manner has higher priority and will be used instead of the ID stored in /etc/machine-id. The machine ID does not change based on local or network configuration or when hardware is replaced. Due to this and its greater length, it is a more useful replacement for the gethostid(3) call that POSIX specifies. This machine ID adheres to the same format and logic as the D-Bus machine ID. This ID uniquely identifies the host. It should be considered "confidential", and must not be exposed in untrusted environments, in particular on the network. If a stable unique identifier that is tied to the machine is needed for some application, the machine ID or any part of it must not be used directly. Instead the machine ID should be hashed with a cryptographic, keyed hash function, using a fixed, application-specific key. That way the ID will be properly unique, and derived in a constant way from the machine ID but there will be no way to retrieve the original machine ID from the application-specific one. The sd_id128_get_machine_app_specific(3) API provides an implementation of such an algorithm. ``` Bon... Reprenons. Il s'agit donc d'un *identifiant unique*, qui est *nécessaire* pour que le système puisse... ben rien en fait, puisque ça fait quelques années que mon système marche très bien sans. Alors peut-être que *systemd* peut en avoir besoin, mais je me demande bien ce qu'il peut en faire, vraiment. Toujours est-il que cet identifiant unique, qui est censé être, je cite "confidential" est manifestement aussi en 0644, donc lisible par tout et n'importe quoi, ce qui inclue le navigateur... Je continue un peu la lecture de la manpage et lis ceci:> HISTORY The simple configuration file format of /etc/machine-id originates in the /var/lib/dbus/machine-id file introduced by D-Bus. In fact, this latter file might be a symlink to /etc/machine-id. Je vérifie sur mon système, je sais que dbus est lancé automatiquement par certaines applications, bien malgré moi vu qu'il ne me sert à rien d'autre qu'a satisfaire une dépendance de `dconf-service` (et tous les logiciels qui ont ce truc en dépendance marchent très bien quand je tue dbus pour info). En effet, il y a bien un p'tit cookie ici (pas pour longtemps certes). Un peu plus de recherche sur ce à quoi peuvent bien servir ces machins et je tombe sur [ceci](https://wiki.debian.org/MachineId):> What should be made clearer in the future> * what is the machine id actually used for? Je vois bien le genre d'usage qu'on peut faire d'un tel identifiant, après tout, je renseigne bien le hostname de mon système (citation du lien précédent: `Being opaque and non-human-meaningful is important for some of the places where it's useful, because if a string is human-meaningful (like a hostname), then people will sometimes want to change it` mouai...) mais je trouve les explications que j'ai trouvées "un peu" légères, et le seul usage qui semble en être fait sur mon système vient... d'un des logiciels qui est sur ma TODO-list de remplacement depuis des lustres: un navigateur web (proprio en plus, vivaldi. En même temps, c'est ma faute d'utiliser un freeware). Par acquit de conscience, j'ai testé vite fait avec firefox et le chromium (installé pour l'occasion) des dépôts debian officiels, et cet identifiant n'est pas utilisé, ou s'il l'est, ce n'est pas loggué dans syslogd. J'imagine qu'il faudrait que je creuse un peu plus, que j'installe un truc qui log les accès à ces deux fichiers pour que je sache quels logiciels, dans la pratique, les utilise réellement, et surtout *pourquoi*, mais je me suis dit qu'il serait plus facile dans un 1er temps d'aller troller ici au sujet de systemd (et dbus, mais ça attire moins).

AltStyle によって変換されたページ (->オリジナル) /