File: 0009-agent-Fix-sock_inotify_fd-handling.patch

package info (click to toggle)
gnupg2 2.4.7-21
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie, trixie-proposed-updates, trixie-updates
  • size: 50,644 kB
  • sloc: ansic: 287,552; sh: 7,938; lisp: 6,735; makefile: 1,982; awk: 160; xml: 53; python: 16; sed: 16; php: 14; perl: 13
file content (41 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Mon, 4 Sep 2023 10:34:42 +0900
Subject: [PATCH 9/9] agent: Fix sock_inotify_fd handling.

* agent/gpg-agent.c (handle_connections): Also check SOCK_INOTIFY_FD
when spawning check_onw_socket_thread.  When removal of the socket
is detected, do same as AGENT_PROBLEM_SOCKET_TAKEOVER.

--

GnuPG-bug-id: 6692
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
---
 agent/gpg-agent.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 7e4e892..22db257 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -3071,7 +3071,7 @@ handle_connections (gnupg_fd_t listen_fd,
     have_homedir_inotify = 1;
 
 #if CHECK_OWN_SOCKET_INTERVAL > 0
-  if (!disable_check_own_socket)
+  if (!disable_check_own_socket && sock_inotify_fd == -1)
     {
       npth_t thread;
 
@@ -3271,7 +3271,10 @@ handle_connections (gnupg_fd_t listen_fd,
           && FD_ISSET (sock_inotify_fd, &read_fdset)
           && gnupg_inotify_has_name (sock_inotify_fd, GPG_AGENT_SOCK_NAME))
         {
-          shutdown_pending = 1;
+          /* We may not remove the socket (if any), as it may be now
+             in use by another server.  */
+          inhibit_socket_removal = 1;
+          shutdown_pending = 2;
           close (sock_inotify_fd);
           sock_inotify_fd = -1;
           log_info ("socket file has been removed - shutting down\n");