Modify newfs so that the root node (and lost+found dir, if created)

of the new fs has uid.gid equal to the euid.egid of the process
which made it. This change permits users who have write access to
a device (say a floppy) to create a filesystem that, when mounted,
they have write access to.

This change closes PR bin/5990 from jbernard@ox.mines.edu, and is also the
change requested in PR bin/6276 from "Charles M. Hannum" <mycroft@netbsd.org>
This commit is contained in:
wrstuden 1999-03-16 21:52:34 +00:00
parent f4ccb35266
commit f2c170eda0
2 changed files with 11 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: mkfs.c,v 1.34 1999/03/11 20:23:58 wrstuden Exp $ */
/* $NetBSD: mkfs.c,v 1.35 1999/03/16 21:52:34 wrstuden Exp $ */
/*
* Copyright (c) 1980, 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
#else
__RCSID("$NetBSD: mkfs.c,v 1.34 1999/03/11 20:23:58 wrstuden Exp $");
__RCSID("$NetBSD: mkfs.c,v 1.35 1999/03/16 21:52:34 wrstuden Exp $");
#endif
#endif /* not lint */
@ -896,6 +896,8 @@ fsinit(utime)
node.di_size = sblock.fs_bsize;
node.di_db[0] = alloc(node.di_size, node.di_mode);
node.di_blocks = btodb(fragroundup(&sblock, node.di_size));
node.di_uid = geteuid();
node.di_gid = getegid();
wtfs(fsbtodb(&sblock, node.di_db[0]), node.di_size, buf);
iput(&node, LOSTFOUNDINO);
#endif
@ -913,6 +915,8 @@ fsinit(utime)
node.di_size = makedir(root_dir, PREDEFDIR);
node.di_db[0] = alloc(sblock.fs_fsize, node.di_mode);
node.di_blocks = btodb(fragroundup(&sblock, node.di_size));
node.di_uid = geteuid();
node.di_gid = getegid();
wtfs(fsbtodb(&sblock, node.di_db[0]), sblock.fs_fsize, buf);
iput(&node, ROOTINO);
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: newfs.8,v 1.22 1999/03/07 11:02:06 mycroft Exp $
.\" $NetBSD: newfs.8,v 1.23 1999/03/16 21:52:34 wrstuden Exp $
.\"
.\" Copyright (c) 1983, 1987, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@ -289,6 +289,10 @@ If the file system will be exported over NFS, the
utility should be run after
.Nm
to improve security.
.Pp
The owner and group ids of the root node of the new filesystem
are set to the effective uid and gid of the user initializing
the filesystem.
.Sh SEE ALSO
.Xr disktab 5 ,
.Xr fs 5 ,