summaryrefslogtreecommitdiff
path: root/ufs-utils
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2001-12-02 22:06:54 +0000
committerRoland McGrath <roland@gnu.org>2001-12-02 22:06:54 +0000
commit1bb094f4aa4782eccadf792e27b29a67c039cf25 (patch)
tree649cefe142a1b5a4c2e94b05ffff5c2032b4ef7b /ufs-utils
parent34b697779460aca1b0849db40f64c9ebbdd43bab (diff)
2001-12-02 Roland McGrath <roland@frob.com>
* mkfs.c (fsinit): Set the root directory's owner/group to the user's. Suggested by Michael Teichgraeber <gnubert@web.de>.
Diffstat (limited to 'ufs-utils')
-rw-r--r--ufs-utils/mkfs.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ufs-utils/mkfs.c b/ufs-utils/mkfs.c
index 1bfce2eb..6d544949 100644
--- a/ufs-utils/mkfs.c
+++ b/ufs-utils/mkfs.c
@@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)mkfs.c 8.3 (Berkeley) 2/3/94";*/
-static char *rcsid = "$Id: mkfs.c,v 1.19 2001/02/26 04:16:18 roland Exp $";
+static char *rcsid = "$Id: mkfs.c,v 1.20 2001/12/02 22:06:54 roland Exp $";
#endif /* not lint */
#include <unistd.h>
@@ -1158,6 +1158,14 @@ fsinit(utime)
node.di_model = IFDIR | UMASK;
node.di_modeh = 0;
node.di_nlink = PREDEFDIR;
+
+ /* Set the uid/gid to non-root if run by a non-root user. This
+ is what mke2fs does in e2fsprogs-1.18 (actually it uses the
+ real IDs iff geteuid()!=0, but that is just wrong). */
+ node.di_uid = geteuid();
+ if (node.di_uid != 0)
+ node.di_gid = getegid();
+
if (Oflag)
node.di_size = makedir((struct directory_entry *)oroot_dir, PREDEFDIR);
else