From patchwork Fri Nov 15 19:15:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 3189521 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4B2449F432 for ; Fri, 15 Nov 2013 19:15:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6ED8E20967 for ; Fri, 15 Nov 2013 19:15:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 703BF2095C for ; Fri, 15 Nov 2013 19:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751723Ab3KOTPl (ORCPT ); Fri, 15 Nov 2013 14:15:41 -0500 Received: from mail-qe0-f45.google.com ([209.85.128.45]:43670 "EHLO mail-qe0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753244Ab3KOTPj (ORCPT ); Fri, 15 Nov 2013 14:15:39 -0500 Received: by mail-qe0-f45.google.com with SMTP id 9so1461125qea.18 for ; Fri, 15 Nov 2013 11:15:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5hYzfdeHOjt61rYFfaLDT7b0V0T8zytF/ZtuyfGtpvU=; b=Au+cTc5LesHx+nlYeN+SJyYUBrJZ8hT8oeB0Oi5Az9tNTseaGZIQ4yqDRUj7fQh311 KdCmaCa5qvk+g7RcsEHyYgNb4YzUjza9aWd3G3BsPwu6hawEk6d3eWPVMUtV84z98hkR pOVy0++eh7lt/MNY0/VVVgd12z9sRPUxGADyM3eOlHkrhdUTsvhSlTvJxoKPn3sB+7mK Y5ehu2LCXer2H+us+GZ9vQnXwVJlIZFmSlC889poofcdrCq9nN62BsmZsoY9xf/AaiO1 sbS6we2Fgse9UO9xZQhfvdDrqS+EXqAYAhaPQwtUfy4s513Y0UwnzVCiy7RfxHVm2EIb HYjw== X-Gm-Message-State: ALoCoQm+YsMYjS08gPMW9I8rHqKs2qfehcIi8J7HdsGqB0uBWAxUSeRNpVAKlXE72ysu15m5yiOD X-Received: by 10.224.22.20 with SMTP id l20mr13345889qab.17.1384542939076; Fri, 15 Nov 2013 11:15:39 -0800 (PST) Received: from salusa.poochiereds.net (cpe-107-015-124-230.nc.res.rr.com. [107.15.124.230]) by mx.google.com with ESMTPSA id u3sm8670800qej.8.2013.11.15.11.15.37 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 15 Nov 2013 11:15:38 -0800 (PST) From: Jeff Layton To: steved@redhat.com Cc: bfields@fieldses.org, linux-nfs@vger.kernel.org Subject: [PATCH 2/2] gssd: don't let parent exit until child has a chance to scan directory once Date: Fri, 15 Nov 2013 14:15:31 -0500 Message-Id: <1384542931-18753-3-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1384542931-18753-1-git-send-email-jlayton@redhat.com> References: <1384542931-18753-1-git-send-email-jlayton@redhat.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 With some proposed kernel changes, it won't even attempt to upcall sometimes if it doesn't appear that gssd is running. This means that we have a theoretical race between gssd starting up at boot time and the init process attempting to mount kerberized filesystems. Fix this by switching gssd to use mydaemon() and having the child only release the parent after it has processed the directory once. Signed-off-by: Jeff Layton --- utils/gssd/gssd.c | 6 ++++-- utils/gssd/gssd.h | 1 + utils/gssd/gssd_main_loop.c | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c index 8ee478b..fdad153 100644 --- a/utils/gssd/gssd.c +++ b/utils/gssd/gssd.c @@ -54,6 +54,7 @@ #include "err_util.h" #include "gss_util.h" #include "krb5_util.h" +#include "nfslib.h" char pipefs_dir[PATH_MAX] = GSSD_PIPEFS_DIR; char keytabfile[PATH_MAX] = GSSD_DEFAULT_KEYTAB_FILE; @@ -63,6 +64,7 @@ int use_memcache = 0; int root_uses_machine_creds = 1; unsigned int context_timeout = 0; char *preferred_realm = NULL; +int pipefds[2] = { -1, -1 }; void sig_die(int signal) @@ -187,8 +189,8 @@ main(int argc, char *argv[]) if (gssd_check_mechs() != 0) errx(1, "Problem with gssapi library"); - if (!fg && daemon(0, 0) < 0) - errx(1, "fork"); + if (!fg) + mydaemon(0, 0, pipefds); signal(SIGINT, sig_die); signal(SIGTERM, sig_die); diff --git a/utils/gssd/gssd.h b/utils/gssd/gssd.h index 86472a1..47995b7 100644 --- a/utils/gssd/gssd.h +++ b/utils/gssd/gssd.h @@ -67,6 +67,7 @@ extern int use_memcache; extern int root_uses_machine_creds; extern unsigned int context_timeout; extern char *preferred_realm; +extern int pipefds[2]; TAILQ_HEAD(clnt_list_head, clnt_info) clnt_list; diff --git a/utils/gssd/gssd_main_loop.c b/utils/gssd/gssd_main_loop.c index ccf7fe5..9970028 100644 --- a/utils/gssd/gssd_main_loop.c +++ b/utils/gssd/gssd_main_loop.c @@ -53,6 +53,7 @@ #include "gssd.h" #include "err_util.h" +#include "nfslib.h" extern struct pollfd *pollarray; extern unsigned long pollsize; @@ -245,6 +246,9 @@ gssd_run() /* Error msg is already printed */ exit(1); } + + /* release the parent after the initial dir scan */ + release_parent(pipefds); } gssd_poll(pollarray, pollsize); }