On Apr 25, 1:10 am, Shanth Murthy <shanth.murth...@gmail.com> wrote:
> Hi ImperatorRj,
>
> I'm not suppose to change the permissions of sysfs due to security reasons,
> they can only be modified by root user. My Service runs as a system user but
> needs to modify sysfs. is there any way to run my service's sysfs
> modification part as a root user.
>
> thanks,
> shanth
>
> On Fri, Apr 22, 2011 at 8:27 PM, ImperatorRj <raul.a.jime...@gmail.com>wrote:
>
>
>
> > On Apr 20, 8:15 pm, Shanth Murthy <shanth.murth...@gmail.com> wrote:
> > > Hi,
>
> > > I have a question related to Android System Service.
>
> > > I have added system service into Android framework..
>
> > > During the run-time of the system service, it has to modify certain sysfs
> > > parameter exposed by underlying device driver to achieve the required
> > > functionality.
> > > Native method is used to modify the sysfs parameter.
>
> > > Given the fact that, usually sysfs interface parameters are modified by
> > root
> > > user only, and system services don't have root permission. how do we
> > tackle
> > > this problem?
>
> > > Any pointer or suggestions would be highly appreciated.
>
> > > Thanks!
>
> > You could modify the permissions either in init.rc if they are already
> > created or in the driver that creates them by callying a user process
> > with chown.
>
> > --
> > unsubscribe: android-porting+unsubscr...@googlegroups.com
> > website:http://groups.google.com/group/android-porting

As I believe Matthias Kaehlcke was saying you can do it from init by
adding a script or simply adding a line to system/core/rootdir/init.rc
probably under on boot such as "chown system system /sys/foo/bar". If
however as was my case your sysfs node is created by a trigger at run
time then you can use "call_usermodehelper" from the driver to use
chmod/chown

const char *PATH = "/sys/foo/bar"
char *argv[4];// = {"chmod", "system.system", PATH, NULL };
char *envp[] = {"HOME=/", "/sbin:/vendor/bin:/system/sbin:/system/bin:/
system/xbin", NULL };
int ret = call_usermodehelper("/system/bin/toolbox", argv, envp,
UMH_WAIT_PROC)
if (ret != 0) printk("FOO: error in call to usermodehelper: %s, %i\n",
PATH, ret);

Hope it helps. If any one knows of a preferred alternative let us know.

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting

Reply via email to