public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/4] hurd: Don't pass fd flags in CMSG_DATA
@ 2023-04-17 13:38 Sergey Bugaev
  2023-04-17 13:39 ` [PATCH 2/4] hurd: Implement MSG_CMSG_CLOEXEC Sergey Bugaev
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Sergey Bugaev @ 2023-04-17 13:38 UTC (permalink / raw)
  To: libc-alpha, bug-hurd
  Cc: Samuel Thibault, Emilio Pozuelo Monfort, Sergey Bugaev

The only valid flag defined here is FD_CLOEXEC. It is of no concern to
the receiving process whether or not the sender process wants to close
its copy of sent file descriptor upon exec, and it should not influence
whether or not the received file descriptor gets the FD_CLOEXEC flag
set in the receiving process.

The latter should in fact be dependent on the MSG_CMSG_CLOEXEC flag
being passed to the recvmsg () call, which is going to be implemented
in the following commit.

Fixes 344e755248ce02c0f8d095d11cc49e340703d926
"hurd: Support sending file descriptors over Unix sockets"

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 sysdeps/mach/hurd/recvmsg.c | 3 +--
 sysdeps/mach/hurd/sendmsg.c | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/sysdeps/mach/hurd/recvmsg.c b/sysdeps/mach/hurd/recvmsg.c
index 39de86f6..5e8b18c6 100644
--- a/sysdeps/mach/hurd/recvmsg.c
+++ b/sysdeps/mach/hurd/recvmsg.c
@@ -189,7 +189,6 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags)
     if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
       {
 	/* SCM_RIGHTS support.  */
-	/* The fd's flags are passed in the control data.  */
 	int *fds = (int *) CMSG_DATA (cmsg);
 	nfds = (cmsg->cmsg_len - CMSG_ALIGN (sizeof (struct cmsghdr)))
 	       / sizeof (int);
@@ -200,7 +199,7 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags)
 	    if (err)
 	      goto cleanup;
 	    fds[j] = opened_fds[newfds] = _hurd_intern_fd (newports[newfds],
-							   fds[j], 0);
+							   0, 0);
 	    if (fds[j] == -1)
 	      {
 		err = errno;
diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c
index 5871d1d8..77a720fb 100644
--- a/sysdeps/mach/hurd/sendmsg.c
+++ b/sysdeps/mach/hurd/sendmsg.c
@@ -138,8 +138,8 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
 					     0, 0, 0, 0);
 		   if (! err)
 		     nports++;
-		   /* We pass the flags in the control data.  */
-		   fds[i] = descriptor->flags;
+		   /* We just pass 0 in the control data.  */
+		   fds[i] = 0;
 		   err;
 		 }));
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-04-21  0:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-17 13:38 [PATCH 1/4] hurd: Don't pass fd flags in CMSG_DATA Sergey Bugaev
2023-04-17 13:39 ` [PATCH 2/4] hurd: Implement MSG_CMSG_CLOEXEC Sergey Bugaev
2023-04-17 13:39 ` [PATCH 3/4] hurd: Only deallocate addrport when it's valid Sergey Bugaev
2023-04-17 13:39 ` [RFC PATCH 4/4] socket: Add a test for MSG_CMSG_CLOEXEC Sergey Bugaev
2023-04-17 22:14   ` [RFC PATCH v2 " Sergey Bugaev
2023-04-18 12:13   ` [RFC PATCH " Adhemerval Zanella Netto
2023-04-18 15:37     ` Sergey Bugaev
2023-04-18 16:50       ` Adhemerval Zanella Netto
2023-04-20 21:14 ` [PATCH 1/4] hurd: Don't pass fd flags in CMSG_DATA Samuel Thibault
2023-04-20 21:47   ` Sergey Bugaev
2023-04-21  0:56     ` Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).