diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2023-12-26 03:47:09 +0100 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2023-12-26 05:29:40 +0100 |
commit | c44f0bc91e7c16ab46a6fba4626ef906d87b04b8 (patch) | |
tree | bed0042aee6bb2897787bbb6e29ed76a0a3ac34a /kbx | |
parent | Merge branch 'STABLE-BRANCH-2-4' (diff) | |
download | gnupg2-c44f0bc91e7c16ab46a6fba4626ef906d87b04b8.tar.xz gnupg2-c44f0bc91e7c16ab46a6fba4626ef906d87b04b8.zip |
agent,kbx: Fix reliable_homedir_inotify (1/2).
* agent/gpg-agent.c (reliable_homedir_inotify): Remove the global.
(handle_connections): Add reliable_homedir_inotify as an arg.
Don't call gnupg_inotify_watch_delete_self when it's not reliable.
(check_others_thread): No check of reliable_homedir_inotify repeatedly
in the loop.
* kbx/keyboxd.c (reliable_homedir_inotify): Remove the global.
(handle_connections): Add reliable_homedir_inotify as an arg.
(handle_tick): No check of reliable_homedir_inotify in the loop.
--
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'kbx')
-rw-r--r-- | kbx/keyboxd.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/kbx/keyboxd.c b/kbx/keyboxd.c index f9792789d..1ba2fd0b5 100644 --- a/kbx/keyboxd.c +++ b/kbx/keyboxd.c @@ -204,11 +204,6 @@ static char *current_logfile; * alternative but portable stat based check. */ static int have_homedir_inotify; -/* Depending on how keyboxd was started, the homedir inotify watch may - * not be reliable. This flag is set if we assume that inotify works - * reliable. */ -static int reliable_homedir_inotify; - /* Number of active connections. */ static int active_connections; @@ -254,7 +249,8 @@ static void kbxd_libgcrypt_progress_cb (void *data, const char *what, static void kbxd_init_default_ctrl (ctrl_t ctrl); static void kbxd_deinit_default_ctrl (ctrl_t ctrl); -static void handle_connections (gnupg_fd_t listen_fd); +static void handle_connections (gnupg_fd_t listen_fd, + int reliable_homedir_inotify); static void check_own_socket (void); static int check_for_running_kbxd (int silent); @@ -464,6 +460,8 @@ main (int argc, char **argv ) int gpgconf_list = 0; int debug_wait = 0; struct assuan_malloc_hooks malloc_hooks; + int reliable_homedir_inotify = 0; + early_system_init (); @@ -846,7 +844,7 @@ main (int argc, char **argv ) } log_info ("%s %s started\n", gpgrt_strusage(11), gpgrt_strusage(13)); - handle_connections (fd); + handle_connections (fd, reliable_homedir_inotify); assuan_sock_close (fd); } @@ -1300,7 +1298,7 @@ handle_tick (void) /* Check whether the homedir is still available. */ if (!shutdown_pending - && (!have_homedir_inotify || !reliable_homedir_inotify) + && !have_homedir_inotify && gnupg_stat (gnupg_homedir (), &statbuf) && errno == ENOENT) { shutdown_pending = 1; @@ -1448,7 +1446,7 @@ start_connection_thread (void *arg) /* Connection handler loop. Wait for connection requests and spawn a * thread after accepting a connection. */ static void -handle_connections (gnupg_fd_t listen_fd) +handle_connections (gnupg_fd_t listen_fd, int reliable_homedir_inotify) { gpg_error_t err; npth_attr_t tattr; @@ -1503,7 +1501,7 @@ handle_connections (gnupg_fd_t listen_fd) gpg_strerror (err)); } - if (disable_check_own_socket) + if (!reliable_homedir_inotify) home_inotify_fd = -1; else if ((err = gnupg_inotify_watch_delete_self (&home_inotify_fd, gnupg_homedir ()))) |