From owner-freebsd-bugs@FreeBSD.ORG Sun Jul 27 00:50:21 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 22C7737B401 for ; Sun, 27 Jul 2003 00:50:21 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1384C43F93 for ; Sun, 27 Jul 2003 00:50:20 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h6R7oJUp061495 for ; Sun, 27 Jul 2003 00:50:19 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h6R7oJ7e061494; Sun, 27 Jul 2003 00:50:19 -0700 (PDT) Resent-Date: Sun, 27 Jul 2003 00:50:19 -0700 (PDT) Resent-Message-Id: <200307270750.h6R7oJ7e061494@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dmitry Morozovsky Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6C6037B401 for ; Sun, 27 Jul 2003 00:45:26 -0700 (PDT) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id D89F643FAF for ; Sun, 27 Jul 2003 00:45:25 -0700 (PDT) (envelope-from marck@woozle.rinet.ru) Received: from woozle.rinet.ru (localhost [127.0.0.1]) by woozle.rinet.ru (8.12.9/8.12.9) with ESMTP id h6R7jO4C092708 for ; Sun, 27 Jul 2003 11:45:24 +0400 (MSD) (envelope-from marck@woozle.rinet.ru) Received: (from marck@localhost) by woozle.rinet.ru (8.12.9/8.12.9/Submit) id h6R7jNKF092707; Sun, 27 Jul 2003 11:45:23 +0400 (MSD) Message-Id: <200307270745.h6R7jNKF092707@woozle.rinet.ru> Date: Sun, 27 Jul 2003 11:45:23 +0400 (MSD) From: Dmitry Morozovsky To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/54897: [PATCH] -y flag for mount_mfs X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dmitry Morozovsky List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jul 2003 07:50:21 -0000 >Number: 54897 >Category: bin >Synopsis: [PATCH] -y flag for mount_mfs >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jul 27 00:50:19 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Dmitry Morozovsky >Release: FreeBSD 4-STABLE i386 >Organization: Cronyx Plus LLC (RiNet ISP) >Environment: System: FreeBSD 4-STABLE >Description: mount_mfs makes file system root inode world writable and sticky, which is great for temporary file places; however, there are number of occasions where this behaviour better be avoided, and mounting leads to race. Workararounds like mount_mfs ... /mnt chmod 755 /mnt rm -rf /mnt do not seem elegant to me. On the other hand, changing default directory mode violates POLA. Hence, the following patch, which adds -y option to mount_mfs. This behaviour is not applicable to -current, as mdconfig does not make fs root-dir 1777 >How-To-Repeat: mount_mfs -s 65536 swap /mnt ls -ld /mnt >Fix: Index: sbin/newfs/mkfs.c =================================================================== RCS file: /home/ncvs/src/sbin/newfs/mkfs.c,v retrieving revision 1.29.2.6 diff -u -r1.29.2.6 mkfs.c --- sbin/newfs/mkfs.c 21 Sep 2001 19:15:21 -0000 1.29.2.6 +++ sbin/newfs/mkfs.c 27 Jul 2003 07:33:00 -0000 @@ -96,6 +96,7 @@ extern int Nflag; /* run mkfs without writing file system */ extern int Oflag; /* format as an 4.3BSD file system */ extern int Uflag; /* enable soft updates for file system */ +extern int yflag; /* do not make root inode with mode 1777 */ extern int fssize; /* file system size */ extern int ntracks; /* # tracks/cylinder */ extern int nsectors; /* # sectors/track */ @@ -1008,7 +1009,7 @@ /* * create the root directory */ - if (mfs) + if (mfs && !yflag) node.di_mode = IFDIR | 01777; else node.di_mode = IFDIR | UMASK; Index: sbin/newfs/newfs.8 =================================================================== RCS file: /home/ncvs/src/sbin/newfs/newfs.8,v retrieving revision 1.26.2.15 diff -u -r1.26.2.15 newfs.8 --- sbin/newfs/newfs.8 13 May 2003 12:16:08 -0000 1.26.2.15 +++ sbin/newfs/newfs.8 27 Jul 2003 07:33:00 -0000 @@ -82,6 +82,7 @@ .Op Fl o Ar options .Op Fl s Ar size .Op Fl v +.Op Fl y .Ar special node .Sh DESCRIPTION .Nm Newfs @@ -333,9 +334,11 @@ .Nm command, except for the .Fl o -option. +and +.Fl y +options. .Pp -That option is as follows: +That options are as follows: .Bl -tag -width indent .It Fl o Options are specified with a @@ -344,6 +347,13 @@ See the .Xr mount 8 man page for possible options and their meanings. +.It Fl y +By default, +.Nm mount_mfs +command makes file system with world writable sticky (mode 1777) +root directory which is useful for temporary file systems. +.Fl y +option disables this behaviour. .El .Sh EXAMPLES .Dl newfs /dev/ad3s1a Index: sbin/newfs/newfs.c =================================================================== RCS file: /home/ncvs/src/sbin/newfs/newfs.c,v retrieving revision 1.30.2.9 diff -u -r1.30.2.9 newfs.c --- sbin/newfs/newfs.c 13 May 2003 12:03:55 -0000 1.30.2.9 +++ sbin/newfs/newfs.c 27 Jul 2003 07:33:00 -0000 @@ -171,6 +171,7 @@ int Nflag; /* run without writing file system */ int Oflag; /* format as an 4.3BSD file system */ int Uflag; /* enable soft updates for file system */ +int yflag; /* do not make root inode with mode 1777 */ int fssize; /* file system size */ int ntracks = NTRACKS; /* # tracks/cylinder */ int nsectors = NSECTORS; /* # sectors/track */ @@ -249,7 +250,7 @@ } opstring = mfs ? - "NF:T:Ua:b:c:d:e:f:g:h:i:m:o:s:v" : + "NF:T:Ua:b:c:d:e:f:g:h:i:m:o:s:vy" : "NOS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n:o:p:r:s:t:u:vx:"; while ((ch = getopt(argc, argv, opstring)) != -1) switch (ch) { @@ -375,6 +376,9 @@ fatal("%s: bad spare sectors per cylinder", optarg); break; + case 'y': + yflag = 1; + break; case '?': default: usage(); @@ -785,5 +789,7 @@ fprintf(stderr, "\t-v do not attempt to determine partition name from device name\n"); fprintf(stderr, "\t-x spare sectors per cylinder\n"); + if (mfs) + fprintf(stderr, "\t-y make normal (non-writable) root dir\n"); exit(1); } >Release-Note: >Audit-Trail: >Unformatted: