Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,740,667 Members 49,396 Now Online
XDA Developers Android and Mobile Development Forum

Build Android from Source with Superuser privileges

Tip us?
 
rotowsky
Old
(Last edited by rotowsky; 24th May 2014 at 10:02 PM.) Reason: Resolved
#1  
Junior Member - OP
Thanks Meter 0
Posts: 5
Join Date: May 2014
Smile Build Android from Source with Superuser privileges

Hello together,

following situation - I have got a Single Board Computer with Android support and the android source code from the manufacturer. It works to build an android image from it at all. Unfortunately, it's not rooted by default. I could manage to get a rooted shell. But I also need superuser privileges for the apps and that's the point where I am struggeling.

At first I tried to comment out following lines from system/extras/su/su.c:

Code:
Select Code
//if (myuid != AID_ROOT && myuid != AID_SHELL) {
//    fprintf(stderr,"su: uid %d not allowed to su\n", myuid);
//    return 1;
//}

//if(setgid(gid) || setuid(uid)) {
//    fprintf(stderr,"su: permission denied\n");
//    return 1;
//}
As this didn't work, I found a thread on stackoverflow and tried this part of the suggestion:

Quote:
> To embed Superuser.apk in AOSP, you have to fetch and build:

> su-binary (e.g. in external/) and stub/remove system/extras/su package.
> Superuser (e.g. in packages/app/)
But I am running in errors while building android:

Code:
Select Code
    ctarget Dex: core-tests-hostdex
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/su.o: in function deny:external/su-binary-master/su.c:287: error: undefined reference to 'LOGW'
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/su.o: in function allow:external/su-binary-master/su.c:319: error: undefined reference to 'LOGE'
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/su.o: in function allow:external/su-binary-master/su.c:330: error: undefined reference to 'LOGE'
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/su.o: in function allow:external/su-binary-master/su.c:338: error: undefined reference to 'LOGD'
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/su.o: in function allow:external/su-binary-master/su.c:352: error: undefined reference to 'LOGE'
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/su.o: in function main:external/su-binary-master/su.c:440: error: undefined reference to 'LOGE'
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/su.o: in function main:external/su-binary-master/su.c:582: error: undefined reference to 'LOGW'
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/db.o: in function database_check:external/su-binary-master/db.c:31: error: undefined reference to 'LOGD'
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/db.o: in function database_check:external/su-binary-master/db.c:35: error: undefined reference to 'LOGD'
../arm-linux-androideabi/bin/ld: out/target/product/.../obj/EXECUTABLES/su_intermediates/db.o: in function database_check:external/su-binary-master/db.c:39: error: undefined reference to 'LOGD'
collect2: ld returned 1 exit status
make: *** [out/target/product/.../obj/EXECUTABLES/su_intermediates/LINKED/su] Error 1
Could anyone tell me how to fix this error or another way to get su privileges, please?

Thank you very much in advance.
 
philos64
Old
(Last edited by philos64; 24th May 2014 at 04:42 PM.)
#2  
philos64's Avatar
Recognized Contributor
Thanks Meter 2640
Posts: 3,394
Join Date: May 2010
Location: Somewhere between sky and sea in Brittany - XDA Assist Place

 
DONATE TO ME
Have you seen that we have a University for Development on xda. I think that your post had a better place on this forum than here.

So goto see here : General discussion > XDA-University


...and don't forget to search before to post

If you want to move your post, contact a mod by the "report button"

XDA Assist is the place where you can get help finding your way on XDA. This is not a support forum !!!
Click and go to XDA-Assist
DONT PM ME FOR QUESTIONS RELATED TO ROM, Ask in thread, it's better for all members- THANKS

Actual Devices : HTC One M8 - HTC One M7 //Google N7 Wifi - Google N7 2013 LTE
Retired Devices :HTC Hero-HTC Desire Z-HTC Desire S-HTC One X- N7 3G - Asus TF300T


 
rotowsky
Old
(Last edited by rotowsky; 24th May 2014 at 04:51 PM.) Reason: typo
#3  
Junior Member - OP
Thanks Meter 0
Posts: 5
Join Date: May 2014
Hi philos,

thank you for your answer. I tried to post the thread there at first, but I got following message:

Quote:
This is not a Q&A forum. By posting questions in this forum you are breaking the forum rules. Please only post questions in the Q&A forums.
I tried to find an already existing thread for this topic, but I couldn't find something helpful.
 
rotowsky
Old
#4  
Junior Member - OP
Thanks Meter 0
Posts: 5
Join Date: May 2014
Okay, I found the problem. For anyone who faces the same problem.

su.h

Remove the following if command:

#if 0
#undef LOGE
#define LOGE(fmt,args...) fprintf(stderr, fmt, ##args)
#undef LOGD
#define LOGD(fmt,args...) fprintf(stderr, fmt, ##args)
#undef LOGW
#define LOGW(fmt,args...) fprintf(stderr, fmt, ##args)
#endif
 
philos64
Old
#5  
philos64's Avatar
Recognized Contributor
Thanks Meter 2640
Posts: 3,394
Join Date: May 2010
Location: Somewhere between sky and sea in Brittany - XDA Assist Place

 
DONATE TO ME
Souds good
If it's good for you and your problem resolved, can you add on the title of your OP.
Thanks in advance

XDA Assist is the place where you can get help finding your way on XDA. This is not a support forum !!!
Click and go to XDA-Assist
DONT PM ME FOR QUESTIONS RELATED TO ROM, Ask in thread, it's better for all members- THANKS

Actual Devices : HTC One M8 - HTC One M7 //Google N7 Wifi - Google N7 2013 LTE
Retired Devices :HTC Hero-HTC Desire Z-HTC Desire S-HTC One X- N7 3G - Asus TF300T


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes