Re: usb device implemented with functionfs - must app run as root?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 06, 2017 at 07:26:13PM +0100, Krzysztof Opasiak wrote:
> 
> 
> On 12/06/2017 07:26 AM, Greg KH wrote:
> > On Tue, Dec 05, 2017 at 10:09:35PM +0000, andy_purcell@xxxxxxxxxxxx wrote:
> > > I have implemented a USB device using functionfs.
> > > A colleague now says our app must run as a normal user, not as root.
> > > 
> > > I tried it and it does not work.
> > > The problem is this - the endpoint files created by the OS are owned by root.
> > > These ep files are created after I write the descriptors and strings to the /dev/usbffs/ep0 file.
> > > 
> > > $ ls -l /dev/usbffs/
> > > total 0
> > > -rw-rw-rw- 1 xyzuser xyzgrp 0 Dec  5 21:36 ep0
> > > -rw------- 1 root    root   0 Dec  5 21:39 ep1
> > > -rw------- 1 root    root   0 Dec  5 21:39 ep2
> > > -rw------- 1 root    root   0 Dec  5 21:39 ep3
> > > 
> > > A normal user-space app cannot open, write, read, these ep files.
> > > 
> > > Is there a remedy for this?
> > 
> > Write a udev rule to change the owners of those files :)
> > 
> > You must have done that already for the ep0 file, right?
> > 
> 
> FunctionFS is a separate file system not a group of device nodes it's just
> mounted under /dev/usbffs. So technically epX are not device nodes and as
> far as I know (please correct me if I'm wrong) there is no uevent then epX
> is created.

Ah, yeah, you are right, sorry about that, mounting filesystems at
/dev/ always confuses everyone :)

> Can we use udev for a custom files other than device nodes? Isn't it only
> uevent parser?

Yes it is, so no, it will not really work for this, sorry.

> I'm not sure if you use systemd or not but there is a FunctionFS based
> activation and this is how we solve this problem. systemd is running as a
> root and opens all epX files and pass them to the service which then can run
> with lower privileges. Additional benefit is that systemd doesn't close
> those fds so even if your demon crashes whole gadget is not going away, all
> other functions are still usable.

Ah, nice, that should work well.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux