Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
* [nfs-utils PATCH 1/1] mount: Do not overwrite /etc/mtab if it's symlink
@ 2019-11-20 18:35 Petr Vorel
  2019-11-20 18:51 ` Chuck Lever
  2019-11-22 15:49 ` Steve Dickson
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Vorel @ 2019-11-20 18:35 UTC (permalink / raw)
  To: linux-nfs; +Cc: Joey Hess, Steve Dickson, Chuck Lever, Petr Vorel

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>
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [nfs-utils PATCH 1/1] mount: Do not overwrite /etc/mtab if it's symlink
  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
  2019-11-22 15:49 ` Steve Dickson
  1 sibling, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2019-11-20 18:51 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Linux NFS Mailing List, Joey Hess, Steve Dickson



> 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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [nfs-utils PATCH 1/1] mount: Do not overwrite /etc/mtab if it's symlink
  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
@ 2019-11-22 15:49 ` Steve Dickson
  2019-11-22 16:27   ` Petr Vorel
  1 sibling, 1 reply; 4+ messages in thread
From: Steve Dickson @ 2019-11-22 15:49 UTC (permalink / raw)
  To: Petr Vorel, linux-nfs; +Cc: Joey Hess, Chuck Lever



On 11/20/19 1:35 PM, Petr Vorel 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>
> 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>
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+");
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [nfs-utils PATCH 1/1] mount: Do not overwrite /etc/mtab if it's symlink
  2019-11-22 15:49 ` Steve Dickson
@ 2019-11-22 16:27   ` Petr Vorel
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2019-11-22 16:27 UTC (permalink / raw)
  To: Steve Dickson; +Cc: linux-nfs, Joey Hess, Chuck Lever

Hi Steve,

> On 11/20/19 1:35 PM, Petr Vorel 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>
> > 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>
> Committed... (tag: nfs-utils-2-4-3-rc2)
I'm sorry for introducing a regression.

Send a patch fixing this.
https://patchwork.kernel.org/patch/11258155/

> steved.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-11-22 15:49 ` Steve Dickson
2019-11-22 16:27   ` Petr Vorel

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git