Bug 11652 - mkfs.ext4 changes folder permissions when creating image
Summary: mkfs.ext4 changes folder permissions when creating image
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 2.1.2
Hardware: Other Multiple
: Medium+ normal
Target Milestone: 2.4 M4
Assignee: Robert Yang
QA Contact:
URL:
Whiteboard: Backport to 2.3.1 & 2.2.2
Depends on:
Blocks:
 
Reported: 2017-06-13 10:04 UTC by Alessio Moscatello
Modified: 2017-09-21 01:37 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alessio Moscatello 2017-06-13 10:04:01 UTC
I'm using Yocto 2.1.1 and I've noticed that files/folders permissions are changed when creating ext4 image.

Steps to reproduce:
1) in pkg_postinst task set wanted file permissions:
---> chmod -R 521 "$D/opt/my_folder"
2) generate the rootfs image

Results:
1)my_folder has correct permissions on rootfs: I can verify it from devshell (so pseudo is correctly handling them)
2)my_folder has correct permissions in rootfs archive
3)my_folder hasn't correct permissions on rootfs ext4 image -> permissions are changed to 751


I think that the cause is in mkfs itself

see line 119 on https://github.com/tytso/e2fsprogs/blob/master/misc/create_inode.c

    inode.i_mode |= st->st_mode;


I've also opened a discussion on e2fsprogs:
https://sourceforge.net/p/e2fsprogs/discussion/7053/thread/33e8a603/#a89f


I'd like to have a feedback from Yocto community to understand if this a bug or rather a misconfiguration of my set up. Can anyone reproduce this issue?

Thanks,
Alessio
Comment 1 Alessio Moscatello 2017-06-14 07:25:17 UTC
Just an update: I've cross-checked and only folder permissions are wrong, file are correct.
It seems that mkfs.ext4 forces rwx for user permission on folders and that permissions for group and other is the one specified in the recipe.
Comment 2 Alessio Moscatello 2017-06-27 10:03:46 UTC
Hello,
I've found the rootcause in lib/ext2fs/mkdir.c, function ext2fs_mkdir:
inode for folder is being created using a default umask

 inode.i_mode = LINUX_S_IFDIR | (0777 & ~fs->umask);

this is ok when creating a filesystem from scratch, but causes permission changes when creating an image starting from a folder.

I've a quick patch to fix the issue, but I think that the best solution is to add a parameter to mkfs in order to select if using or not the default umask when using -d option as well.

BR,
Alessio