From owner-freebsd-usb@FreeBSD.ORG Sun Sep 14 05:38:46 2014 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1A50D994 for ; Sun, 14 Sep 2014 05:38:46 +0000 (UTC) Received: from mail-ie0-f175.google.com (mail-ie0-f175.google.com [209.85.223.175]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D9D078BC for ; Sun, 14 Sep 2014 05:38:45 +0000 (UTC) Received: by mail-ie0-f175.google.com with SMTP id at20so2908787iec.6 for ; Sat, 13 Sep 2014 22:38:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=8TVcze3PnwcWxCOY1CVZlm1RuLYd8GsBXlKHZ6UUcpA=; b=CTH97Z+0UskTlVeKCsQhKzBlgAbZnzXrJsdUmpFAk1ZtsoAxxAPgT/3Tu/0t4t1CWZ kLd0JdSEMKbabJqi+Nnlb+m6T5yPrBj6vYkSpXvC7ya9cZBlQOpA5aVLX+uwxqmhr9EJ OLKWibzYcBzQkGA6NteLghszDt3vsa9zHvkEflxwS//qkdWrElGOpb4aX92Qj4Kv37kF ltAs9mjaHvpozNh/8NjhpjRRzS9AWwxSkUTM87iuitiNoHCtiGvxYNRsGrIZS74vlzTt JLJwrnrvcl9vkdBf8/l/P8qxirE8dqdT8D0jvbsY7EHYf7hxcJTVS4OFM6Gd+PGXagOr SErg== X-Gm-Message-State: ALoCoQnuoHdC/VP6byRj5118Vj9Yvz9UTsSpge264C5PXbYR/PUsH7hvofIhOrvKAoJ48Ar+67IO5nLCn+PYMrQxiqlYkGBeMeBop1MpjmUwNqoYr09kHU+78B5q3F5jRLQ8bVLXVSun X-Received: by 10.50.20.4 with SMTP id j4mr13653926ige.13.1410673118658; Sat, 13 Sep 2014 22:38:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.110.74 with HTTP; Sat, 13 Sep 2014 22:38:23 -0700 (PDT) In-Reply-To: <54144E00.4080100@selasky.org> References: <54144E00.4080100@selasky.org> From: "Lundberg, Johannes" Date: Sun, 14 Sep 2014 14:38:23 +0900 Message-ID: Subject: Re: libusb and non-root access problem To: Hans Petter Selasky Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: "freebsd-usb@freebsd.org" X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Sep 2014 05:38:46 -0000 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 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.