From patchwork Thu Oct 11 20:41:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Babioch X-Patchwork-Id: 982714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=babioch.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MMIOvzV3"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=babioch.de header.i=@babioch.de header.b="L2eKiLdb"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42WNFs629Pz9s7h for ; Fri, 12 Oct 2018 07:42:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xBzQm2pacVzkQYDl1oLQnQw99OnuBuXXFTFY3RXRKi0=; b=MMIOvzV3/7LtyQ KhQRupa0ZbYJR+eHZh5J0lI2QTTDc8aEJzSJ+7HoKnl9opXFFntRGF9s+8yy5y7WyXpJ7URxk28Em VM8JJ7jEqq8U5FybM2U4yWB9Hr2xrHR/Mr1VIdywG1Z+xwjfOpMgTia4ekFEqTY9IqpC2rWbSiB81 b5tq12I81t2bq8DaCIEnqYlB0XchOUIhWMNHH4mq1ZpPM2TlRoGaTk+tZQJNk4Wgrx7QDUXOYvayp MFsLzMCdFZcMAgsm8D3R8Kh6dklQxyxUfA8keRQcW7XFliA3ch3A6WNo9fmX9wzhjObaeW8Nmkz0n XARc5DLjAtgRwlMcs1Mw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gAhn7-0005Zr-B1; Thu, 11 Oct 2018 20:42:41 +0000 Received: from mail.babioch.de ([144.76.131.5]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gAhn4-0005Yo-IH for hostap@lists.infradead.org; Thu, 11 Oct 2018 20:42:40 +0000 From: Karol Babioch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=babioch.de; s=20170501; t=1539290517; bh=eoyWD5MwVecvTJVjc8SCHy3S2MCm/3squk7VJIefQXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=L2eKiLdbph8IgkCUvd7UbfF7TskC36JTsTwfwkfb3CXBo2zPhCjUQCwy8iZYRGK5l KGN7DmWZj9mIw9w7jAmW+fXSAnyshp3TflXsmRylb+6PIw7EHfhkZbGkZtzTUUCWJr osGO8RufV39Zh6XREotnUjhTgU6YAg6Q1oSpf9zo1sTrSdeya0w9sJJH0hpCj7twpY fvia47TIIVbSR5sccls2aHxCpZbCAVhugMaACr22JyLuNUEB/j7VLPs7D9Mz9VYeB3 kqdYlZmFz4mSO5343oZeP4hXATgpeZZayQv5aW1RvmZUt79YxNdZauWZONL2Hw947r NTssKKyLTkgRg== To: hostap@lists.infradead.org Subject: [PATCH v2 2/2] Enable the close-on-exec flag for the debug log file descriptor Date: Thu, 11 Oct 2018 22:41:35 +0200 Message-Id: <20181011204135.30058-1-karol@babioch.de> In-Reply-To: <20181011202010.29226-2-karol@babioch.de> References: <20181011202010.29226-2-karol@babioch.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181011_134238_754764_04BC00A5 X-CRM114-Status: UNSURE ( 8.11 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [144.76.131.5 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Karol Babioch Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On Linux this flag will make sure that no file descriptor is accidentally leaked into potential child processes. While this is not a problem right now, it is considered to be good practice these days when dealing with file descriptors on the Linux. Signed-off-by: Karol Babioch --- src/utils/wpa_debug.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c index b412f88e3..9d159632d 100644 --- a/src/utils/wpa_debug.c +++ b/src/utils/wpa_debug.c @@ -60,6 +60,9 @@ static int wpa_to_android_level(int level) #ifdef CONFIG_DEBUG_FILE #include #include +#ifdef __linux__ +#include +#endif /* __linux__ */ static int out_fd = -1; static FILE *out_file = NULL; @@ -567,6 +570,14 @@ int wpa_debug_open_file(const char *path) return -1; } +#ifdef __linux__ + if (fcntl(out_fd, F_SETFD, FD_CLOEXEC) == -1) { + wpa_printf(MSG_ERROR, "wpa_debug_open_file: Failed to set O_CLOEXEC " + "on output file descriptor, using standard output"); + close(out_fd); + return -1; + } +#endif /* __linux__ */ #ifndef _WIN32 setvbuf(out_file, NULL, _IOLBF, 0); #endif /* _WIN32 */