master hovercats/oakiss / pkg / bubblewrap / patch / 0004-Revert-Handle-EINTR-when-doing-I-O-on-files-or-socke.patch
  1From bbe8e2f75800633c251adbb34f7f9a1632a0d22a Mon Sep 17 00:00:00 2001
  2From: Michael Forney <mforney@mforney.org>
  3Date: Sun, 2 Feb 2025 01:34:54 -0800
  4Subject: [PATCH] Revert "Handle EINTR when doing I/O on files or sockets"
  5
  6This reverts commit 0c9646573f140d415cf790310ed17c2ab89f64a3.
  7---
  8 bind-mount.c |  2 +-
  9 bubblewrap.c | 26 +++++++++++++-------------
 10 network.c    |  6 +++---
 11 utils.c      | 16 ++++++++--------
 12 4 files changed, 25 insertions(+), 25 deletions(-)
 13
 14diff --git a/bind-mount.c b/bind-mount.c
 15index a2e1ac6..c1aa9ce 100644
 16--- a/bind-mount.c
 17+++ b/bind-mount.c
 18@@ -405,7 +405,7 @@ bind_mount (int           proc_fd,
 19   if (resolved_dest == NULL)
 20     return BIND_MOUNT_ERROR_REALPATH_DEST;
 21 
 22-  dest_fd = TEMP_FAILURE_RETRY (open (resolved_dest, O_PATH | O_CLOEXEC));
 23+  dest_fd = open (resolved_dest, O_PATH | O_CLOEXEC);
 24   if (dest_fd < 0)
 25     {
 26       if (failing_path != NULL)
 27diff --git a/bubblewrap.c b/bubblewrap.c
 28index bc53891..4848713 100644
 29--- a/bubblewrap.c
 30+++ b/bubblewrap.c
 31@@ -608,7 +608,7 @@ do_init (int event_fd, pid_t initial_pid)
 32 
 33   for (lock = lock_files; lock != NULL; lock = lock->next)
 34     {
 35-      int fd = TEMP_FAILURE_RETRY (open (lock->path, O_RDONLY | O_CLOEXEC));
 36+      int fd = open (lock->path, O_RDONLY | O_CLOEXEC);
 37       if (fd == -1)
 38         die_with_error ("Unable to open lock file %s", lock->path);
 39 
 40@@ -619,7 +619,7 @@ do_init (int event_fd, pid_t initial_pid)
 41         .l_len = 0
 42       };
 43 
 44-      if (TEMP_FAILURE_RETRY (fcntl (fd, F_SETLK, &l)) < 0)
 45+      if (fcntl (fd, F_SETLK, &l) < 0)
 46         die_with_error ("Unable to lock file %s", lock->path);
 47 
 48       /* Keep fd open to hang on to lock */
 49@@ -636,7 +636,7 @@ do_init (int event_fd, pid_t initial_pid)
 50       pid_t child;
 51       int status;
 52 
 53-      child = TEMP_FAILURE_RETRY (wait (&status));
 54+      child = wait (&status);
 55       if (child == initial_pid)
 56         {
 57           initial_exit_status = propagate_exit_status (status);
 58@@ -647,7 +647,7 @@ do_init (int event_fd, pid_t initial_pid)
 59               int res UNUSED;
 60 
 61               val = initial_exit_status + 1;
 62-              res = TEMP_FAILURE_RETRY (write (event_fd, &val, 8));
 63+              res = write (event_fd, &val, 8);
 64               /* Ignore res, if e.g. the parent died and closed event_fd
 65                  we don't want to error out here */
 66             }
 67@@ -1071,10 +1071,10 @@ privileged_op (int         privileged_op_socket,
 68       if (arg2 != NULL)
 69         strcpy ((char *) buffer + arg2_offset, arg2);
 70 
 71-      if (TEMP_FAILURE_RETRY (write (privileged_op_socket, buffer, buffer_size)) != (ssize_t)buffer_size)
 72+      if (write (privileged_op_socket, buffer, buffer_size) != (ssize_t)buffer_size)
 73         die ("Can't write to privileged_op_socket");
 74 
 75-      if (TEMP_FAILURE_RETRY (read (privileged_op_socket, buffer, 1)) != 1)
 76+      if (read (privileged_op_socket, buffer, 1) != 1)
 77         die ("Can't read from privileged_op_socket");
 78 
 79       return;
 80@@ -2824,7 +2824,7 @@ namespace_ids_read (pid_t  pid)
 81   NsInfo *info;
 82 
 83   dir = xasprintf ("%d/ns", pid);
 84-  ns_fd = TEMP_FAILURE_RETRY (openat (proc_fd, dir, O_PATH));
 85+  ns_fd = openat (proc_fd, dir, O_PATH);
 86 
 87   if (ns_fd < 0)
 88     die_with_error ("open /proc/%s/ns failed", dir);
 89@@ -3046,7 +3046,7 @@ main (int    argc,
 90 
 91   /* We need to read stuff from proc during the pivot_root dance, etc.
 92      Lets keep a fd to it open */
 93-  proc_fd = TEMP_FAILURE_RETRY (open ("/proc", O_PATH));
 94+  proc_fd = open ("/proc", O_PATH);
 95   if (proc_fd == -1)
 96     die_with_error ("Can't open /proc");
 97 
 98@@ -3213,7 +3213,7 @@ main (int    argc,
 99 
100       /* Let child run now that the uid maps are set up */
101       val = 1;
102-      res = TEMP_FAILURE_RETRY (write (child_wait_fd, &val, 8));
103+      res = write (child_wait_fd, &val, 8);
104       /* Ignore res, if e.g. the child died and closed child_wait_fd we don't want to error out here */
105       close (child_wait_fd);
106 
107@@ -3393,12 +3393,12 @@ main (int    argc,
108               op = read_priv_sec_op (unpriv_socket, buffer, sizeof (buffer),
109                                      &flags, &perms, &size_arg, &arg1, &arg2);
110               privileged_op (-1, op, flags, perms, size_arg, arg1, arg2);
111-              if (TEMP_FAILURE_RETRY (write (unpriv_socket, buffer, 1)) != 1)
112+              if (write (unpriv_socket, buffer, 1) != 1)
113                 die ("Can't write to op_socket");
114             }
115           while (op != PRIV_SEP_OP_DONE);
116 
117-          TEMP_FAILURE_RETRY (waitpid (child, &status, 0));
118+          waitpid (child, &status, 0);
119           /* Continue post setup */
120         }
121     }
122@@ -3422,7 +3422,7 @@ main (int    argc,
123    * We're aiming to make /newroot the real root, and get rid of /oldroot. To do
124    * that we need a temporary place to store it before we can unmount it.
125    */
126-  { cleanup_fd int oldrootfd = TEMP_FAILURE_RETRY (open ("/", O_DIRECTORY | O_RDONLY));
127+  { cleanup_fd int oldrootfd = open ("/", O_DIRECTORY | O_RDONLY);
128     if (oldrootfd < 0)
129       die_with_error ("can't open /");
130     if (chdir ("/newroot") != 0)
131@@ -3470,7 +3470,7 @@ main (int    argc,
132         {
133           cleanup_fd int sysctl_fd = -1;
134 
135-          sysctl_fd = TEMP_FAILURE_RETRY (openat (proc_fd, "sys/user/max_user_namespaces", O_WRONLY));
136+          sysctl_fd = openat (proc_fd, "sys/user/max_user_namespaces", O_WRONLY);
137 
138           if (sysctl_fd < 0)
139             die_with_error ("cannot open /proc/sys/user/max_user_namespaces");
140diff --git a/network.c b/network.c
141index 373d606..f6d58a6 100644
142--- a/network.c
143+++ b/network.c
144@@ -53,8 +53,8 @@ rtnl_send_request (int              rtnl_fd,
145   struct sockaddr_nl dst_addr = { AF_NETLINK, 0 };
146   ssize_t sent;
147 
148-  sent = TEMP_FAILURE_RETRY (sendto (rtnl_fd, (void *) header, header->nlmsg_len, 0,
149-                                     (struct sockaddr *) &dst_addr, sizeof (dst_addr)));
150+  sent = sendto (rtnl_fd, (void *) header, header->nlmsg_len, 0,
151+                 (struct sockaddr *) &dst_addr, sizeof (dst_addr));
152   if (sent < 0)
153     return -1;
154 
155@@ -71,7 +71,7 @@ rtnl_read_reply (int          rtnl_fd,
156 
157   while (1)
158     {
159-      received = TEMP_FAILURE_RETRY (recv (rtnl_fd, buffer, sizeof (buffer), 0));
160+      received = recv (rtnl_fd, buffer, sizeof (buffer), 0);
161       if (received < 0)
162         return -1;
163 
164diff --git a/utils.c b/utils.c
165index 8ab89bb..ffe0a0d 100644
166--- a/utils.c
167+++ b/utils.c
168@@ -378,7 +378,7 @@ fdwalk (int proc_fd, int (*cb)(void *data,
169   int res = 0;
170   DIR *d;
171 
172-  dfd = TEMP_FAILURE_RETRY (openat (proc_fd, "self/fd", O_DIRECTORY | O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOCTTY));
173+  dfd = openat (proc_fd, "self/fd", O_DIRECTORY | O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOCTTY);
174   if (dfd == -1)
175     return res;
176 
177@@ -460,7 +460,7 @@ write_file_at (int         dfd,
178   bool res;
179   int errsv;
180 
181-  fd = TEMP_FAILURE_RETRY (openat (dfd, path, O_RDWR | O_CLOEXEC, 0));
182+  fd = openat (dfd, path, O_RDWR | O_CLOEXEC, 0);
183   if (fd == -1)
184     return -1;
185 
186@@ -485,7 +485,7 @@ create_file (const char *path,
187   int res;
188   int errsv;
189 
190-  fd = TEMP_FAILURE_RETRY (creat (path, mode));
191+  fd = creat (path, mode);
192   if (fd == -1)
193     return -1;
194 
195@@ -566,11 +566,11 @@ copy_file (const char *src_path,
196   int res;
197   int errsv;
198 
199-  sfd = TEMP_FAILURE_RETRY (open (src_path, O_CLOEXEC | O_RDONLY));
200+  sfd = open (src_path, O_CLOEXEC | O_RDONLY);
201   if (sfd == -1)
202     return -1;
203 
204-  dfd = TEMP_FAILURE_RETRY (creat (dst_path, mode));
205+  dfd = creat (dst_path, mode);
206   if (dfd == -1)
207     {
208       errsv = errno;
209@@ -647,7 +647,7 @@ load_file_at (int         dfd,
210   char *data;
211   int errsv;
212 
213-  fd = TEMP_FAILURE_RETRY (openat (dfd, path, O_CLOEXEC | O_RDONLY));
214+  fd = openat (dfd, path, O_CLOEXEC | O_RDONLY);
215   if (fd == -1)
216     return NULL;
217 
218@@ -777,7 +777,7 @@ send_pid_on_socket (int sockfd)
219   cred.gid = getegid ();
220   memcpy (CMSG_DATA (cmsg), &cred, sizeof (cred));
221 
222-  if (TEMP_FAILURE_RETRY (sendmsg (sockfd, &msg, 0)) < 0)
223+  if (sendmsg (sockfd, &msg, 0) < 0)
224     die_with_error ("Can't send pid");
225 }
226 
227@@ -807,7 +807,7 @@ read_pid_from_socket (int sockfd)
228   msg.msg_control = control_buf_rcv;
229   msg.msg_controllen = sizeof (control_buf_rcv);
230 
231-  if (TEMP_FAILURE_RETRY (recvmsg (sockfd, &msg, 0)) < 0)
232+  if (recvmsg (sockfd, &msg, 0) < 0)
233     die_with_error ("Can't read pid from socket");
234 
235   if (msg.msg_controllen <= 0)
236-- 
2372.44.0
238