Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6782208pxb; Wed, 17 Feb 2021 13:19:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/iOTAkm2vwuJIxMNd5+kQ76kMNcTcYrlOWzBIrw8KqIVW2Xh0aCaBtQQgd9nWGH3rnDbd X-Received: by 2002:a17:906:2bce:: with SMTP id n14mr823903ejg.171.1613596783930; Wed, 17 Feb 2021 13:19:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613596783; cv=none; d=google.com; s=arc-20160816; b=PUR03rZBKCtnqyA/FwC8reXRyjHw0nZPaDjWtpNrPsUXjcRtMYKily4fFlOL2vDpIy tWTozHL0PQFa0IQey0RnM8E3BYbsMnrEKsbvBg5gHZF2nd6L1qx6hHRd2dLUKs/NYbca h7PNmfP4n0ymDiJ/X5SNl0iQM+vvDMQZblXAanIejGUwoaNQwc68ubBj5hW2tU8lMP3V jfAZI3n6PbPryaKIyP9VGt8DxscaDbYBuhyIvCNWyb3pBOvD/km70cUJWVzNLAmbxb+e AVqngLGhqrN7sdBehbUJ4UZeeALEKIKvD+0yy/j2J/iYTE3+A6ms90inDLrzsoi3B9dY FE8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vXMVZQzcD/afED0UUSGpEVqPqSf5aFYIAOftVCsKesA=; b=yDvfiuLY509SD4uXSeLC4MBGGCg2cvrhTx9cZ0rQXiZSkD4RXeWj/L9UTgWd65BEpw eiO1A7pCtorQ8EwE+YfuS9bPOiqrE97SKdsHvwy1kl9N4Lct+8HQL/gMi3qvV3hKGoaK tW6vGSBiQ0z48dHyecSkseNJ/D/mt2VX2PnADIAUFjQaRsNEjNMY6SQU5S6Fcce+pOFF wK5t/WZOe83FjmOYaAbx5F6tJNWgX50vDvWi2hQTAflNhQoifmzC0FEwiL3uRQcPwPaV ALIr5Vb6NheIsgNs4mdDMxqfrtn6dyA/dqiMApPmCLDSW6152Ahb8wfIyfvMk3dbcRxW PR5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HhUGDq4+; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si802270ejq.235.2021.02.17.13.19.20; Wed, 17 Feb 2021 13:19:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HhUGDq4+; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233374AbhBQTmf (ORCPT + 99 others); Wed, 17 Feb 2021 14:42:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:21218 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232666AbhBQTme (ORCPT ); Wed, 17 Feb 2021 14:42:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613590867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vXMVZQzcD/afED0UUSGpEVqPqSf5aFYIAOftVCsKesA=; b=HhUGDq4+VS4633oA7lrHyPYOwR3OS3ozqKhXoA8HGgjuT9Zlq58DjFdbQ+iYajMyuVQGqr kMrkydGz3q53wLmXBQkzUT9400023dCcCaKyosEE3vZlbQ6Pu42e6aUnsG5jdHwpIZ3oOI JrW8Kju39lOcCut7Jo/kjScLm8PtA1o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-NscBO290NreswSGKBuvnDw-1; Wed, 17 Feb 2021 14:41:05 -0500 X-MC-Unique: NscBO290NreswSGKBuvnDw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6004FEC1A1 for ; Wed, 17 Feb 2021 19:41:04 +0000 (UTC) Received: from madhat.home.dicksonnet.net (ovpn-112-108.phx2.redhat.com [10.3.112.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B9CC60657 for ; Wed, 17 Feb 2021 19:41:04 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 1/6] exportd: the initial shell of the v4 export support Date: Wed, 17 Feb 2021 14:42:35 -0500 Message-Id: <20210217194240.79915-2-steved@redhat.com> In-Reply-To: <20210217194240.79915-1-steved@redhat.com> References: <20210217194240.79915-1-steved@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Steve Dickson --- .gitignore | 1 + configure.ac | 1 + utils/Makefile.am | 1 + utils/exportd/Makefile.am | 56 ++++++++++++++++++ utils/exportd/exportd.c | 121 ++++++++++++++++++++++++++++++++++++++ utils/exportd/exportd.man | 74 +++++++++++++++++++++++ 6 files changed, 254 insertions(+) create mode 100644 utils/exportd/Makefile.am create mode 100644 utils/exportd/exportd.c create mode 100644 utils/exportd/exportd.man diff --git a/.gitignore b/.gitignore index e97b31f..c89d1cd 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ utils/idmapd/idmapd utils/lockd/lockd utils/mount/mount.nfs utils/mountd/mountd +utils/exportd/exportd utils/nfsd/nfsd utils/nfsstat/nfsstat utils/nhfsstone/nhfsstone diff --git a/configure.ac b/configure.ac index 50847d8..ffd6247 100644 --- a/configure.ac +++ b/configure.ac @@ -706,6 +706,7 @@ AC_CONFIG_FILES([ utils/idmapd/Makefile utils/mount/Makefile utils/mountd/Makefile + utils/exportd/Makefile utils/nfsd/Makefile utils/nfsref/Makefile utils/nfsstat/Makefile diff --git a/utils/Makefile.am b/utils/Makefile.am index 4c930a4..4638e97 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -34,6 +34,7 @@ endif SUBDIRS = \ exportfs \ mountd \ + exportd \ nfsd \ nfsstat \ showmount \ diff --git a/utils/exportd/Makefile.am b/utils/exportd/Makefile.am new file mode 100644 index 0000000..2314d32 --- /dev/null +++ b/utils/exportd/Makefile.am @@ -0,0 +1,56 @@ +## Process this file with automake to produce Makefile.in + +OPTLIBS = + +man8_MANS = exportd.man +EXTRA_DIST = $(man8_MANS) + +sbin_PROGRAMS = exportd + +exportd_SOURCES = exportd.c +exportd_LDADD = ../../support/nfs/libnfs.la + +exportd_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) + +MAINTAINERCLEANFILES = Makefile.in + +####################################################################### +# The following allows the current practice of having +# daemons renamed during the install to include RPCPREFIX +# and the KPREFIX +# This could all be done much easier with program_transform_name +# ( program_transform_name = s/^/$(RPCPREFIX)$(KPREFIX)/ ) +# but that also renames the man pages, which the current +# practice does not do. +install-exec-hook: + (cd $(DESTDIR)$(sbindir) && \ + for p in $(sbin_PROGRAMS); do \ + mv -f $$p$(EXEEXT) $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ + done) +uninstall-hook: + (cd $(DESTDIR)$(sbindir) && \ + for p in $(sbin_PROGRAMS); do \ + rm -f $(RPCPREFIX)$(KPREFIX)$$p$(EXEEXT) ;\ + done) + + +# XXX This makes some assumptions about what automake does. +# XXX But there is no install-man-hook or install-man-local. +install-man: install-man8 install-man-links +uninstall-man: uninstall-man8 uninstall-man-links + +install-man-links: + (cd $(DESTDIR)$(man8dir) && \ + for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ + inst=`echo $$m | sed -e 's/man$$/8/'`; \ + rm -f $(RPCPREFIX)$$inst ; \ + $(LN_S) $$inst $(RPCPREFIX)$$inst ; \ + done) + +uninstall-man-links: + (cd $(DESTDIR)$(man8dir) && \ + for m in $(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS); do \ + inst=`echo $$m | sed -e 's/man$$/8/'`; \ + rm -f $(RPCPREFIX)$$inst ; \ + done) + diff --git a/utils/exportd/exportd.c b/utils/exportd/exportd.c new file mode 100644 index 0000000..53712fa --- /dev/null +++ b/utils/exportd/exportd.c @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2021 Red Hat + * + * support/exportd/exportd.c + * + * Routines used to support NFSv4 exports + * + */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "nfslib.h" +#include "conffile.h" + + +static struct option longopts[] = +{ + { "foreground", 0, 0, 'F' }, + { "debug", 1, 0, 'd' }, + { "help", 0, 0, 'h' }, + { NULL, 0, 0, 0 } +}; + +/* + * Signal handlers. + */ +inline static void set_signals(void); + +static void +killer (int sig) +{ + xlog (L_NOTICE, "Caught signal %d, un-registering and exiting.", sig); + exit(0); +} +static void +sig_hup (int UNUSED(sig)) +{ + /* don't exit on SIGHUP */ + xlog (L_NOTICE, "Received SIGHUP... Ignoring.\n"); + return; +} +inline static void +set_signals(void) +{ + struct sigaction sa; + + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(SIGPIPE, &sa, NULL); + /* WARNING: the following works on Linux and SysV, but not BSD! */ + sigaction(SIGCHLD, &sa, NULL); + + sa.sa_handler = killer; + sigaction(SIGINT, &sa, NULL); + sigaction(SIGTERM, &sa, NULL); + + sa.sa_handler = sig_hup; + sigaction(SIGHUP, &sa, NULL); +} +static void +usage(const char *prog, int n) +{ + fprintf(stderr, + "Usage: %s [-f|--foreground] [-h|--help] [-d kind|--debug kind]\n", prog); + exit(n); +} + +int +main(int argc, char **argv) +{ + char *progname; + int foreground = 0; + int c; + + /* Set the basename */ + if ((progname = strrchr(argv[0], '/')) != NULL) + progname++; + else + progname = argv[0]; + + /* Initialize logging. */ + xlog_open(progname); + + conf_init_file(NFS_CONFFILE); + xlog_from_conffile(progname); + + while ((c = getopt_long(argc, argv, "d:fh", longopts, NULL)) != EOF) { + switch (c) { + case 'd': + xlog_sconfig(optarg, 1); + break; + case 'f': + foreground++; + break; + case 'h': + usage(progname, 0); + break; + case '?': + default: + usage(progname, 1); + } + + } + + if (!foreground) + xlog_stderr(0); + + daemon_init(foreground); + + set_signals(); + + daemon_ready(); +} diff --git a/utils/exportd/exportd.man b/utils/exportd/exportd.man new file mode 100644 index 0000000..96e133c --- /dev/null +++ b/utils/exportd/exportd.man @@ -0,0 +1,74 @@ +.\"@(#)exportd.8" +.\" +.\" Copyright (C) 2021 Red Hat +.\" +.TH exportd 8 "02 Feb 2021" +.SH NAME +exportd \- NFSv4 Server Mount Daemon +.SH SYNOPSIS +.BI "/usr/sbin/exportd [" options "]" +.SH DESCRIPTION +The +.B exportd +is used to manage NFSv4 exports. The NFSv4 server +receives a mount request from a client and pass it up to +.B exportd. +.B exportd +then uses the exports(5) export +table to verify the validity of the mount request. +.PP +An NFS server maintains a table of local physical file systems +that are accessible to NFS clients. +Each file system in this table is referred to as an +.IR "exported file system" , +or +.IR export , +for short. +.PP +Each file system in the export table has an access control list. +.B exportd +uses these access control lists to determine +whether an NFS client is permitted to access a given file system. +For details on how to manage your NFS server's export table, see the +.BR exports (5) +and +.BR exportfs (8) +man pages. +.SH OPTIONS +.TP +.B \-d kind " or " \-\-debug kind +Turn on debugging. Valid kinds are: all, auth, call, general and parse. +.TP +.B \-F " or " \-\-foreground +Run in foreground (do not daemonize) +.TP +.B \-h " or " \-\-help +Display usage message. +.SH CONFIGURATION FILE +Many of the options that can be set on the command line can also be +controlled through values set in the +.B [exportd] +or, in some cases, the +.B [nfsd] +sections of the +.I /etc/nfs.conf +configuration file. +Values recognized in the +.B [exportd] +section include +.B debug +which each have the same effect as the option with the same name. +.SH FILES +.TP 2.5i +.I /etc/exports +input file for +.BR exportfs , +listing exports, export options, and access control lists +.SH SEE ALSO +.BR exportfs (8), +.BR exports (5), +.BR showmount (8), +.BR nfs.conf (5), +.BR firwall-cmd (1), +.sp +RFC 3530 - "Network File System (NFS) version 4 Protocol" -- 2.29.2