Whamcloud - gitweb
Mke2fs now creates the lost+found directory with 0700 permissions,
authorTheodore Ts'o <tytso@mit.edu>
Mon, 24 Dec 2001 14:40:00 +0000 (09:40 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 24 Dec 2001 14:40:00 +0000 (09:40 -0500)
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
lib/ext2fs/ext2fs.h
lib/ext2fs/initialize.c
lib/ext2fs/mkdir.c
lib/ext2fs/openfs.c
misc/ChangeLog
misc/mke2fs.c

index 7338ee0..474bd20 100644 (file)
@@ -1,5 +1,13 @@
 2001-12-24  Theodore Tso  <tytso@valinux.com>
 
+       * 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
index 2b23e04..4b594fd 100644 (file)
@@ -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.
index 821036e..d8fa228 100644 (file)
@@ -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
index 15a6863..98f0496 100644 (file)
@@ -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;
index 96ddf49..f3f849f 100644 (file)
@@ -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)
index f693d61..bcdeefe 100644 (file)
@@ -1,3 +1,11 @@
+2001-12-24  Theodore Tso  <tytso@valinux.com>
+
+       * 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  <tytso@valinux.com>
 
        * Makefile.in, jfs_user.h: Move linux/jbd.h to
index d60e28e..92f3463 100644 (file)
@@ -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)