Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Sep 2014 14:38:23 +0900
From:      "Lundberg, Johannes" <johannes@brilliantservice.co.jp>
To:        Hans Petter Selasky <hps@selasky.org>
Cc:        "freebsd-usb@freebsd.org" <freebsd-usb@freebsd.org>
Subject:   Re: libusb and non-root access problem
Message-ID:  <CAASDrVmNZ8ejS-794iNU_GTxiw-t=7xXs=FteKcS5RumeW-iJQ@mail.gmail.com>
In-Reply-To: <54144E00.4080100@selasky.org>
References:  <CAASDrVn4eQXG7z11OE3ydyZGMaq-9rjCZqyv655SkZ%2BgKffeUg@mail.gmail.com> <54144E00.4080100@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks Hans for prompt reply, as always.

I reverse engineered a driver by sniffing USB traffic. The first two things
this driver did was SET_CONFIG and SET_INTERFACE.  My implementation worked
fine under Linux but stumbled onto this (permission) problem on FreeBSD.

However, it seems to work fine if I skip the SET_CONFIG and SET_INTERFACE
calls so I can use my driver as normal user.

Thanks!

On Sat, Sep 13, 2014 at 11:00 PM, Hans Petter Selasky <hps@selasky.org>
wrote:

> On 09/13/14 14:04, Lundberg, Johannes wrote:
>
>> Hi
>>
>> I tried now for hours but no luck with this.. I have a special usb devic=
e
>> to which I connect with libusb. Everything works find as root but I can
>> seem to be able to access with normal user no matter how I configure
>> devfs.
>>
>> I changed both conf and rules and even set myself as owner and group and
>> 777 permission to /dev/ugen* /dev/usb and /dev/usb/* but no luck...
>>
>> I can connect to the device and claim interface but then it fails at the
>> first libusb_control_transfer with error -4
>>
>> I have done this before without problems. I am running the newest
>> 11-CURRENT snapshot so could there be any bug that causes this or has
>> anything changed in configurations?
>>
>> Grateful for any advice...
>> --
>> Johannes Lundberg
>>
>>
> Hi,
>
> You only need to "chmod /dev/usb/X.Y.0" .
>
> Some control transfers are always restricted to root user:
>
>         /*
>          * Avoid requests that would damage the bus integrity:
>          */
>         if (((req->bmRequestType =3D=3D UT_WRITE_DEVICE) &&
>             (req->bRequest =3D=3D UR_SET_ADDRESS)) ||
>             ((req->bmRequestType =3D=3D UT_WRITE_DEVICE) &&
>             (req->bRequest =3D=3D UR_SET_CONFIG)) ||
>             ((req->bmRequestType =3D=3D UT_WRITE_INTERFACE) &&
>             (req->bRequest =3D=3D UR_SET_INTERFACE))) {
>                 /*
>                  * These requests can be useful for testing USB drivers.
>                  */
>                 error =3D priv_check(curthread, PRIV_DRIVER);
>                 if (error) {
>                         return (error);
>                 }
>         }
>
> You need to use their libusb counterpart to avoid problems!
>
> --HPS
>

--=20
=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D=
-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-
=E7=A7=98=E5=AF=86=E4=BF=9D=E6=8C=81=E3=81=AB=E3=81=A4=E3=81=84=E3=81=A6=EF=
=BC=9A=E3=81=93=E3=81=AE=E9=9B=BB=E5=AD=90=E3=83=A1=E3=83=BC=E3=83=AB=E3=81=
=AF=E3=80=81=E5=90=8D=E5=AE=9B=E4=BA=BA=E3=81=AB=E9=80=81=E4=BF=A1=E3=81=97=
=E3=81=9F=E3=82=82=E3=81=AE=E3=81=A7=E3=81=82=E3=82=8A=E3=80=81=E7=A7=98=E5=
=8C=BF=E7=89=B9=E6=A8=A9=E3=81=AE=E5=AF=BE=E8=B1=A1=E3=81=A8=E3=81=AA=E3=82=
=8B=E6=83=85=E5=A0=B1=E3=82=92=E5=90=AB=E3=82=93=E3=81=A7=E3=81=84=E3=81=BE=
=E3=81=99=E3=80=82
=E3=82=82=E3=81=97=E3=80=81=E5=90=8D=E5=AE=9B=E4=BA=BA=E4=BB=A5=E5=A4=96=E3=
=81=AE=E6=96=B9=E3=81=8C=E5=8F=97=E4=BF=A1=E3=81=95=E3=82=8C=E3=81=9F=E5=A0=
=B4=E5=90=88=E3=80=81=E3=81=93=E3=81=AE=E3=83=A1=E3=83=BC=E3=83=AB=E3=81=AE=
=E7=A0=B4=E6=A3=84=E3=80=81=E3=81=8A=E3=82=88=E3=81=B3=E3=81=93=E3=81=AE=E3=
=83=A1=E3=83=BC=E3=83=AB=E3=81=AB=E9=96=A2=E3=81=99=E3=82=8B=E4=B8=80=E5=88=
=87=E3=81=AE=E9=96=8B=E7=A4=BA=E3=80=81
=E8=A4=87=E5=86=99=E3=80=81=E9=85=8D=E5=B8=83=E3=80=81=E3=81=9D=E3=81=AE=E4=
=BB=96=E3=81=AE=E5=88=A9=E7=94=A8=E3=80=81=E3=81=BE=E3=81=9F=E3=81=AF=E8=A8=
=98=E8=BC=89=E5=86=85=E5=AE=B9=E3=81=AB=E5=9F=BA=E3=81=A5=E3=81=8F=E3=81=84=
=E3=81=8B=E3=81=AA=E3=82=8B=E8=A1=8C=E5=8B=95=E3=82=82=E3=81=95=E3=82=8C=E3=
=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=8A=E9=A1=98=E3=81=84=E7=94=B3=E3=81=
=97=E4=B8=8A=E3=81=92=E3=81=BE=E3=81=99=E3=80=82
---
CONFIDENTIALITY NOTE: The information in this email is confidential
and intended solely for the addressee.
Disclosure, copying, distribution or any other action of use of this
email by person other than intended recipient, is prohibited.
If you are not the intended recipient and have received this email in
error, please destroy the original message.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAASDrVmNZ8ejS-794iNU_GTxiw-t=7xXs=FteKcS5RumeW-iJQ>