Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1189492ybg; Fri, 18 Oct 2019 13:30:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0evfbuqX/bYxiax+u9s8L5DMBJLL1p7WDHu8NOG5ha15Ki6X0BdzqsrPbtB+I4smGsyTt X-Received: by 2002:a17:906:5381:: with SMTP id g1mr10583852ejo.159.1571430601303; Fri, 18 Oct 2019 13:30:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571430601; cv=none; d=google.com; s=arc-20160816; b=ArLHk68QlUl/mtPsBmPPFy3zd6lwNFVX/bS87bYoa+FntJ8W6cp2m6t3ZPnQk0/fRC qE2vblZtQUqZHfe+ZqPo383eqKhBayOTLf8CgmxPWRcfLnGQ558J562UTeUcL2zEeDyJ TpAcuKXMk70Dtxdht2HYbwuTu1xKQpoqV0eC/UxoqfjvBDP2nbmP3fKAv7XndLUL6iny FRxommXKtl2Cf4+fO4/ko60Kw5YSEeSM7gMuLHEQ4PtOjsmB/S1U7e3NkYFcaOIAGUag yAbP2HnyYSLs7CAIDlU5hWxUn/AbX5jrP8l56ZxOIGJj7K4FxLwS65rsG3p+Bq9zjESO HLow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=aZPsg2BHAO3IhHvwMQbcHBNc6u75dgyTnfEJunkVJyk=; b=VeU7lEKh2s55szP9PtXOu+IiXBDng44gDLivQ+9TECX+ZHeR07mOrkcksZVKiahjim It5xbBXWpTSB3noajMBR6P9SldhNA3vuTMEdrtdFImyQIuIcsL7e/Pg316Q1/F4rCkzO iqxgMnYuePxvC751aCsbUjQuDDWcQnssgJwbvt5kqT930kIHGEgqVl7QJaIy619iB7tc MGgRcSUDRKvi/v6b4KsQEWdZcEPbtQ8ZCoFwb79zqGwCG7xewjDgqVFYqnk/xE0hndP0 f5hnH/qRlt0OxDtHtBTCfNVUlvlhRK+EMqweP8N7IBvnAXryLHomVN05V3Q5uK6zh/Sz mIhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4si4454833edm.183.2019.10.18.13.29.35; Fri, 18 Oct 2019 13:30:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440392AbfJQPIo (ORCPT + 99 others); Thu, 17 Oct 2019 11:08:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45278 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440394AbfJQPIo (ORCPT ); Thu, 17 Oct 2019 11:08:44 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82E8330860DA for ; Thu, 17 Oct 2019 15:08:44 +0000 (UTC) Received: from coeurl.usersys.redhat.com (ovpn-120-158.rdu2.redhat.com [10.10.120.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6833719C77; Thu, 17 Oct 2019 15:08:44 +0000 (UTC) Received: by coeurl.usersys.redhat.com (Postfix, from userid 1000) id 186D920836; Thu, 17 Oct 2019 11:08:44 -0400 (EDT) From: Scott Mayhew To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [nfs-utils PATCH v3] gssd: daemonize earlier Date: Thu, 17 Oct 2019 11:08:44 -0400 Message-Id: <20191017150844.21045-1-smayhew@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 17 Oct 2019 15:08:44 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org daemon_init() calls closeall() which closes all fd's >= 4. This causes rpc.gssd to fail when it's configured to use the gssproxy interposer plugin (via "use-gss-proxy=1" in nfs.conf or GSS_USE_PROXY="yes" in the environment) *and* libtirpc debugging is enabled (i.e. at least one "-r" on the command line): 1. During startup if rpc debugging is enabled then libtirpc_set_debug() is called, which calls openlog() which consumes fd 3. 2. If the gssproxy interposer plugin is enabled then when gssd_check_mechs() is called, a socket is created (fd 4) and connected to /var/lib/gssproxy/default.sock. The fd is stored internally in a struct gpm_ctx. 3. daemon_init() runs and closes all fd's >= 4. 4. event_init() runs which calls epoll_create() which returns an epoll fd of 4. 5. Later when handling an upcall, gssd calls gssd_acquire_krb5_cred() which winds up closing the gpm_ctx->fd which was 4. 6. event_dispatch() calls epoll_wait() with epfd=4, and -EBADF is returned. gssd logs the message ""ERROR: event_dispatch() returned!" and exits. The solution is to call daemon_init() earlier. Signed-off-by: Scott Mayhew --- utils/gssd/gssd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c index 19ad4da..c38dedb 100644 --- a/utils/gssd/gssd.c +++ b/utils/gssd/gssd.c @@ -1020,11 +1020,11 @@ main(int argc, char *argv[]) "support setting debug levels\n"); #endif + daemon_init(fg); + if (gssd_check_mechs() != 0) errx(1, "Problem with gssapi library"); - daemon_init(fg); - event_init(); pipefs_dir = opendir(pipefs_path); -- 2.17.2