[fdo] Detect my own session being closed

Rastersoft rastersoft at gmail.com
Wed Feb 5 16:55:14 UTC 2020


Hello:

I created a backup program that uses an external HD to do the backups, and
it is designed to allow several users to share the same hard disk by
storing each backup in a different folder. To ensure that the backups are
always made, it automatically mounts the backup hard disk when it detects
it (using udisk2 DBus interface). The first problem is that if the backup
program of the user A mounts the disk, only user A can access it. The
second problem is that, if user closes its session as user A and opens a
new session as user B, the external hard disk is still mounted as the user
A, so the backup program of user B can't access it unless user B manually
unmounts it.

My questions are:

- Is it possible to mount an external hard disk, using udisk2, making it
accessible for all the users?
- If not, is it possible to mark a mounted partition as "umount on session
close"?
- If not, is it possible to detect when my session is being closed, to make
the backup program to umount the partition, thus allowing other users to
use it?

About this last question: I already tried to connect to the SessionRemoved
signal from logind, but with no luck: I receive the signal when other users
close their session, but my program is killed before it can process the
signal. Also I tried to use onexit(), atexit(), and GApplication's close
signals, but also with no luck: the code isn't  called (I'm using GTK, and
the program always dies with a 'broken pipe' message when the session is
closed).

Thanks in advance.

-- 
Nos leemos
                 RASTER    (Linux user #228804)
raster at rastersoft.com              http://www.rastersoft.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/freedesktop/attachments/20200205/c8a073b8/attachment.htm>


More information about the freedesktop mailing list