Date: Sun, 26 Oct 1997 11:41:56 +0100 (MET) From: Wolfram Schneider <wosch@cs.tu-berlin.de> To: freebsd-fs@freebsd.org Subject: disabled symlinks Message-ID: <199710261041.LAA00556@panke.panke.de>
next in thread | raw e-mail | index | archive | help
I want mount a file system without symlinks, e.g. mount -t mfs -o nodev,nosuid,nosymlink /dev/sd0b /tmp The nosymlink flag do not allow the creation of a symlink on the mounted file system. Here is a patch for the kernel and mount(8). # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # nosymlink-kernel.diff # nosymlink-user.diff # echo x - nosymlink-kernel.diff sed 's/^X//' >nosymlink-kernel.diff << 'END-of-nosymlink-kernel.diff' XIndex: kern/vfs_syscalls.c X=================================================================== XRCS file: /usr/cvs/src/sys/kern/vfs_syscalls.c,v Xretrieving revision 1.51.2.6 Xdiff -u -r1.51.2.6 vfs_syscalls.c X--- vfs_syscalls.c 1997/10/23 18:04:55 1.51.2.6 X+++ vfs_syscalls.c 1997/10/25 18:18:44 X@@ -183,9 +183,11 @@ X else if (mp->mnt_flag & MNT_RDONLY) X mp->mnt_flag |= MNT_WANTRDWR; X mp->mnt_flag &=~ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV | X- MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOATIME); X+ MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOATIME | X+ MNT_NOSYMLINK); X mp->mnt_flag |= uap->flags & (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV | X- MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_FORCE | MNT_NOATIME); X+ MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_FORCE | MNT_NOATIME | X+ MNT_NOSYMLINK); X /* X * Mount the filesystem. X */ XIndex: sys/mount.h X=================================================================== XRCS file: /usr/cvs/src/sys/sys/mount.h,v Xretrieving revision 1.34.2.1 Xdiff -u -r1.34.2.1 mount.h X--- mount.h 1997/08/17 13:33:43 1.34.2.1 X+++ mount.h 1997/10/25 17:23:00 X@@ -161,6 +161,7 @@ X #define MNT_UNION 0x00000020 /* union with underlying filesystem */ X #define MNT_ASYNC 0x00000040 /* file system written asynchronously */ X #define MNT_NOATIME 0x10000000 /* Disable update of file access times */ X+#define MNT_NOSYMLINK 0x20000000 /* Disable symlinks */ X X /* X * exported mount flags. X@@ -185,7 +186,8 @@ X #define MNT_VISFLAGMASK (MNT_RDONLY|MNT_SYNCHRONOUS|MNT_NOEXEC|MNT_NOSUID| \ X MNT_NODEV|MNT_UNION|MNT_ASYNC|MNT_EXRDONLY|MNT_EXPORTED| \ X MNT_DEFEXPORTED|MNT_EXPORTANON|MNT_EXKERB|MNT_LOCAL| \ X- MNT_QUOTA|MNT_ROOTFS|MNT_USER|MNT_NOATIME) X+ MNT_QUOTA|MNT_ROOTFS|MNT_USER|MNT_NOATIME|\ X+ MNT_NOSYMLINK) X X /* X * filesystem control flags. XIndex: ufs/ufs/ufs_vnops.c X=================================================================== XRCS file: /usr/cvs/src/sys/ufs/ufs/ufs_vnops.c,v Xretrieving revision 1.41.2.3 Xdiff -u -r1.41.2.3 ufs_vnops.c X--- ufs_vnops.c 1997/06/29 08:48:50 1.41.2.3 X+++ ufs_vnops.c 1997/10/25 22:27:27 X@@ -1515,6 +1515,12 @@ X register struct inode *ip; X int len, error; X X+ /* do not create symlinks on this file system */ X+ if (ap->a_dvp->v_mount->mnt_flag & MNT_NOSYMLINK) { X+ vput(ap->a_dvp); X+ return ENOSYS; X+ } X+ X error = ufs_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp, X vpp, ap->a_cnp); X if (error) END-of-nosymlink-kernel.diff echo x - nosymlink-user.diff sed 's/^X//' >nosymlink-user.diff << 'END-of-nosymlink-user.diff' XIndex: mount/mntopts.h X=================================================================== XRCS file: /usr/cvs/src/sbin/mount/mntopts.h,v Xretrieving revision 1.7 Xdiff -u -r1.7 mntopts.h X--- mntopts.h 1996/09/03 07:13:55 1.7 X+++ mntopts.h 1997/10/20 15:55:25 X@@ -47,6 +47,7 @@ X #define MOPT_NODEV { "dev", 1, MNT_NODEV, 0 } X #define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 } X #define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 } X+#define MOPT_NOSYMLINK { "symlink", 1, MNT_NOSYMLINK, 0 } X #define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 } X #define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 } X #define MOPT_UNION { "union", 0, MNT_UNION, 0 } X@@ -75,6 +76,7 @@ X MOPT_NODEV, \ X MOPT_NOEXEC, \ X MOPT_NOSUID, \ X+ MOPT_NOSYMLINK, \ X MOPT_RDONLY, \ X MOPT_UNION X XIndex: mount/mount.8 X=================================================================== XRCS file: /usr/cvs/src/sbin/mount/mount.8,v Xretrieving revision 1.11.2.2 Xdiff -u -r1.11.2.2 mount.8 X--- mount.8 1997/08/24 17:52:01 1.11.2.2 X+++ mount.8 1997/10/25 22:41:36 X@@ -134,6 +134,10 @@ X wrapper like X .Xr suidperl X is installed on your system. X+.It nosymlink X+Do not allow the creation of a X+.Xr symlink 2 X+on the mounted file system. X .It rdonly X The same as X .Fl r ; XIndex: mount/mount.c X=================================================================== XRCS file: /usr/cvs/src/sbin/mount/mount.c,v Xretrieving revision 1.15 Xdiff -u -r1.15 mount.c X--- mount.c 1996/09/03 07:13:56 1.15 X+++ mount.c 1997/10/25 17:25:58 X@@ -92,6 +92,7 @@ X { MNT_NODEV, "nodev" }, X { MNT_NOEXEC, "noexec" }, X { MNT_NOSUID, "nosuid" }, X+ { MNT_NOSYMLINK, "nosymlink" }, X { MNT_QUOTA, "with quotas" }, X { MNT_RDONLY, "read-only" }, X { MNT_SYNCHRONOUS, "synchronous" }, X@@ -588,6 +589,9 @@ X X if (ent->f_flags & MNT_ASYNC) X printf (",async"); X+ X+ if (ent->f_flags & MNT_NOSYMLINK) X+ printf (",nosymlink"); X X if (fst = getfsspec (ent->f_mntfromname)) X printf ("\t%u %u\n", fst->fs_freq, fst->fs_passno); END-of-nosymlink-user.diff exit -- Wolfram Schneider <wosch@apfel.de> http://www.apfel.de/~wosch/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710261041.LAA00556>