From patchwork Tue Jan 12 13:14:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 8017041 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BE634BEEE5 for ; Tue, 12 Jan 2016 13:17:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 021FA203C1 for ; Tue, 12 Jan 2016 13:17:14 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37BF62038F for ; Tue, 12 Jan 2016 13:17:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aIymT-0005i4-87; Tue, 12 Jan 2016 13:14:37 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aIymR-0005hm-Mp for xen-devel@lists.xenproject.org; Tue, 12 Jan 2016 13:14:35 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 93/AF-03066-A3CF4965; Tue, 12 Jan 2016 13:14:34 +0000 X-Env-Sender: prvs=812c9b64b=roger.pau@citrix.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1452604472!14781965!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41024 invoked from network); 12 Jan 2016 13:14:34 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-11.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 12 Jan 2016 13:14:34 -0000 X-IronPort-AV: E=Sophos;i="5.20,557,1444694400"; d="scan'208";a="324422018" From: Roger Pau Monne To: Date: Tue, 12 Jan 2016 14:14:26 +0100 Message-ID: <1452604467-65746-2-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 1.9.5 (Apple Git-50.3) In-Reply-To: <1452604467-65746-1-git-send-email-roger.pau@citrix.com> References: <1452604467-65746-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Roger Pau Monne Subject: [Xen-devel] [PATCH 1/2] libxl: fix _SC_GETPW_R_SIZE_MAX usage X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to the FreeBSD sysconf man page [0] if the variable is associated with functionality that is not supported, -1 is returned and errno is not modified. Modify libxl__dm_runas_helper so it's able to correctly deal with this situation by setting the initial buffer value to 2048. [0] https://www.freebsd.org/cgi/man.cgi?query=sysconf Signed-off-by: Roger Pau Monné --- tools/libxl/libxl_dm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 0aaefd9..ec8fb51 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -728,7 +728,14 @@ static int libxl__dm_runas_helper(libxl__gc *gc, const char *username) long buf_size; int ret; + errno = 0; buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); + if (buf_size < 0 && errno == 0) { + buf_size = 2048; + LOG(DEBUG, +"sysconf(_SC_GETPW_R_SIZE_MAX) is not supported, using a buffer size of %ld", + buf_size); + } if (buf_size < 0) { LOGE(ERROR, "sysconf(_SC_GETPW_R_SIZE_MAX) returned error %ld", buf_size);