root permissions to android NDK

1,098 views
Skip to first unread message

sahil

unread,
Nov 1, 2010, 1:52:23 PM11/1/10
to android-ndk
Hi,

I have an NDK application that makes call to my system call in which I
set priority of processes to real time (making a call to
sched_setscheduler in my system call). If I run a C program that makes
a call to this system call via the adb shell in superuser mode, the C
program runs fine.

I created a NDK application for the same purpose and when I run the
NDK app I get an error when my system call makes a call to
sched_setscheduler. The problem is process does not have appropriate
privileges (EPERM).

Call to sched_setscheduler looks like:
struct sched_param sp;
int rtprio; (given a value >0 and <= 99)
.
.
sp.sched_priority = rtprio;
sched_setscheduler(task, SCHED_FIFO, &sp);

we have tried varied values like 1, 14, 15 and 99. given that the
value of RLIMIT_RTPRIO is 14.

What possibly could be done to handle this problem? The first thing I
tried is to move the app from /data/app folder to /system/app folder,
but it did not work.

We have a rooted droid phone and running android 2.0.1.

Thanks
Sahil


Dianne Hackborn

unread,
Nov 1, 2010, 7:57:45 PM11/1/10
to andro...@googlegroups.com
Sorry, applications can't get root on a regular production Android device.



--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Chris Stratton

unread,
Nov 1, 2010, 11:54:08 PM11/1/10
to android-ndk
On Nov 1, 7:57 pm, Dianne Hackborn <hack...@android.com> wrote:

> Sorry, applications can't get root on a regular production Android device.

> > We have a rooted droid phone and running android 2.0.1.

Which is not what the OP has.

Sahil, you will have to look into the details of whatever mechanism
("su", setuid bit, etc) is used for launching a root process on your
particular modified rom.

sahil khurana

unread,
Nov 2, 2010, 12:00:55 AM11/2/10
to andro...@googlegroups.com
Thanks Chris, Dianne,

I found a workaround for it. I by-passed a check (check_from_same_owner) with-in the kernel that was not allowing me to set the real time priority.
I had to do it for a particular process so I used my own mechanism for that.

Though, it is still a workaround!

Thanks.
Sahil


--

Mark Meisner

unread,
Nov 28, 2011, 10:54:03 PM11/28/11
to andro...@googlegroups.com
What if it's not a regular production device?   I have a Beagleboard running Gingerbread.  I have the Linux spidev driver enabled and all the pinmuxing done correctly.  I am trying to access the driver (/dev/spidev1.1) through NDK using open/close/read/write/ioctl calls; so far without luck.  I think it is a permission issue but don't know where to begin to fix it.  I have the ability to change and rebuild anything in the kernel, bootloader, or filesystem.  Tips would be greatly appreciated.

David Turner

unread,
Nov 29, 2011, 11:41:14 AM11/29/11
to andro...@googlegroups.com
On Tue, Nov 29, 2011 at 4:54 AM, Mark Meisner <mmeis...@gmail.com> wrote:
What if it's not a regular production device?   I have a Beagleboard running Gingerbread.  I have the Linux spidev driver enabled and all the pinmuxing done correctly.  I am trying to access the driver (/dev/spidev1.1) through NDK using open/close/read/write/ioctl calls; so far without luck.  I think it is a permission issue but don't know where to begin to fix it.  I have the ability to change and rebuild anything in the kernel, bootloader, or filesystem.  Tips would be greatly appreciated.

I'd recommend writing a system service that gets started on boot through init.<hardware>.rc and that has the right user/group to access the /dev/<device> file, and eventually provide an application-accessible interface to it (e.g. through a Unix domain socket, which allows you to check the peer credential through SOL_PEERCRED, to ensure that your service is talking to exactly the right application, and not some random malware that scan all open ports on the system).

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/YDsinHJOmeIJ.
Reply all
Reply to author
Forward
0 new messages