How to chmod an executable (apply commands after building)?

331 views
Skip to first unread message

ruediger

unread,
Mar 22, 2011, 10:23:23 AM3/22/11
to Android Building
I will have to apply special access rights to a Linux executable that
I added to the build system.
How can I add a command such as chmod to the executable's Android.mk
to be executed by the build system after the executable has been
built?
thanks!

John Michelau

unread,
Mar 22, 2011, 3:29:20 PM3/22/11
to Android Building
You can run chmod from your product init file: init.<product>.rc. It
should be under vendor/<vendor>/<product>/init.<product>.rc. Please
note that after you make this change, you've modified the ramdisk
which is part of the boot.img, so that's what you need to reflash to
test it.

Ex:
chmod 640 /dev/ttyHS3

ruediger

unread,
Mar 23, 2011, 3:50:47 AM3/23/11
to Android Building
good idea, that should solve my current problem
thank you

anyhow, if someone knows a method supported by the build system to
start a command after building I still would be interested to know

John Michelau

unread,
Mar 23, 2011, 9:42:40 PM3/23/11
to Android Building
Lastly, if you want this to be part of the build itself, you can
probably automate mounting your file system onto your build machine
and doing the modes that way. The actual method depends on whether
your system image is yaffs, ext4, etc. For yaffs, you can get unyaffs
for unpacking it, and then repack it with mkyaffs2image. For ext4,
you can just mount it directly in Linux and modify it.

These are all just hacks though. There must be a better way.

John Michelau

unread,
Mar 23, 2011, 9:38:50 PM3/23/11
to Android Building
Another way is to modify system/core/include/private/
android_filesystem_config.h and add your executable and permissions to
the android_files[] array.

Ex below for setuid root:
{ 04770, AID_ROOT, AID_RADIO, "system/bin/pppd-ril" },

On Mar 23, 2:50 am, ruediger <ruediger.b...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages