Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp454830ybc; Fri, 22 Nov 2019 07:50:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzI/jZh0J29VgTxbiEUo0w8RKcCH19ILtbv62ESlAh99ugVyShWYSNocKLPOiHmUlM5nvqQ X-Received: by 2002:a50:970e:: with SMTP id c14mr1892918edb.20.1574437805719; Fri, 22 Nov 2019 07:50:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574437805; cv=none; d=google.com; s=arc-20160816; b=wLg0dstUxT9f09HPA3IdpDzhqPkwJtcIm36TKYsUstk0RTJbxOonbsE+0kT4eJtJRX xMfRTUyEhKZj1xuWqmKm9NaqBjdVxcDb53G1GtymabaIaG8/YG1a+vDSAJ44g01acHkY 7JJaA7J9yJQApG/z3jc+1kncJDWjeOmmSyZs9+dtfF7QR3JuCs70cgbikoh0iX9fwT4F 83QwWBgOOUqudRtqkkI7X7p1qhBorbVLfzPe3qhdlkCF/tDYCt9jxTlMxz3QniDxh4/A Zh4JzPty+1hszAueKb0WL2wMErAuUJ72zROMmffjUhrjgeN+79X9bcqFX4woDPwfMWu6 XIpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=cHM8qSivLaVgJ93w5exNqPwhavT4W01ZjSyTWkcdftk=; b=ayKFfNAOuqj8Vi5C951NK1oPjAbmHsVi4v+cgy9QUjFqVdz9d0N0JrqpMmFXsJdEUU km5J+9X35Fxnn3N8MVdomBXB+9v/yWAL9B1p5NTcwDDef3yzEIOZ39p/ESi8Hqt0jQ3g OUgjBfms0CPTy6Qg3b/qwkocBlJ0gUPtfzT3RBTzfRlq0kM4kNas7EJ3csyLKv0+uQu8 X7tVp4EqoESfqaVHiHsk3QV/w7H/r+5KVwxnh3sa5bVu68ne+UjnI0NQSVlagQBq7fJC S9YA3f+DqDDXM5khX9x0Oysfoa/ahRC5lgm6RalQd+twVgHA8rL+jioZexdxXfvcAUQ/ MGlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XQVRiY78; 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=pass (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 k15si4466009ejq.153.2019.11.22.07.49.30; Fri, 22 Nov 2019 07:50:05 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XQVRiY78; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726613AbfKVPt0 (ORCPT + 99 others); Fri, 22 Nov 2019 10:49:26 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:27053 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726546AbfKVPtZ (ORCPT ); Fri, 22 Nov 2019 10:49:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574437764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cHM8qSivLaVgJ93w5exNqPwhavT4W01ZjSyTWkcdftk=; b=XQVRiY78Q9tWRkp95oAx/RPx+lV/8sVNam/Dff3HhnG0nqSuuiPdFi8Wk1qgeMaeheEMyV SBuDUmlVdrSHzpQOdRYGgMRNJwIMnLEvWCn4QGEa6RI14wP+g5BPWSUs0n42iyu1Fnt9Gr NPhrqiB/dY42wIidWRD5Ha0slhJhrxo= 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-233-p05zpBIfMYOojWnxjteEeQ-1; Fri, 22 Nov 2019 10:49:20 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A438E477; Fri, 22 Nov 2019 15:49:19 +0000 (UTC) Received: from madhat.boston.devel.redhat.com (ovpn-117-36.phx2.redhat.com [10.3.117.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F95110027B1; Fri, 22 Nov 2019 15:49:19 +0000 (UTC) Subject: Re: [nfs-utils PATCH 1/1] mount: Do not overwrite /etc/mtab if it's symlink To: Petr Vorel , linux-nfs@vger.kernel.org Cc: Joey Hess , Chuck Lever References: <20191120183529.29366-1-petr.vorel@gmail.com> From: Steve Dickson Message-ID: <938c3cf9-0584-d6b9-b3a1-ec12795761c5@RedHat.com> Date: Fri, 22 Nov 2019 10:49:18 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191120183529.29366-1-petr.vorel@gmail.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: p05zpBIfMYOojWnxjteEeQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On 11/20/19 1:35 PM, Petr Vorel wrote: > From: Joey Hess > > Some systems have /etc/mtab symlink to /proc/mounts. In that case > mount.nfs complains: > Can't set permissions on mtab: Operation not permitted > > See https://bugs.debian.org/476577 > > This change makes mount.nfs handle symlinked /etc/mtab the way > umount.nfs and util- linux handle it. > > Cc: Chuck Lever > Signed-off-by: Joey Hess > [ pvorel: took patch from Debian, rebased for 2.4.3-rc1 and created commit > message. Patch is also used in Gentoo. ] > Signed-off-by: Petr Vorel Committed... (tag: nfs-utils-2-4-3-rc2) steved. > --- > Hi, > > if you merge, please keep Joey as the author in git :). > > Kind regards, > Petr > > utils/mount/fstab.c | 2 +- > utils/mount/fstab.h | 1 + > utils/mount/mount.c | 7 +++++++ > 3 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/utils/mount/fstab.c b/utils/mount/fstab.c > index 8b0aaf1a..146d8f40 100644 > --- a/utils/mount/fstab.c > +++ b/utils/mount/fstab.c > @@ -61,7 +61,7 @@ mtab_does_not_exist(void) { > return var_mtab_does_not_exist; > } > > -static int > +int > mtab_is_a_symlink(void) { > get_mtab_info(); > return var_mtab_is_a_symlink; > diff --git a/utils/mount/fstab.h b/utils/mount/fstab.h > index 313bf9b3..8676c8c2 100644 > --- a/utils/mount/fstab.h > +++ b/utils/mount/fstab.h > @@ -7,6 +7,7 @@ > #define _PATH_FSTAB "/etc/fstab" > #endif > > +int mtab_is_a_symlink(void); > int mtab_is_writable(void); > int mtab_does_not_exist(void); > void reset_mtab_info(void); > diff --git a/utils/mount/mount.c b/utils/mount/mount.c > index 91f10877..92a0dfe4 100644 > --- a/utils/mount/mount.c > +++ b/utils/mount/mount.c > @@ -204,6 +204,13 @@ create_mtab (void) { > int flags; > mntFILE *mfp; > > + /* Avoid writing if the mtab is a symlink to /proc/mounts, since > + that would create a file /proc/mounts in case the proc filesystem > + is not mounted, and the fchmod below would also fail. */ > + if (mtab_is_a_symlink()) { > + return EX_SUCCESS; > + } > + > lock_mtab(); > > mfp = nfs_setmntent (MOUNTED, "a+"); >