linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: Petr Vorel <petr.vorel@gmail.com>
Cc: Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	Joey Hess <joeyh@debian.org>, Steve Dickson <steved@redhat.com>
Subject: Re: [nfs-utils PATCH 1/1] mount: Do not overwrite /etc/mtab if it's symlink
Date: Wed, 20 Nov 2019 13:51:38 -0500	[thread overview]
Message-ID: <C92F18A6-711E-4791-B140-F59595F89C22@oracle.com> (raw)
In-Reply-To: <20191120183529.29366-1-petr.vorel@gmail.com>



> On Nov 20, 2019, at 1:35 PM, Petr Vorel <petr.vorel@gmail.com> wrote:
> 
> From: Joey Hess <joeyh@debian.org>
> 
> 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 <chuck.lever@oracle.com>

No objection from me.


> Signed-off-by: Joey Hess <joeyh@debian.org>
> [ 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 <petr.vorel@gmail.com>
> ---
> 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+");
> -- 
> 2.24.0
> 

--
Chuck Lever




  reply	other threads:[~2019-11-20 18:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20 18:35 [nfs-utils PATCH 1/1] mount: Do not overwrite /etc/mtab if it's symlink Petr Vorel
2019-11-20 18:51 ` Chuck Lever [this message]
2019-11-22 15:49 ` Steve Dickson
2019-11-22 16:27   ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C92F18A6-711E-4791-B140-F59595F89C22@oracle.com \
    --to=chuck.lever@oracle.com \
    --cc=joeyh@debian.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=petr.vorel@gmail.com \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).