On 2020/05/19 11:36, Andreas Kusalananda Kähäri wrote: > >Synopsis: Mounting MFS filesystem does not preserve directory permissions > >of mount point > >Category: system > >Environment: > System : OpenBSD 6.7 > Details : OpenBSD 6.7-current (GENERIC.MP) #198: Mon May 18 > 20:33:28 MDT 2020 > > dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP > > Architecture: OpenBSD.amd64 > Machine : amd64 > >Description: > > I've notice that with the most recent snapshot, the permissions of my > /tmp directory, mounted as a MFS filesystem, were wrong: > > $ ls -ld /tmp > drwxr-xr-x 2 root wheel 512 May 19 11:23 /tmp > > This filesystem is mounted via fstab: > > swap /tmp mfs rw,nodev,nosuid,-s1G > > ... and the mount point has the correct permissions: > > $ doas umount /tmp > $ ls -ld /tmp > drwxrwxrwt 7 root wheel 512 May 19 11:23 /tmp
OK? Index: mkfs.c =================================================================== RCS file: /cvs/src/sbin/newfs/mkfs.c,v retrieving revision 1.98 diff -u -p -r1.98 mkfs.c --- mkfs.c 3 Jul 2019 03:24:02 -0000 1.98 +++ mkfs.c 19 May 2020 11:43:30 -0000 @@ -134,7 +134,7 @@ static int ilog2(int); void initcg(int, time_t); void wtfs(daddr_t, int, void *); int fsinit1(time_t, mode_t, uid_t, gid_t); -int fsinit2(time_t); +int fsinit2(time_t, mode_t, uid_t, gid_t); int makedir(struct direct *, int); void iput(union dinode *, ino_t); void setblock(struct fs *, unsigned char *, int); @@ -590,7 +590,7 @@ mkfs(struct partition *pp, char *fsys, i sblock.fs_ffs1_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree; sblock.fs_ffs1_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree; } else { - if (fsinit2(utime)) + if (fsinit2(utime, mfsmode, mfsuid, mfsgid)) errx(32, "fsinit2 failed"); } @@ -841,7 +841,7 @@ fsinit1(time_t utime, mode_t mfsmode, ui } int -fsinit2(time_t utime) +fsinit2(time_t utime, mode_t mfsmode, uid_t mfsuid, gid_t mfsgid) { union dinode node; @@ -856,9 +856,15 @@ fsinit2(time_t utime) /* * Create the root directory. */ - node.dp2.di_mode = IFDIR | UMASK; - node.dp2.di_uid = geteuid(); - node.dp2.di_gid = getegid(); + if (mfs) { + node.dp2.di_mode = IFDIR | mfsmode; + node.dp2.di_uid = mfsuid; + node.dp2.di_gid = mfsgid; + } else { + node.dp2.di_mode = IFDIR | UMASK; + node.dp2.di_uid = geteuid(); + node.dp2.di_gid = getegid(); + } node.dp2.di_nlink = PREDEFDIR; node.dp2.di_size = makedir(root_dir, PREDEFDIR);