storaged-project / udisks

The UDisks project provides a daemon, tools and libraries to access and manipulate disks, storage devices and technologies.
https://storaged.org/doc/udisks2-api/latest/
Other
349 stars 142 forks source link

RFE: Add "idle" time information #63

Open mathstuf opened 8 years ago

mathstuf commented 8 years ago

I would like to be able to automatically lock my encrypted USB keys after a timeout of no activity on them. This is currently possible with automount for regular mounts using the --timeout option in /etc/auto.master, but does not work with the cryptsetup part of using encrypted disks.

See https://github.com/coldfix/udiskie/issues/83.

Original bug against udisks2

tsmetana commented 8 years ago

Do I understand it well that you want the removable LUKS encrypted volumes to get automatically unmounted and closed after some (configurable) "inactivity" time on the device?

mathstuf commented 8 years ago

More like I'd like the idle time exposed so that user applications can decide what to actually do. Since pinging for idle time would be less than ideal, something like:

org.freedesktop.UDisks2.RequestIdleSignal(in string device, in uint32 timeout_in_secs, out uint32 cookie)
org.freedesktop.UDisks2.DropIdleSignal(in uint32 cookie)

(not sure if there's a better way to drop the signal) with the corresponding signal:

org.freedesktop.UDisks2.DeviceIdle(string device, uint32 idle_time)

The autofs infrastructure has knowledge of how long a device has been idle and can auto-unmount after a time, but it doesn't do the LUKS part of the dance.

tsmetana commented 8 years ago

OK. Thanks for the explanation. I will keep the issue open and get back to it in the future hopefully (unless somebody sends a patch, of course). I'm sorry I can't promise anything more at the moment.

mathstuf commented 8 years ago

Ok, so there might be a way to just have storaged expose the information. Chasing things up from libcryptsetup, it looks like this code gets the information that is important (not necessarily a timeout, but whether the device has active mounts or not). This is just a thin wrapper around dm_status_device. Further down the rabbit hole, it looks like gudev might be able to get similar information, but I'm not sure. Thoughts?

tsmetana commented 8 years ago

@mathstuf: LUKS uses device mapper libraries to get the device status. It would require to dig deeper to find out if there is something generally useful in the DM code to solve the issue.