- API UsbBackend (liste, formatage FAT32, éjection) + implémentation UDisks2 via GDBus : disques USB amovibles uniquement (jamais HintSystem), table MBR + partition 0x0c à 1 Mio formatée vfat, montage, PowerOff ; autorisation déléguée à polkit (pas de root) - writeToUsb : vérification des archives AVANT effacement, formatage, licence dans license/, extraction fw puis carte, éjection - règles de l'app officielle : label assaini (11 car., majuscules, NEW), taille de clé minimale 2/4/8… Go avec marge de 10 % - CLI : usb-list, write-usb (confirmation YES), write-dir - tests : faux backend (ordre des étapes, archive corrompue => clé intacte), labels, tailles - tools/e2e-usb.sh : image loop via UDisks2 + contrôle sfdisk/fsck/mtools ; tools/dev-polkit.sh pour WSL/CI - validé de bout en bout avec le vrai firmware RCC 8,39 Go : MBR, FAT32, label, arborescence, fsck propre, en environ 20 s Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
#!/bin/sh
|
|
# DEVELOPMENT ONLY (WSL / test VM): lets the invoking user run UDisks2 operations
|
|
# (loop-setup, format, mount, power-off) without a polkit agent, so that the end-to-end
|
|
# USB tests can run headless. Never install this on a real desktop machine.
|
|
#
|
|
# usage: sudo tools/dev-polkit.sh install | remove
|
|
set -eu
|
|
|
|
RULE=/etc/polkit-1/rules.d/49-openpu-dev.rules
|
|
USER_NAME=${SUDO_USER:-}
|
|
|
|
case "${1:-}" in
|
|
install)
|
|
[ -n "$USER_NAME" ] || { echo "run with sudo from your user account" >&2; exit 1; }
|
|
cat > "$RULE" <<EOF
|
|
// Installed by openpu tools/dev-polkit.sh — remove with: sudo tools/dev-polkit.sh remove
|
|
polkit.addRule(function(action, subject) {
|
|
if (subject.user == "$USER_NAME" && action.id.indexOf("org.freedesktop.udisks2.") == 0)
|
|
return polkit.Result.YES;
|
|
});
|
|
EOF
|
|
chmod 644 "$RULE"
|
|
systemctl restart polkit 2>/dev/null || true
|
|
echo "installed $RULE for user $USER_NAME"
|
|
;;
|
|
remove)
|
|
rm -f "$RULE"
|
|
systemctl restart polkit 2>/dev/null || true
|
|
echo "removed $RULE"
|
|
;;
|
|
*)
|
|
echo "usage: sudo $0 install|remove" >&2
|
|
exit 2
|
|
;;
|
|
esac
|