mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
agent: Shutdown on removal of the home directory.
* common/sysutils.c (gnupg_inotify_watch_delete_self): New. * agent/gpg-agent.c (handle_connections): Rename my_inotify_fd to sock_inotify_fd. (handle_connections): Add home_inotify_fd to watch the home directory. -- GnuPG-bug-id: 3218 Note that we should add this also to dirmngr. And for non-Linux systems a stat in ticker should be implemented. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
815ecdf08a
commit
1ead1ca818
3 changed files with 86 additions and 16 deletions
|
@ -1125,6 +1125,43 @@ w32_get_user_sid (void)
|
|||
|
||||
/* Support for inotify under Linux. */
|
||||
|
||||
/* Store a new inotify file handle for FNAME at R_FD or return an
|
||||
* error code. This file descriptor watch the removal of FNAME. */
|
||||
gpg_error_t
|
||||
gnupg_inotify_watch_delete_self (int *r_fd, const char *fname)
|
||||
{
|
||||
#if HAVE_INOTIFY_INIT
|
||||
gpg_error_t err;
|
||||
int fd;
|
||||
|
||||
*r_fd = -1;
|
||||
|
||||
if (!fname)
|
||||
return my_error (GPG_ERR_INV_VALUE);
|
||||
|
||||
fd = inotify_init ();
|
||||
if (fd == -1)
|
||||
return my_error_from_syserror ();
|
||||
|
||||
if (inotify_add_watch (fd, fname, IN_DELETE_SELF) == -1)
|
||||
{
|
||||
err = my_error_from_syserror ();
|
||||
close (fd);
|
||||
return err;
|
||||
}
|
||||
|
||||
*r_fd = fd;
|
||||
return 0;
|
||||
#else /*!HAVE_INOTIFY_INIT*/
|
||||
|
||||
(void)fname;
|
||||
*r_fd = -1;
|
||||
return my_error (GPG_ERR_NOT_SUPPORTED);
|
||||
|
||||
#endif /*!HAVE_INOTIFY_INIT*/
|
||||
}
|
||||
|
||||
|
||||
/* Store a new inotify file handle for SOCKET_NAME at R_FD or return
|
||||
* an error code. */
|
||||
gpg_error_t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue