On Fri, Sep 21, 2018 at 11:29 AM +0200, Michal Privoznik <mprivozn(a)redhat.com>
wrote:
If there was a caller which would dup the client FD without
CLOEXEC flag and later decided to change the flag it wouldn't be
safe to do because fork() might have had occurred meantime.
Switch to the other pattern - always dup FD with the flag set and
let callers clear the flag if they need to do so.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
[…snip…]
-int virNetSocketDupFD(virNetSocketPtr sock, bool cloexec)
+int virNetSocketDupFD(virNetSocketPtr sock)
Might be useful to document this function.
{
int fd;
- if (cloexec)
- fd = fcntl(sock->fd, F_DUPFD_CLOEXEC, 0);
- else
- fd = dup(sock->fd);
+ fd = fcntl(sock->fd, F_DUPFD_CLOEXEC, 0);
if (fd < 0) {
virReportSystemError(errno, "%s",
_("Unable to copy socket file handle"));
diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h
index de795af917..e6bac27566 100644
--- a/src/rpc/virnetsocket.h
+++ b/src/rpc/virnetsocket.h
@@ -124,7 +124,7 @@ virNetSocketPtr virNetSocketNewPostExecRestart(virJSONValuePtr
object);
virJSONValuePtr virNetSocketPreExecRestart(virNetSocketPtr sock);
int virNetSocketGetFD(virNetSocketPtr sock);
-int virNetSocketDupFD(virNetSocketPtr sock, bool cloexec);
+int virNetSocketDupFD(virNetSocketPtr sock);
bool virNetSocketIsLocal(virNetSocketPtr sock);
--
2.16.4
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Anyway, Reviewed-by: Marc Hartmayer <mhartmay(a)linux.ibm.com>
--
Kind regards / Beste Grüße
Marc Hartmayer
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294