From nobody Sat Jun 11 19:52:00 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0FB3F833B2D; Sat, 11 Jun 2022 19:52:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LL7l44KMwz4rQ0; Sat, 11 Jun 2022 19:52:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654977121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XMXj+H2W5sQPz7YyO8wWUybjTxl6wGOhHQ/qp/0fAV4=; b=TY+jltoXHUakO3KKdmSRncsgGnYMfcG5hwl6jhNoOpxsMCNKZfUoBb4OgV6FLs+lq7rbxD xl9XNV6uZYfpwfqTrlJPbLutgSeEKW6K7gyD+Gh4VxpD47eaWyB66316VCAoBsGj7EymUz 4ojv/HSZkeHBQvdSoReVSbGs/HRgHOEHXGuLuypgyvocm+yfTuAesgrpW57XIIkyt8Qpx2 h0LFukluGtTy0VSxSlFVkVUYq80YTBa2i/tn21rbl/JJiw5zp6XdgPlNlxhiV14iD0GcVw V8mXD+3ijDLrX+hp3zTaVyoF2ET44XFWq3jHZj6B32O0Rs73mKbRm4mD7kFUyg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 66C9713787; Sat, 11 Jun 2022 19:52:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25BJq0KN066921; Sat, 11 Jun 2022 19:52:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25BJq0Uq066919; Sat, 11 Jun 2022 19:52:00 GMT (envelope-from git) Date: Sat, 11 Jun 2022 19:52:00 GMT Message-Id: <202206111952.25BJq0Uq066919@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: 667c782baa8f - stable/13 - mount_nfs: Only create a mounttab file entry is nmount(2) succeeds List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 667c782baa8fea889dae25beba294160995e85b5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654977121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XMXj+H2W5sQPz7YyO8wWUybjTxl6wGOhHQ/qp/0fAV4=; b=b8FX+IR4Mdd1ETllqmCz71KT53tZMdVcrAskHZHViifrSkAbIVZcEsRuqc2iLxGJwuZwnT le/If9OyYErcm0L66aVGg63Q0MgOLN2TsxcCzRk/Kj7PH8+zCMMhaYkFLJ2JyAYBhLi65C pjjfELkiNkiqRzApE7Q8lAPJKJ46vps5nn9c1kP4hKc/dvFk6PcDwGPj/nGge6yeAJ53w0 5Gxys0L2k3Jsy+gqSTlAJp7XMhwj/ozufPNP4bxu5di7raQDzjNJnh+j7pq3N8lwd6yTsK z8O8hmclpiYEWYYyNErXwiCk2GVmnsS6FnloKmr0o7MA2nfZHpQcp8xi6qtVVw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654977121; a=rsa-sha256; cv=none; b=gP+ju306M1vE0ek4Ixln3Icc4KczzZv8iskALG4u49YrnQoJpGRE7wWlUuHULSYi5ztzlW VQCpkSEOAzPJwBFWvEnSVMu0YYXHZr39kf/RCsUw2HBcpzn127smeuSnbLlpgOYDx+mMxl T9BDcIMMUqonnr3E33ikmAufQXDyWeUEsZklvwmVdESkPs2JE2BSJMN5TsmlNhUZ5K076U N00IGTUHY/mkND/a02HxsEkR+TUkAAOvRhWNizcal5mdqSmpDZk71mfin9/I1zExJDrkCo PreVc9MWAwqa+yIHBlnCxXr/hlv0IrepO2DtUJWPFEQXUm4pShlpXgbfhqjiLQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=667c782baa8fea889dae25beba294160995e85b5 commit 667c782baa8fea889dae25beba294160995e85b5 Author: Rick Macklem AuthorDate: 2022-05-28 22:48:40 +0000 Commit: Rick Macklem CommitDate: 2022-06-11 19:50:33 +0000 mount_nfs: Only create a mounttab file entry is nmount(2) succeeds mount_nfs creates entries in the mounttab file and umount removes them. Entries in the mounttab file ae used by rpc.umntall to notify the NFS server that NFSv3 entries need to be removed when they have not been removed by umount. Without this patch, an enty will be created in the mounttab file, even if the nmount(2) syscall fails for the mount. This patch modifies the code so that the mounttab entry is only created after nmount(2) succeeds. This change only affects NFSv3 and only affects how showmount displays NFSv3 mounts. (cherry picked from commit 7cab630ba4fb26bf85336a89d88721ed2315c46c) --- sbin/mount_nfs/mount_nfs.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index 898a6dc9d724..6ea861193df8 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -139,7 +139,7 @@ enum tryret { static int sec_name_to_num(const char *sec); static const char *sec_num_to_name(int num); -static int getnfsargs(char *, struct iovec **iov, int *iovlen); +static int getnfsargs(char **, char **, struct iovec **iov, int *iovlen); /* void set_rpc_maxgrouplist(int); */ static struct netconfig *getnetconf_cached(const char *netid); static const char *netidbytype(int af, int sotype); @@ -156,7 +156,7 @@ main(int argc, char *argv[]) int c; struct iovec *iov; int num, iovlen; - char *mntname, *p, *spec, *tmp; + char *host, *mntname, *p, *spec, *tmp; char mntpath[MAXPATHLEN], errmsg[255]; char hostname[MAXHOSTNAMELEN + 1], gssn[MAXHOSTNAMELEN + 50]; const char *gssname, *nmount_errstr; @@ -461,7 +461,7 @@ main(int argc, char *argv[]) __DECONST(void *, gssname), strlen(gssname) + 1); } - if (!getnfsargs(spec, &iov, &iovlen)) + if (!getnfsargs(&spec, &host, &iov, &iovlen)) exit(1); /* resolve the mountpoint with realpath(3) */ @@ -479,6 +479,9 @@ main(int argc, char *argv[]) else err(1, "nmount: %s%s%s", mntpath, errmsg[0] ? ", " : "", errmsg); + } else if (mountmode != V4 && !add_mtab(host, spec)) { + /* Add mounted file system to PATH_MOUNTTAB */ + warnx("can't update %s for %s:%s", PATH_MOUNTTAB, host, spec); } exit(0); @@ -568,15 +571,16 @@ rtm_ifinfo_sleep(time_t sec) } static int -getnfsargs(char *spec, struct iovec **iov, int *iovlen) +getnfsargs(char **specp, char **hostpp, struct iovec **iov, int *iovlen) { struct addrinfo hints, *ai_nfs, *ai; enum tryret ret; int ecode, speclen, remoteerr, offset, have_bracket = 0; - char *hostp, *delimp, *errstr; + char *hostp, *delimp, *errstr, *spec; size_t len; static char nam[MNAMELEN + 1], pname[MAXHOSTNAMELEN + 5]; + spec = *specp; if (*spec == '[' && (delimp = strchr(spec + 1, ']')) != NULL && *(delimp + 1) == ':') { hostp = spec + 1; @@ -718,9 +722,9 @@ getnfsargs(char *spec, struct iovec **iov, int *iovlen) freeaddrinfo(ai_nfs); build_iovec(iov, iovlen, "hostname", nam, (size_t)-1); - /* Add mounted file system to PATH_MOUNTTAB */ - if (mountmode != V4 && !add_mtab(hostp, spec)) - warnx("can't update %s for %s:%s", PATH_MOUNTTAB, hostp, spec); + + *specp = spec; + *hostpp = hostp; return (1); }