mount: Do not overwrite /etc/mtab if it's symlink
Subsystems (2)
PATCH 1/1 mount: Do not overwrite /etc/mtab if it's symlink
From: Joey Hess <[email protected]>
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.
[ pvorel: took patch from Debian, rebased for 2.4.3-rc1 and created commit message. Patch is also used in Gentoo. ]
---
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(-)
utils/mount/fstab.c +1 -1
@@ -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;
utils/mount/fstab.h +1 -0
@@ -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 );
utils/mount/mount.c +7 -0
@@ -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+" );
Signature · 1 line
2.24.0
Quoted 10 lines · Petr Vorel
From: Joey Hess <[email protected]>
Some systems have
/etc/mtabsymlink to/proc/mounts. In that case mount.nfs complains:
Can't set permissions on mtab: Operation not permitted
Quoted 6 lines
See https://bugs.debian.org/476577
This change makes mount.nfs handle symlinked
/etc/mtabthe way umount.nfs and util- linux handle it.Cc Chuck Lever <[email protected]>
No objection from me.
Quoted 63 lines
Signed-off-by Joey Hess <[email protected]>[ 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 <[email protected]>---
Hi,if you merge, please keep Joey as the author in git :).
Kind regards,
Petrutils/mount/fstab.c | 2 +- utils/mount/fstab.h | 1 + utils/mount/mount.c | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)utils/mount/fstab.c +1
-1@@ -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;utils/mount/fstab.h +1
-0@@ -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 );utils/mount/mount.c +7
-0@@ -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+" );Signature · 1 line
2.24.0
--
Chuck Lever
Quoted 8 lines · Petr Vorel
From: Joey Hess <[email protected]>
Some systems have
/etc/mtabsymlink to/proc/mounts. In that case mount.nfs complains:
Can't set permissions on mtab: Operation not permitted
Quoted 8 lines
This change makes mount.nfs handle symlinked
/etc/mtabthe way umount.nfs and util- linux handle it.Cc Chuck Lever <[email protected]>Signed-off-by Joey Hess <[email protected]>[ 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 <[email protected]>
Committed... (tag: nfs-utils-2-4-3-rc2)
steved.
Quoted 57 lines
---
Hi,if you merge, please keep Joey as the author in git :).
Kind regards,
Petrutils/mount/fstab.c | 2 +- utils/mount/fstab.h | 1 + utils/mount/mount.c | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)utils/mount/fstab.c +1
-1@@ -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;utils/mount/fstab.h +1
-0@@ -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 );utils/mount/mount.c +7
-0@@ -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+" );
Hi Steve,
Quoted 12 lines · Petr Vorel
Quoted 10 lines
From: Joey Hess <[email protected]>
Some systems have
/etc/mtabsymlink to/proc/mounts. In that case mount.nfs complains:
Can't set permissions on mtab: Operation not permittedSee https://bugs.debian.org/476577
This change makes mount.nfs handle symlinked
/etc/mtabthe way umount.nfs and util- linux handle it.
Quoted 6 lines
Quoted 5 lines
Cc Chuck Lever <[email protected]>Signed-off-by Joey Hess <[email protected]>[ 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 <[email protected]>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/
Quoted 1 line
steved.
Kind regards,
Petr