Re: [PATCH v2 8/8] rpc: pass listen FD to the daemon being started

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 16, 2014 at 08:30:02PM +0200, Martin Kletzander wrote:
This eliminates the need for active waiting.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=927369

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
src/rpc/virnetsocket.c | 58 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 39 insertions(+), 19 deletions(-)

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index a94b2bc..c00209c 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
[...]
@@ -569,28 +572,45 @@ int virNetSocketNewConnectUNIX(const char *path,
[...]
+        /*
+         * We cannot do the umask() trick here because that's not
+         * thread-safe.  fchmod(), however, is not guaranteed to work on
+         * some BSD favours, but *should* work on Linux before the socket
+         * is bound.  POSIX says the behaviour of fchmod() called on
+         * socket is unspecified, though.
+         */
+        if (fchmod(passfd, 0700) < 0) {
+            virReportSystemError(errno, "%s",
+                                 _("Failed to change permissions on socket"));
+            goto error;
        }


I've finally found a way out of this.  We can fork() and in the child
do only umask() and bind().  It shouldn't be a problem that fstat()
returns different mode for the socket than stat(), it should work
everywhere and thanks to the fact that we do this pretty rarely and
copy-on-write pages there shouldn't be significant impact.

Is this acceptable?

Martin

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]