From patchwork Tue Jan 8 21:26:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 210541 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ED4642C009A for ; Wed, 9 Jan 2013 08:26:38 +1100 (EST) Received: from localhost ([::1]:56721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tsggv-0006JX-3C for incoming@patchwork.ozlabs.org; Tue, 08 Jan 2013 16:26:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tsggk-0006IS-Rz for qemu-devel@nongnu.org; Tue, 08 Jan 2013 16:26:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tsggj-00055h-Q3 for qemu-devel@nongnu.org; Tue, 08 Jan 2013 16:26:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:65446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tsggj-00055d-IT for qemu-devel@nongnu.org; Tue, 08 Jan 2013 16:26:25 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r08LQNLT022363 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 8 Jan 2013 16:26:23 -0500 Received: from localhost (ovpn-113-104.phx2.redhat.com [10.3.113.104]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r08LQLVZ018238; Tue, 8 Jan 2013 16:26:22 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 8 Jan 2013 19:26:25 -0200 Message-Id: <1357680386-10904-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1357680386-10904-1-git-send-email-lcapitulino@redhat.com> References: <1357680386-10904-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 1/2] qemu-ga: ga_open_pidfile(): use qemu_open() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This ensures that O_CLOEXEC is passed to open(), this way the pid file fd is not leaked to executed processes. Signed-off-by: Luiz Capitulino Reviewed-by: Eric Blake --- qga/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/main.c b/qga/main.c index ba5fa1c..e4245cc 100644 --- a/qga/main.c +++ b/qga/main.c @@ -242,7 +242,7 @@ static bool ga_open_pidfile(const char *pidfile) int pidfd; char pidstr[32]; - pidfd = open(pidfile, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR); + pidfd = qemu_open(pidfile, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR); if (pidfd == -1 || lockf(pidfd, F_TLOCK, 0)) { g_critical("Cannot lock pid file, %s", strerror(errno)); if (pidfd != -1) {