Depois de uma boa quantidade de puxões de cabelo, eu finalmente decidi usar curingas, no interesse de preservar minha sanidade, como sugerido por link .
Eu criei o arquivo %código%: com o conteúdo:
[udisks]
Identity=unix-group:plugdev
Action=org.freedesktop.udisks.*
ResultAny=yes
[udisks2]
Identity=unix-group:plugdev
Action=org.freedesktop.udisks2.*
ResultAny=yes
Com o script
#!/bin/bash
set -ex
udiskie-mount -o umask=0022 /dev/disk/by-uuid/4E1AEA7B1AEA6007 --verbose
udiskie-umount /dev/disk/by-uuid/4E1AEA7B1AEA6007 --verbose
Eu recebo a seguinte saída:
+ udiskie-mount -o umask=0022 /dev/disk/by-uuid/4E1AEA7B1AEA6007 --verbose
DEBUG [2016-04-21 15:29:01,634] udiskie.config: Failed to read config file: [Errno 2] No such file or directory: '/home/faheem/.config/udiskie/config.yml'
DEBUG [2016-04-21 15:29:01,637] udiskie.config: Failed to read config file: [Errno 2] No such file or directory: '/home/faheem/.config/udiskie/config.json'
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
DEBUG [2016-04-21 15:29:01,862] udiskie.config: IgnoreDevice(match={'is_block': False}, value=True) created
DEBUG [2016-04-21 15:29:01,862] udiskie.config: IgnoreDevice(match={'is_external': False}, value=True) created
DEBUG [2016-04-21 15:29:01,862] udiskie.config: IgnoreDevice(match={'is_ignored': True}, value=True) created
DEBUG [2016-04-21 15:29:01,866] udiskie.udisks2: found device owning "/dev/disk/by-uuid/4E1AEA7B1AEA6007": "/org/freedesktop/UDisks2/block_devices/sde1"
DEBUG [2016-04-21 15:29:01,866] udiskie.mount: mounting /org/freedesktop/UDisks2/block_devices/sde1 with {'fstype': 'ntfs', 'options': ['umask=0022']}
DEBUG [2016-04-21 15:29:03,354] udiskie.udisks2: +++ device_mounted: /org/freedesktop/UDisks2/block_devices/sde1
DEBUG [2016-04-21 15:29:03,354] udiskie.udisks2: +++ device_changed: /org/freedesktop/UDisks2/block_devices/sde1
INFO [2016-04-21 15:29:03,354] udiskie.mount: mounted /org/freedesktop/UDisks2/block_devices/sde1 on /media/faheem/My Passport
+ udiskie-umount /dev/disk/by-uuid/4E1AEA7B1AEA6007 --verbose
DEBUG [2016-04-21 15:29:03,490] udiskie.config: Failed to read config file: [Errno 2] No such file or directory: '/home/faheem/.config/udiskie/config.yml'
DEBUG [2016-04-21 15:29:03,492] udiskie.config: Failed to read config file: [Errno 2] No such file or directory: '/home/faheem/.config/udiskie/config.json'
DEBUG [2016-04-21 15:29:03,679] udiskie.config: IgnoreDevice(match={'is_block': False}, value=True) created
DEBUG [2016-04-21 15:29:03,679] udiskie.config: IgnoreDevice(match={'is_external': False}, value=True) created
DEBUG [2016-04-21 15:29:03,679] udiskie.config: IgnoreDevice(match={'is_ignored': True}, value=True) created
DEBUG [2016-04-21 15:29:03,681] udiskie.udisks2: found device owning "/dev/disk/by-uuid/4E1AEA7B1AEA6007": "/org/freedesktop/UDisks2/block_devices/sde1"
DEBUG [2016-04-21 15:29:03,681] udiskie.mount: unmounting /org/freedesktop/UDisks2/block_devices/sde1
DEBUG [2016-04-21 15:29:03,691] udiskie.udisks2: +++ device_changed: /org/freedesktop/UDisks2/block_devices/sde1
DEBUG [2016-04-21 15:29:03,712] udiskie.udisks2: +++ device_unmounted: /org/freedesktop/UDisks2/block_devices/sde1
INFO [2016-04-21 15:29:03,712] udiskie.mount: unmounted /org/freedesktop/UDisks2/block_devices/sde1
NOTAS E COMENTÁRIOS:
1) Policykit ou Polkit, seja o que for, é uma dor gigantesca.
2) A sintaxe usada após a versão 105 é Javascript - ninguém sabe por quê. A sintaxe usada para a versão 105 ou anterior é mostrada acima. A versão em Jessie é 105. Ver p. link e link
3) /etc/polkit-1/localauthority/50-local.d/10-udiskie.pkla
fornece uma lista de todas as ações registradas. Com o script acima, as ações pkaction
listadas são:
org.freedesktop.udisks2.ata-check-power
org.freedesktop.udisks2.ata-secure-erase
org.freedesktop.udisks2.ata-smart-enable-disable
org.freedesktop.udisks2.ata-smart-selftest
org.freedesktop.udisks2.ata-smart-simulate
org.freedesktop.udisks2.ata-smart-update
org.freedesktop.udisks2.ata-standby
org.freedesktop.udisks2.ata-standby-other-seat
org.freedesktop.udisks2.ata-standby-system
org.freedesktop.udisks2.cancel-job
org.freedesktop.udisks2.cancel-job-other-user
org.freedesktop.udisks2.eject-media
org.freedesktop.udisks2.eject-media-other-seat
org.freedesktop.udisks2.eject-media-system
org.freedesktop.udisks2.encrypted-change-passphrase
org.freedesktop.udisks2.encrypted-change-passphrase-system
org.freedesktop.udisks2.encrypted-lock-others
org.freedesktop.udisks2.encrypted-unlock
org.freedesktop.udisks2.encrypted-unlock-crypttab
org.freedesktop.udisks2.encrypted-unlock-other-seat
org.freedesktop.udisks2.encrypted-unlock-system
org.freedesktop.udisks2.filesystem-fstab
org.freedesktop.udisks2.filesystem-mount
org.freedesktop.udisks2.filesystem-mount-other-seat
org.freedesktop.udisks2.filesystem-mount-system
org.freedesktop.udisks2.filesystem-unmount-others
org.freedesktop.udisks2.loop-delete-others
org.freedesktop.udisks2.loop-modify-others
org.freedesktop.udisks2.loop-setup
org.freedesktop.udisks2.manage-md-raid
org.freedesktop.udisks2.manage-swapspace
org.freedesktop.udisks2.modify-device
org.freedesktop.udisks2.modify-device-other-seat
org.freedesktop.udisks2.modify-device-system
org.freedesktop.udisks2.modify-drive-settings
org.freedesktop.udisks2.modify-system-configuration
org.freedesktop.udisks2.open-device
org.freedesktop.udisks2.open-device-system
org.freedesktop.udisks2.power-off-drive
org.freedesktop.udisks2.power-off-drive-other-seat
org.freedesktop.udisks2.power-off-drive-system
org.freedesktop.udisks2.read-system-configuration-secrets
org.freedesktop.udisks2.rescan
Há também uma lista em ações do polkit Udisks .
Eu poderia me entreter tentando reduzir essa lista enquanto ainda permitia que o udiskie fosse montado e desmontado em um cron job. A questão é, isso vale a pena? E essas restrições realmente fornecem alguma segurança adicional?
4) Eu ainda estou recebendo o seguinte. Este é aparentemente um aviso - não parece estar impedindo qualquer coisa de trabalhar.
Unable to init server: Could not connect: Connection refused
ATUALIZAÇÃO: Depois de alguma discussão com Thomas G. (como ele disse, "Ótimo que funcionou. No entanto, pode não ser a melhor ideia para permitir cada ação do udisks. "), eu mudei para
[udisks2]
Identity=unix-user:faheem
Action=org.freedesktop.udisks2.filesystem-mount-other-seat;org.freedesktop.udisks2.filesystem-mount
ResultAny=yes
que ainda parece funcionar.
Followups: discussão de um possível patch para o pacote Debian udiskie .