From nobody Sat Feb 7 08:23:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1580217194752392.649379151492; Tue, 28 Jan 2020 05:13:14 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-340-Q5dvcCGoOTmzw6mBJdVoYA-1; Tue, 28 Jan 2020 08:13:11 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CDC318010C4; Tue, 28 Jan 2020 13:13:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2EAE60C85; Tue, 28 Jan 2020 13:13:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 59D0C18034FE; Tue, 28 Jan 2020 13:13:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00SDD474019388 for ; Tue, 28 Jan 2020 08:13:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0C5D81001DE0; Tue, 28 Jan 2020 13:13:04 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (unknown [10.33.8.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22D06100032E; Tue, 28 Jan 2020 13:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580217193; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bhA3xtQTGbutsXb94sxNN3ohQhw3IP0G8MphmMJde9c=; b=A2MkBCt5DEbwu27s13MSeQiYelO4Pab1IQabvc5zLEtyYUfGQnicXafAuXWgNvqBk7CW+f rxJIMMdSOvUQJuKmVn7b7pSD/hj1viB/MDDEyrHx305vJRAjaNUY3toO2th/QthiLvyDrO MKkYkD7vo7lOuC0CLXEdAIoOtLGU2ZE= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 25/56] src: conditionalize use of F_DUPFD_CLOEXEC Date: Tue, 28 Jan 2020 13:11:06 +0000 Message-Id: <20200128131137.1762449-26-berrange@redhat.com> In-Reply-To: <20200128131137.1762449-1-berrange@redhat.com> References: <20200128131137.1762449-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: Q5dvcCGoOTmzw6mBJdVoYA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The F_DUPFD_CLOEXEC functionality is not available on some platformms. We must thus explicitly call the virSetCloexec function once we remove GNULIB's equiv fix for this. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- src/rpc/virnetsocket.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index b25c57d01e..a286f0ce02 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -1397,15 +1397,27 @@ int virNetSocketDupFD(virNetSocketPtr sock, bool cl= oexec) { int fd; =20 +#ifdef F_DUPFD_CLOEXEC if (cloexec) fd =3D fcntl(sock->fd, F_DUPFD_CLOEXEC, 0); else +#endif /* F_DUPFD_CLOEXEC */ fd =3D dup(sock->fd); if (fd < 0) { virReportSystemError(errno, "%s", _("Unable to copy socket file handle")); return -1; } +#ifndef F_DUPFD_CLOEXEC + if (cloexec && + virSetCloseExec(fd < 0)) { + int saveerr =3D errno; + closesocket(fd); + errno =3D saveerr; + return -1; + } +#endif /* F_DUPFD_CLOEXEC */ + return fd; } =20 --=20 2.24.1