From 6a525069a99787ef3ae1156f12230044b3568f4b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 24 Dec 2001 09:40:00 -0500 Subject: [PATCH] Mke2fs now creates the lost+found directory with 0700 permissions, since files which get dropped into that directory may have come from a protected directory, and the system administrator may not deal with immediately. (Addresses Debian bug #118443) --- lib/ext2fs/ChangeLog | 8 ++++++++ lib/ext2fs/ext2fs.h | 3 ++- lib/ext2fs/initialize.c | 1 + lib/ext2fs/mkdir.c | 2 +- lib/ext2fs/openfs.c | 1 + misc/ChangeLog | 8 ++++++++ misc/mke2fs.c | 3 ++- 7 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 7338ee0..474bd20 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,5 +1,13 @@ 2001-12-24 Theodore Tso + * ext2fs.h, openfs.c (ext2fs_open), initialize.c + (ext2fs_initialize), mkdir.c (ext2fs_mkdir): Add a new + field to struct_ext2_filsys, umask. This field is + initialize to 022, and affects ext2fs_mkdir in the obvious + way. (In the future umask should also affect new file + creation routines, but the fileio functions don't + currently support this yes.) + * ismounted.c (check_mntent_file): Stat all of the entries in /etc/mtab and/or /proc/mounts in order to catch dim-witted system administrators who might have created alias diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 2b23e04..4b594fd 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -214,10 +214,11 @@ struct struct_ext2_filsys { __u32 stride; /* for mke2fs */ struct ext2_super_block * orig_super; struct ext2_image_hdr * image_header; + __u32 umask; /* * Reserved for future expansion */ - __u32 reserved[9]; + __u32 reserved[8]; /* * Reserved for the use of the calling application. diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index 821036e..d8fa228 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -78,6 +78,7 @@ errcode_t ext2fs_initialize(const char *name, int flags, memset(fs, 0, sizeof(struct struct_ext2_filsys)); fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; fs->flags = flags | EXT2_FLAG_RW; + fs->umask = 022; #ifdef WORDS_BIGENDIAN fs->flags |= EXT2_FLAG_SWAP_BYTES; #endif diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c index 15a6863..98f0496 100644 --- a/lib/ext2fs/mkdir.c +++ b/lib/ext2fs/mkdir.c @@ -81,7 +81,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum, * Create the inode structure.... */ memset(&inode, 0, sizeof(struct ext2_inode)); - inode.i_mode = LINUX_S_IFDIR | 0755; + inode.i_mode = LINUX_S_IFDIR | (0777 & ~fs->umask); inode.i_uid = inode.i_gid = 0; inode.i_blocks = fs->blocksize / 512; inode.i_block[0] = blk; diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 96ddf49..f3f849f 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -58,6 +58,7 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, memset(fs, 0, sizeof(struct struct_ext2_filsys)); fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; fs->flags = flags; + fs->umask = 022; retval = manager->open(name, (flags & EXT2_FLAG_RW) ? IO_FLAG_RW : 0, &fs->io); if (retval) diff --git a/misc/ChangeLog b/misc/ChangeLog index f693d61..bcdeefe 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,11 @@ +2001-12-24 Theodore Tso + + * mke2fs.c (create_lost_and_found): The lost+found directory is + now created with 0700 permissions, since files which get + dropped into that directory may have come from a protected + directory, and the system administrator may not deal with + immediately. (Addresses Debian bug #118443) + 2001-12-23 Theodore Tso * Makefile.in, jfs_user.h: Move linux/jbd.h to diff --git a/misc/mke2fs.c b/misc/mke2fs.c index d60e28e..92f3463 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -493,6 +493,7 @@ static void create_lost_and_found(ext2_filsys fs) int i; int lpf_size = 0; + fs->umask = 077; retval = ext2fs_mkdir(fs, EXT2_ROOT_INO, 0, name); if (retval) { com_err("ext2fs_mkdir", retval, @@ -516,7 +517,7 @@ static void create_lost_and_found(ext2_filsys fs) _("while expanding /lost+found")); exit(1); } - } + } } static void create_bad_block_inode(ext2_filsys fs, badblocks_list bb_list) -- 1.8.3.1