TeamWin / Team-Win-Recovery-Project

Core recovery files for the Team Win Recovery Project (T.W.R.P) - this is not up to date, please see https://github.com/TeamWin/android_bootable_recovery/
http://twrp.me
1.96k stars 741 forks source link

3.0.2-0 In backups some files not assigned to the correct user and group. #749

Open vortex-5 opened 8 years ago

vortex-5 commented 8 years ago

Edit: I figured out the bug the problem is TWRP during nandroid backup sets the owner and group of boot.emmc.win to root:root instead of all other files of the backup being set to media_rw:media_rw potentially this is a bug with the backup script.


After generating a recovery in with /data/ formatted to F2FS when the system is booted normally into the OS (android 6.0.1) the user is unable to copy date for /sdcard/TWRP/BACKUPS

MTP mounting will fail with an unknown error.

ADB will get a permission denied on boot.emmc when trying to pull. (Other files pull correctly)

adb: error: failed to copy '/sdcard/TWRP/BACKUPS/016B7EB20600300F/2016-08-24--11-29-03_cm_maguro-userdebug_6.0.1_MOB30Z_502ef2473a/boot.emmc.win' to 'D:\Downloads\BACKUPS\016B7EB20600300F\2016-08-24--11-29-03_cm_maguro-userdebug_6.0.1_MOB30Z_502ef2473a\boot.emmc.win': Permission denied

GitteHuber commented 8 years ago

Same bug on my maguro, all my partitions are formatted to ext4/ROM standard. (I'm not using f2fs.) After a successful nandroid backup boot.emmc.win and efs.emmc.win can't be copied. (system.ext4.win, data.ext4.win, logs and hashfiles are just fine).

crazymanjinn commented 8 years ago

Seeing this same issue using TWRP 3.0.2.2 on Nexus 6P.

/sdcard/TWRP/BACKUPS/8XV7N15B06000229/2016-09-21--00-46-33_MTC19T # ls -al
__bionic_open_tzdata: couldn't find any tzdata when looking for GMT!
drwxrwxrwx    2 media_rw media_rw      4096 Sep 21 04:50 .
drwxrwxrwx    3 media_rw media_rw      4096 Sep 21 04:46 ..
-rw-------    1 root     root      33554432 Sep 21 04:50 boot.emmc.win
-rw-rw-r--    1 media_rw media_rw 1675536384 Sep 21 04:48 data.ext4.win000
-rw-rw-r--    1 media_rw media_rw 1659289088 Sep 21 04:48 data.ext4.win001
-rw-rw-r--    1 media_rw media_rw 1611045376 Sep 21 04:49 data.ext4.win002
-rw-rw-r--    1 media_rw media_rw 1598832128 Sep 21 04:50 data.ext4.win003
-rw-rw-r--    1 media_rw media_rw 1608135680 Sep 21 04:50 data.ext4.win004
-rw-rw-r--    1 media_rw media_rw        66 Sep 21 04:50 data.info
-rw-rw-r--    1 media_rw media_rw   6025105 Sep 21 04:50 recovery.log
-rw-rw-r--    1 media_rw media_rw 1563212288 Sep 21 04:46 system.ext4.win000
-rw-rw-r--    1 media_rw media_rw 374734350 Sep 21 04:47 system.ext4.win001
-rw-rw-r--    1 media_rw media_rw        65 Sep 21 04:47 system.info

SD card is formatted with ext4 not F2FS:

/sdcard/TWRP/BACKUPS/8XV7N15B06000229/2016-09-21--00-46-33_MTC19T # mount
/dev/block/mmcblk0p44 on /sdcard type ext4 (rw,seclabel,relatime,data=ordered)
mddvul22 commented 7 years ago

I apologize if I should be opening a different bug report. But this looks similar to my problem. But it looks more complicated in my case. I'm using 3.0.2-1 (for the nexus 9). In my case, permissions "look" good for boot.emmc.win. However, root can't read the file. And therefore, rsync can't copy it. The other files in the backup directory are all readable and rsyncable:

flounder:/storage/emulated/0/TWRP/BACKUPS/HT5B3JT00007/2016-11-19--07-03-34_aosp_flounder-userdebug_7.0_NRD91D_eng.root # whoami root

flounder:/storage/emulated/0/TWRP/BACKUPS/HT5B3JT00007/2016-11-19--07-03-34_aosp_flounder-userdebug_7.0_NRD91D_eng.root # ls -la boot.emmc.win -rw-rw---- 1 root sdcard_rw 33554432 2016-11-19 07:03 boot.emmc.win

flounder:/storage/emulated/0/TWRP/BACKUPS/HT5B3JT00007/2016-11-19--07-03-34_aosp_flounder-userdebug_7.0_NRD91D_eng.root # cat boot.emmc.win sh: cat: boot.emmc.win: Permission denied

1|flounder:/storage/emulated/0/TWRP/BACKUPS/HT5B3JT00007/2016-11-19--07-03-34_aosp_flounder-userdebug_7.0_NRD91D_eng.root # whoami root

flounder:/storage/emulated/0/TWRP/BACKUPS/HT5B3JT00007/2016-11-19--07-03-34_aosp_flounder-userdebug_7.0_NRD91D_eng.root #

nailyk-fr commented 7 years ago

@78c59635bdd8 Can you please post the output of '_ls -lZ /data/media/0/TWRP/BACKUPS/HT5B3JT00007/2016-11-19--07-03-34_aosp_flounder-userdebug_7.0_NRD91Deng.root' and 'mount | grep "/data" ' ? It could be the same issue but with selinux enforcement.

mddvul22 commented 7 years ago

Interesting. Thanks. I see different ownership when I do that:

flounder:/ # ls -lZ /data/media/0/TWRP/BACKUPS/HT5B3JT00007/2016-11-19--07-03-34_aosp_flounder-userdebug_7.0_NRD91D_eng.root
total 4372824 -rw------- 1 root root u:object_r:media_rw_data_file:s0 33554432 2016-11-19 07:03 boot.emmc.win -rw-rw-r-- 1 media_rw media_rw u:object_r:media_rw_data_file:s0 48 2016-11-19 07:03 boot.emmc.win.md5 -rw-rw-r-- 1 media_rw media_rw u:object_r:media_rw_data_file:s0 1377361920 2016-11-19 07:06 data.f2fs.win -rw-rw-r-- 1 media_rw media_rw u:object_r:media_rw_data_file:s0 48 2016-11-19 07:07 data.f2fs.win.md5 -rw-rw-r-- 1 media_rw media_rw u:object_r:media_rw_data_file:s0 65 2016-11-19 07:06 data.info -rw-rw-r-- 1 media_rw media_rw u:object_r:media_rw_data_file:s0 1084520 2016-11-19 07:07 recovery.log -rw-rw-r-- 1 media_rw media_rw u:object_r:media_rw_data_file:s0 824603136 2016-11-19 07:04 system.ext4.win -rw-rw-r-- 1 media_rw media_rw u:object_r:media_rw_data_file:s0 50 2016-11-19 07:04 system.ext4.win.md5 -rw-rw-r-- 1 media_rw media_rw u:object_r:media_rw_data_file:s0 64 2016-11-19 07:04 system.info flounder:/ #

flounder:/ # mount | grep "/data" /dev/block/dm-0 on /data type f2fs (rw,seclabel,nosuid,nodev,noatime,background_gc=on,discard,user_xattr,acl,errors=panic) flounder:/ #

nailyk-fr commented 7 years ago

You are on f2fs storage with extended attributes. Ownership are forced by fuser into /storage/emulated/0. As the file is 600 root acces is refused into /storage. Root is still able to access the file into the original mount point /data/media (/mnt/media_rw/ for extsd):

nailyk@nailyk :) % adb root                                                                                                                                                                                                                                               /tmp
restarting adbd as root
nailyk@nailyk :) % adb pull /storage/f0bf3380-ec86-4e0f-bd26-abf7adc6057b/TWRP/BACKUPS/CB5A218U9A/2016-10-29_cm_z3-userdebug_7.0_NBD90Z_324c7cf4f2_test-/TA.emmc.win ./                                                                                                   /tmp
failed to copy '/storage/f0bf3380-ec86-4e0f-bd26-abf7adc6057b/TWRP/BACKUPS/CB5A218U9A/2016-10-29_cm_z3-userdebug_7.0_NBD90Z_324c7cf4f2_test-/TA.emmc.win' to './/TA.emmc.win': open failed: Permission denied
nailyk@nailyk 141 :( % adb pull /mnt/media_rw/f0bf3380-ec86-4e0f-bd26-abf7adc6057b/TWRP/BACKUPS/CB5A218U9A/2016-10-29_cm_z3-userdebug_7.0_NBD90Z_324c7cf4f2_test-/TA.emmc.win                                                                                             /tmp
1885 KB/s (2097152 bytes in 1.086s)

The pending patch should solve this issue. Thanks for reporting.

mddvul22 commented 7 years ago

@nailyk-fr -- I see this patch is in Omnirom's code base. So, does this mean that this is something that must be fixed at the ROM level? As opposed to fixing it in TWRP?

Thanks.

nailyk-fr commented 7 years ago

It is a twrp issue but twrp is part of omni afaik. If you are on official builds (downloaded through twrp.me) you need to wait for the patch to be merged, then a new build. If you are on unofficial you can ask your maintainer to build again with a cherry-pick of this commit.

nailyk-fr commented 7 years ago

Since the rebuild of 3.1 for everyone this is fixed ;)