FORUMS
Remove All Ads from XDA
Honor 9 Lite

Patching Sepolicy with Supolicy Tool, modifed file not produced.

641 posts
Thanks Meter: 289
 
Post Reply Email Thread
I am in the position of having to manually apply the defult sepolicy patch, init,?*init_shell?* and?*recovery?*permissive, and as the title states when using the supolicy tool to modify my supplieded sepolicy it is not being produced and on closer inspection throwing an error. I have attached both the images and the sepolicy file I am trying to applie these change to.

Have I been doing something wrong or is the file corrupted??

If you need more info just ask

Note: when I first tried it inside an adb shell it reported a segumentation fault, but I was unable to reproduce that condition to be provided with as a screen shot.

Click image for larger version

Name:	Screenshot_4.jpg
Views:	1056
Size:	138.6 KB
ID:	3877025

Click image for larger version

Name:	Screenshot_5.jpg
Views:	1012
Size:	119.2 KB
ID:	3877026

EDIT: I at least can say that the possibility of a corrupt file is now smaller becuse I am able to run dumpav and dump its contents to a txt file and then do afb pull back to pc. So amyone know any way to applie the defult P atchs needed to sysyemless root?
Attached Files
File Type: zip sepolicy.zip - [Click for QR Code] (107.9 KB, 516 views)
 
 
18th September 2016, 08:07 AM |#2  
Matt07211's Avatar
OP Senior Member
Thanks Meter: 289
 
More
@Chainfire Since this is your binary files, you should know the most about it.

Commands to gain application root on emulator

Code:
adb shell df           #Check Available Space
adb shell mount -o remount,rw /system
adb push su /system/bin/su
adb shell chmod 0755 /system/bin/su
adb push su /system/xbin/su
adb shell chmod 0755 /system/xbin/su
adb shell su --install
adb shell "su --daemon&"
adb install superuser.apk
adb install rootcheck.apk
I then proceed to patch the sepolicy file with the following commands

Code:
adb push sepolicy /data/local/tmp/sepolicy 
adb shell su -c "supolicy --file /data/local/tmp/sepolicy /data/local/tmp/sepolicy_out"   #There is no sepolicy_out file
adb shell su -c "chmod 0644 /data/local/tmp/sepolicy_out" 
adb pull /data/local/tmp/sepolicy_out sepolicy_out
So what am I able to do?
Are you able to
A) Help me debug the problem
Or
B) Patch the sepolicy file and post the output back to me/here
19th September 2016, 08:26 AM |#3  
Chainfire's Avatar
Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 86,422
 
Donate to Me
More
Quote:
Originally Posted by Matt07211

...

Works fine on my device... could be an x86 specific issue? Unfortunately I don't have any x86 devices to test with.
Attached Files
File Type: zip sepolicy_out.zip - [Click for QR Code] (140.8 KB, 218 views)
The Following 2 Users Say Thank You to Chainfire For This Useful Post: [ View ]
19th September 2016, 09:27 AM |#4  
Matt07211's Avatar
OP Senior Member
Thanks Meter: 289
 
More
Thanks for that. Yes, I am trying to patch the policy for my armv8 (arm64) cpu device (just realised, but would trying to patch the sepolicy from one architecture using the supolicy for a different architecture have new the problem?, if so I feel dumb). And since I didn't have a spare device devce that met the requirements, I resorted to use the already setup emulator in my Windows installation.
I had proceeded to root and run the supolicy tool for which nothing out-putted (tried different directorys), I then created a new sub-directory, test, in /data/local/tmp and chmod it with read and write permissions. I tried again and failed, I then ran a dumpav in the sepolicy I was trying to patch and outputted it to /data/local/tmp/test/dumpav.txt which worked.

I am just wondering why it didn't work for me .

Thanks again for the sepolic_out file, I really do apperciate it.
19th September 2016, 11:17 AM |#5  
Chainfire's Avatar
Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 86,422
 
Donate to Me
More
Ah you're saying the segmentation fault occurred on the emulator? That's interesting. Might be reproducable on my end.
19th September 2016, 12:16 PM |#6  
Matt07211's Avatar
OP Senior Member
Thanks Meter: 289
 
More
Note: look at my first image with cms in the foreground and near the bottom of the command window you should see the segfault message, around second last command or so.

To reproduce that segfault (hopefully):
1) https://software.intel.com/en-us/and...r-system-image Download the system image from here (had to direct download instead of sdk as internet was running through profile and ask wouldn't work through it)

2) used the 2.78 SuperSu zip and run above commands to gain root

3) run above commands to try and modify sepolicy (it doesn't produce anything)

4) start an adb shell and then run the commands inside the shell. Know the outputs shown was segfault the first time running the commands, every time afterwards it would show the error in the above screenshots

If you figure out what cause the segfault can you please tell me ?
19th September 2016, 03:01 PM |#7  
Chainfire's Avatar
Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 86,422
 
Donate to Me
More
Quote:
Originally Posted by Matt07211

Note: look at my first image with cms in the foreground and near the bottom of the command window you should see the segfault message, around second last command or so.

To reproduce that segfault (hopefully):
1) https://software.intel.com/en-us/and...r-system-image Download the system image from here (had to direct download instead of sdk as internet was running through profile and ask wouldn't work through it)

2) used the 2.78 SuperSu zip and run above commands to gain root

3) run above commands to try and modify sepolicy (it doesn't produce anything)

4) start an adb shell and then run the commands inside the shell. Know the outputs shown was segfault the first time running the commands, every time afterwards it would show the error in the above screenshots

If you figure out what cause the segfault can you please tell me ?

Before I go do all this, can you make sure the issue persists with the v2.78 SR1 version from the BETA thread ? Some issues with supolicy were fixed in that release.
19th September 2016, 03:46 PM |#8  
Matt07211's Avatar
OP Senior Member
Thanks Meter: 289
 
More
Started with a fresh emulator and the newest SuperSu and ran these commands to gain root (I am placing everything as described in update-binary in the right places just to eliminate one thing, missing dependencies)

Code:
adb shell df 
adb shell mount -o remount,rw /system
adb push Superuser.apk /system/app/Superuser.apk
adb shell chmod 0644 /system/app/Superuser.apk 
adb push install-recovery.sh /system/etc/install-recovery.sh 
adb shell ln -s /system/etc/install-recovery.sh /system/bin/install-recovery.sh 
adb shell chmod 0755 /system/etc/install-recovery.sh 
adb push su /system/xbin/su 
adb shell chmod 0755 /system/xbin/su 
adb push su /system/bin/.ext/.su 
adb shell chmod 0755 /system/bin/.ext/.su 
adb push su /system/xbin/daemonsu 
adb shell chmod 0755 /system/xbin/daemonsu 
adb push su /system/xbin/sugote 
adb shell chmod 0755 /system/xbin/sugote 
adb push supolicy /system/xbin/supolicy 
adb shell chmod 0755 /system/xbin/supolicy
adb push libsupol.so /system/lib/libsupol.so 
adb shell chmod 0644 /system/lib/libsupol.so 
adb push 99SuperSUDaemon /system/etc/init.d/99SuperSUDaemon 
adb shell chmod 0755 /system/etc/init.d/99SuperSUDaemon 
adb shell su --install 
adb shell "su --daemon&" 
adb install superuser.apk 
adb install rootcheck.apk
No everything should be in place, and we now can eliminate one thing (supolicy not finding needed dependencies)

Opened up SuperSu and let it install/update binary (succesful)

I then proceeded to patch the sepolicy file like so

Code:
adb push sepolicy /data/local/tmp/sepolicy
adb shell su -c "supolicy --file /data/local/tmp/sepolicy /data/local/tmp/sepolicy_out"
I then did "ls" in the directory and no file out-putted. So I went into a shell and ran

Code:
supolicy --file /data/local/tmp/sepolicy /data/local/tmp/sepolicy_out
And it throw the error shown in the image below. First time running that command in shell it says stopped, but the second time it says stopped as well as segfault.

Keep in mind I am trying to patch a sepolicy file that originates from an armv8 cpu (arm64) on an x86 Intel emulator.

Any more info needed? I am happy to help @Chainfire
Attached Thumbnails
Click image for larger version

Name:	20160919_234505.jpg
Views:	220
Size:	266.3 KB
ID:	3879981  
19th September 2016, 06:33 PM |#9  
Chainfire's Avatar
Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 86,422
 
Donate to Me
More
So, I think it has something to do with your emulator image (perhaps its too old ?)

I took SuperSU's ZIP file and extracted it, changed to that folder, then:

(note that my adb shell to my emulator image has # root by default)

Code:
adb push c:\download\sepolicy /data/local/tmp/sepolicy
adb push x86\. /data/local/tmp/.

adb shell
cd /data/local/tmp
chmod 0755 supolicy
LD_LIBRARY_PATH=/data/local/tmp:$LD_LIBRARY_PATH ./supolicy --file sepolicy sepolicy_out
exit
Resulting in:

Code:
supolicy v2.78 (ndk:x86) - Copyright (C) 2014-2016 - Chainfire

Patching policy [sepolicy] --> [sepolicy_out] ...
- Success
So, I'm really not sure what might be going on with your setup, but I don't think its SuperSU itself, but rather the emulator.

Note that to use supolicy --file, you only need supolicy and libsupol.so, you don't even need root.
The Following User Says Thank You to Chainfire For This Useful Post: [ View ]
19th September 2016, 10:58 PM |#10  
Matt07211's Avatar
OP Senior Member
Thanks Meter: 289
 
More
Quote:
Originally Posted by Chainfire

So, I think it has something to do with your emulator image (perhaps its too old ?)

I took SuperSU's ZIP file and extracted it, changed to that folder, then:

(note that my adb shell to my emulator image has # root by default)



Resulting in:



So, I'm really not sure what might be going on with your setup, but I don't think its SuperSU itself, but rather the emulator.

Note that to use supolicy --file, you only need supolicy and libsupol.so, you don't even need root.

Hmm, I really don't know what is wrong, I will try exactly what you have done later today, to see If can reproduce the output. If it doesn't work then we can pin it down to the emulator itself. What emulator image did you use?

I also realise that so emulator are rooted in the sense that web shell has root acess, just wasn't sure what dependices supolicy had at the time.
19th September 2016, 11:49 PM |#11  
Chainfire's Avatar
Senior Moderator / Senior Recognized Developer - Where is my shirt?
Thanks Meter: 86,422
 
Donate to Me
More
Quote:
Originally Posted by Matt07211

Hmm, I really don't know what is wrong, I will try exactly what you have done later today, to see If can reproduce the output. If it doesn't work then we can pin it down to the emulator itself. What emulator image did you use?

I also realise that so emulator are rooted in the sense that web shell has root acess, just wasn't sure what dependices supolicy had at the time.

I created an API 22 Google Nexus x86_64 AVD in Android Studio
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes