⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 authorization.txt

📁 linux 内核源代码
💻 TXT
字号:
Authorizing (or not) your USB devices to connect to the system(C) 2007 Inaky Perez-Gonzalez <inaky@linux.intel.com> Intel CorporationThis feature allows you to control if a USB device can be used (ornot) in a system. This feature will allow you to implement a lock-downof USB devices, fully controlled by user space.As of now, when a USB device is connected it is configured andit's interfaces inmediately made available to the users. With thismodification, only if root authorizes the device to be configured willthen it be possible to use it.Usage:Authorize a device to connect:$ echo 1 > /sys/usb/devices/DEVICE/authorizedDeauthorize a device:$ echo 0 > /sys/usb/devices/DEVICE/authorizedSet new devices connected to hostX to be deauthorized by default (ie:lock down):$ echo 0 > /sys/bus/devices/usbX/authorized_defaultRemove the lock down:$ echo 1 > /sys/bus/devices/usbX/authorized_defaultBy default, Wired USB devices are authorized by default toconnect. Wireless USB hosts deauthorize by default all new connecteddevices (this is so because we need to do an authentication phasebefore authorizing).Example system lockdown (lame)-----------------------Imagine you want to implement a lockdown so only devices of type XYZcan be connected (for example, it is a kiosk machine with a visibleUSB port):boot uprc.local -> for host in /sys/bus/devices/usb* do    echo 0 > $host/authorized_default doneHookup an script to udev, for new USB devices if device_is_my_type $DEV then   echo 1 > $device_path/authorized doneNow, device_is_my_type() is where the juice for a lockdown is. Justchecking if the class, type and protocol match something is the worsesecurity verification you can make (or the best, for someone willingto break it). If you need something secure, use crypto and CertificateAuthentication or stuff like that. Something simple for an storage keycould be:function device_is_my_type(){   echo 1 > authorized		# temporarily authorize it                                # FIXME: make sure none can mount it   mount DEVICENODE /mntpoint   sum=$(md5sum /mntpoint/.signature)   if [ $sum = $(cat /etc/lockdown/keysum) ]   then        echo "We are good, connected"        umount /mntpoint        # Other stuff so others can use it   else        echo 0 > authorized   fi}Of course, this is lame, you'd want to do a real certificateverification stuff with PKI, so you don't depend on a shared secret,etc, but you get the idea. Anybody with access to a device gadget kitcan fake descriptors and device info. Don't trust that. You arewelcome.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -