2

I am using Apps2sd to move some apps to ext4 partition mmcblk1p2. It successfully moved 1 app ( see code below ) but after linking another , the symblink for app gets deleted but data folder's symblink preserved so after boot the apk ( 'disappears' ) . Everything is the same in terms of ownership and security context ( SeLinux ).
I cant dig up anything of interest from dmesg. Why does this happen ? Both apps are User Apps . Both apps have everything possible linked. One App remains 'alive' & the other 'disappears' after boot . SeLinux is Permissive . This is an Android Q Project Treble ROM
I am not using App2sdnative mount script, ( though my ROM has addon.sh support and I tossed App2sdnative mount script in there ) but, Partition mmcblk1p2 which is sdext2 is mounted through my own script . 1 line of thinking ruled out was Partition mmcblk1p2 which is sdext2 is being mounted late enough & before that itself the symlink is considered invalid & gets deleted but that wont explain why the other app survives ?
In the below 'camscanner' is the app that persists after boot and 'BofA' which is bank Of America disappears.

Apk directories

PrKr:/data/sdext2/apk # ls -al /data/app/com.intsig.camscanner-WRx5fzxsezoqL6Gc53H5qg==
total 21760
drwxrwxr-x   3 system system      4096 2020-04-02 10:42 .
drwxrwx--x 114 system system     20480 2020-04-15 08:24 ..
lrwxrwxrwx   1 root   root          72 2020-03-29 17:43 base.apk -> /data/sdext2/apk/com.intsig.camscanner-WRx5fzxsezoqL6Gc53H5qg==/base.apk
lrwxrwxrwx   1 root   root          71 2020-03-29 17:43 lib -> /data/sdext2/app-lib/com.intsig.camscanner-WRx5fzxsezoqL6Gc53H5qg==/lib
drwxrwx--x   3 system install     4096 2020-03-29 17:43 oat
-rw-r--r--   1 system system  22239154 2020-03-29 17:43 split_config.armeabi.apk

PrKr:/data/sdext2/apk # ls -alZ $_
total 21760
drwxrwxr-x   3 system system  u:object_r:apk_data_file:s0             4096 2020-04-02 10:42 .
drwxrwx--x 114 system system  u:object_r:apk_data_file:s0            20480 2020-04-15 08:24 ..
lrwxrwxrwx   1 root   root    u:object_r:mnt_user_file:s0               72 2020-03-29 17:43 base.apk -> /data/sdext2/apk/com.intsig.camscanner-WRx5fzxsezoqL6Gc53H5qg==/ba
se.apk
lrwxrwxrwx   1 root   root    u:object_r:mnt_user_file:s0               71 2020-03-29 17:43 lib -> /data/sdext2/app-lib/com.intsig.camscanner-WRx5fzxsezoqL6Gc53H5qg==/lib

drwxrwx--x   3 system install u:object_r:dalvikcache_data_file:s0     4096 2020-03-29 17:43 oat
-rw-r--r--   1 system system  u:object_r:apk_data_file:s0         22239154 2020-03-29 17:43 split_config.armeabi.apk

and BofAm. This is before reboot. the below link gets deleted after reboot. I am posting the pre-boot scenario for comparison. Nothing to post , after reboot as the link is deleted

130|PrKr:/data/sdext2/apk # ls -al /data/app/com.infonow.bofa-N_WOiCdzw7ZF21E7EtehGQ==
total 40
drwxrwxr-x   3 system system   4096 2020-04-15 08:26 .
drwxrwx--x 114 system system  20480 2020-04-15 08:24 ..
lrwxrwxrwx   1 root   root       67 2020-04-15 08:24 base.apk -> /data/sdext2/apk/com.infonow.bofa-N_WOiCdzw7ZF21E7EtehGQ==/base.apk
lrwxrwxrwx   1 root   root       66 2020-04-15 08:24 lib -> /data/sdext2/app-lib/com.infonow.bofa-N_WOiCdzw7ZF21E7EtehGQ==/lib
drwxrwx--x   3 system install  4096 2020-04-15 08:24 oat

PrKr:/data/sdext2/apk # ls -alZ $_
total 40
drwxrwxr-x   3 system system  u:object_r:apk_data_file:s0          4096 2020-04-15 08:26 .
drwxrwx--x 114 system system  u:object_r:apk_data_file:s0         20480 2020-04-15 08:24 ..
lrwxrwxrwx   1 root   root    u:object_r:mnt_user_file:s0            67 2020-04-15 08:24 base.apk -> /data/sdext2/apk/com.infonow.bofa-N_WOiCdzw7ZF21E7EtehGQ==/base.apk
lrwxrwxrwx   1 root   root    u:object_r:mnt_user_file:s0            66 2020-04-15 08:24 lib -> /data/sdext2/app-lib/com.infonow.bofa-N_WOiCdzw7ZF21E7EtehGQ==/lib
drwxrwx--x   3 system install u:object_r:dalvikcache_data_file:s0  4096 2020-04-15 08:24 oat

Questions

How can I get this to work ?
Also SeLinux being permissive avc denials are just FYI or they are in force ? restorcon and other selinux commands are regardless or matter ?

What I did so far :
--tinkered with various options including putting magisk in global mount space
-- ran a umask command before link re-creation after deleting the original link as mentioned here to make that link RO . Link octals remain the same viz 777
-- restorecon though i dunno why that'd matter if I am running in permissive mode ?


I manage to get some more information from log cat and here it is on pastebin
Update :
Heyya thanks. I put mount scripts in pastebin_2_with_MountScipts with relevant notes on top `` and the earlier pastebin_1_with_logCat has some more info from logcat it sounds like something deleted /data/app/com.infonow.bofa-jnpc8sttz4BVPzQsPK5zw==/base.apk the symblink. What process was it ? after that I can see package manager is complaining and doing clean ups . One thing still unclear. Does SeLinux Context matter in permissive mode ?. TYVM

  • i think you have answered question yourself already. sdext2 is mounted too late, that's a common reason for such behavior (some apps dissapear, some not) – alecxs Apr 17 at 14:37
  • Howdy that seemingly convinces had it not been 1) Another App getting mounted just fine. Everything is the same as I mentioned how come the other one mounts fine ? 2 ) if I link everything except the apk . The other components /data/app/<name>/lib --> /data/sdext2/app-lib/ mounts just fine, which tells me something else is going on. What possibly can explain this differential behavior ? – user1874594 Apr 17 at 16:53
  • also if SeLinux is permissive avc denials ( from dmesg ) are just FYI or they are in force ? – user1874594 Apr 17 at 16:57
  • Updated the question with this info – user1874594 Apr 18 at 3:13
  • ...in permissive mode does context matter. From that lil drop I know of the 'sea' called selinux. If permissive those avc denials are just FYI or contextmatters ? Yes the app does move when it links and the owner & everything is ditto for the app that survives a reboot Vs that whose link is lost.. I will do some more use case testing and revert back and I will also give your loop a try. Thanks AlecXS – user1874594 Apr 18 at 15:12
1

This is example mount script /data/adb/service.d/40sdext2

#!/system/bin/sh
[ -d /data/sdext2 ] && \
until grep -qw /data/sdext2 /proc/mounts
  do
    mount -t ext4 -o rw,nosuid,nodev,noatime /dev/block/mmcblk1p2 /data/sdext2
done &
| improve this answer | |
  • 1
    can be placed in /data/adb/post-fs-data.d or /data/adb/service.d should work in both cases – alecxs Apr 18 at 10:47
  • downvote if not solves your symlink problem – alecxs Apr 18 at 10:52
  • nah... never ever downvote someone's best efforts after all.... w/out efforts there will not be results. tend to avoid using loops in in Su level scripts since they can cause boot loops. I have no complain about my script not being able to mount. does mount but I am not sure if the problem is the mount timing or there is another issue – user1874594 Apr 18 at 13:35
  • 1
    I am less inclined to think about the Mount timing because the same app will link without any issues if I link the data lib odex everything except apk ... the minute I link just apk it will refuse to show up after a reboot – user1874594 Apr 18 at 13:38
  • Ok I got it to work w/ the following modifications. I was running my mount script from /data/adb/modules/<name>/script.sh which actually came from my old phone that I did not bother to change. I took your cue and tossed it in /data/adb/service.d giving it the right chmod's it needed after that I suspected the davik cache must be telling the older location before the move, though, if there's a symblink in there then it should feel nothing changed..so cleared dalvik cache & the apps would reappear with links in place. So Alec - TYVM – user1874594 Apr 21 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.