WO2014180244A1 - 外部设备控制方法及装置 - Google Patents

外部设备控制方法及装置 Download PDF

Info

Publication number
WO2014180244A1
WO2014180244A1 PCT/CN2014/075847 CN2014075847W WO2014180244A1 WO 2014180244 A1 WO2014180244 A1 WO 2014180244A1 CN 2014075847 W CN2014075847 W CN 2014075847W WO 2014180244 A1 WO2014180244 A1 WO 2014180244A1
Authority
WO
WIPO (PCT)
Prior art keywords
external device
terminal
port
control
information
Prior art date
Application number
PCT/CN2014/075847
Other languages
English (en)
French (fr)
Inventor
覃晓旭
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2014180244A1 publication Critical patent/WO2014180244A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/82Protecting input, output or interconnection devices
    • G06F21/85Protecting input, output or interconnection devices interconnection devices, e.g. bus-connected or in-line devices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2141Access rights, e.g. capability lists, access control lists, access tables, access matrices

Definitions

  • the present invention relates to the field of communications, and in particular to an external device control method and apparatus.
  • terminals generally provide ports to support external devices, for example, applications of a Universal Serial Bus (USB) device, which greatly facilitates the rapid use of information devices and enhances data. Convenience of exchange and storage.
  • USB Universal Serial Bus
  • the following uses a USB device as an example for description.
  • USB devices are easy to use, information security issues such as monitoring and auditing of USB devices are also emerging.
  • Information security is the focus of every organization, and information security is everywhere. The inventors have found that the system in the related art does not have hierarchical control of the terminal peripheral authority, and all USB peripherals are all readable, writable, and mapable at the terminal.
  • the present invention provides an external device control method and apparatus to solve at least the problem that the system does not perform authority control on the external device and causes the system to be less secure.
  • an external device control method including: receiving, from a port of a terminal, a message indicating that an external device is connected to the port; determining, according to a control rule, the external device on the terminal Permission; control the external device according to the permission.
  • the rights of the external device on the terminal include at least one of: whether the external device is allowed to be mounted on the terminal, whether the external device is allowed to be mapped to a virtual machine running on the terminal The read and write permissions of the external device after being mounted on the terminal and/or mapped to the virtual machine.
  • the control rule includes at least one of: determining, according to information of the port, the authority of the external device on the terminal; determining the external device according to information of the external device carried in the message
  • the authority on the terminal is determined according to the user logged in by the operating system on the terminal or the user group to which the user belongs; the operation on the virtual machine is performed according to the operation on the terminal; The user logged in by the system or the user group to which the user belongs determines the authority of the external device on the terminal.
  • the information about the external device carried in the message includes at least one of: a vendor identifier VID of the external device, a product identifier PID of the external device, a base class of the external device, the Subclass of external device Subclass The protocol of the external device.
  • the control rule is locally determined at the terminal, and/or the control rule is issued by the remote control terminal.
  • the method further includes: receiving a query message from the remote control terminal; reporting port information of the terminal and/or information of an external device connected to a port of the terminal according to the query message.
  • receiving, from the port of the terminal, the message indicating that the external device is connected to the port includes: initializing a socket to bind a port local to the terminal, where the socket is non-blocking Socket; establishes a thread and receives the message through the thread.
  • an external device control apparatus including: a first receiving module, configured to receive, from a port of a terminal, a message indicating that an external device is connected to the port; and a determining module, configured to Determining the authority of the external device on the terminal according to a control rule; and the control module is configured to control the external device according to the permission.
  • the rights of the external device on the terminal include at least one of: whether the external device is allowed to be mounted on the terminal, whether the external device is allowed to be mapped to a virtual machine running on the terminal The read and write permissions of the external device after being mounted on the terminal and/or mapped to the virtual machine.
  • the control rule includes at least one of: determining, according to information of the port, the authority of the external device on the terminal; determining the external device according to information of the external device carried in the message The authority on the terminal; determining the authority of the external device on the terminal according to the user logged in by the operating system on the terminal or the user group to which the user belongs; operating the operating system on the virtual machine according to the terminal The logged in user or the user group to which the user belongs determines the authority of the external device on the terminal.
  • the information of the external device carried in the message includes at least one of the following: a vendor identifier VID of the external device, the external device a product identification PID, a base class of the external device, and a subclass of the external device, Subclass, a protocol of the external device.
  • the control rule is locally determined at the terminal, and/or the control rule is issued by the remote control terminal.
  • the device further includes: a second receiving module, configured to receive a query message from the remote control end; the reporting module is configured to report port information of the terminal according to the query message and/or the terminal Information about the external device connected to the port.
  • the first receiving module is configured to initialize a socket to bind a port local to the terminal, and establish a thread, and receive, by the thread, the message, where the socket is a non-blocking socket word.
  • the method for controlling the external device according to the authority of the external device on the terminal solves the problem that the security control of the external device is not performed due to the lack of authority control on the external device, thereby improving system stability. The effects of sex, system security, and user experience.
  • FIG. 2 is a structural block diagram of an external device control device according to an embodiment of the present invention
  • FIG. 3 is an external device according to an embodiment of the present invention.
  • FIG. 4 is a diagram of a system topology relationship according to an embodiment of the present invention.
  • FIG. 5 is a block diagram of a remote control remote mapping system according to an embodiment of the present invention
  • FIG. 6 is a diagram of a remote control according to an embodiment of the present invention.
  • FIG. 7 is a system framework diagram of a local control remote mapping according to an embodiment of the present invention;
  • FIG. 8 is a flowchart of a local terminal local peripheral authority control of a thin terminal according to an embodiment of the present invention;
  • FIG. 9 is a flowchart of controlling a local USB peripheral authority control by a remote delivery control command according to an embodiment of the invention.
  • FIG. 1 is a flowchart of an external device control method according to an embodiment of the present invention. As shown in FIG. 1, the process includes the following steps: Step S102, a port of a slave terminal Receiving a message for instructing the external device to connect to the port; Step S104: determining, according to the control rule, the authority of the external device on the terminal; Step S106, controlling the external device according to the permission.
  • the method for controlling the external device according to the control rule and the authority of the external device on the terminal is adopted, thereby solving the problem that the system security is low due to the lack of authority control on the external device existing in the related art, and the problem is improved.
  • receiving a message from the port of the terminal to indicate that the external device is connected to the port may be implemented in multiple manners.
  • the method may be implemented by using a socket.
  • the foregoing step S102 may include : Initializes the socket to bind the local port of the terminal, where the socket is a non-blocking socket; establishes a thread and receives the message through the thread.
  • non-blocking sockets The way to implement non-blocking sockets is to implement non-blocking sockets through the select mechanism. You can also use the ioctl setting 0_NONBLOCK to implement non-blocking sockets under operating system Linux. Set the ioctlsocket under operating system Windows.
  • the way FIONBIO implements non-blocking sockets can also be done in other ways.
  • the rights of the external device on the terminal may be various, for example, may include at least one of the following: whether to allow the external device to be mounted on the terminal, whether to allow the external device to be mapped to the virtual machine running on the terminal, and external Read and write permissions of the device after it is mounted on the terminal and/or mapped to the virtual machine.
  • Virtual machines are involved.
  • Virtual machines can be used in cloud technology.
  • cloud virtual technology is used more and more frequently, and cloud virtual machines also have security problems. This is because USB peripherals can be used normally through virtual mapping technology, so the terminal needs to control the mapping permissions of peripherals. stand up.
  • the problem of virtual machine security can be solved by "allowing external devices to be mapped to virtual machines running on the terminal" above. According to the above multiple permissions, the external device can be controlled more comprehensively to ensure the security and stability of the system.
  • the foregoing control rule may also be diverse, for example, may include at least one of: determining the authority of the external device on the terminal according to the information of the port; determining the external device on the terminal according to the information of the external device carried in the message Privilege; determine the authority of the external device on the terminal according to the user logged in by the operating system on the terminal or the user group to which the user belongs; determine the external device based on the user logged in by the operating system running the virtual machine on the terminal or the user group to which the user belongs. Permissions on the terminal. These rules can be set for different ports, controlled according to specific devices, or set according to the user. These rules can be used in combination or separately.
  • the information of the external device may include at least one of the following: a vendor identifier VID of the external device, a product identifier PID of the external device, a base class Class of the external device, a subclass of the external device, a protocol protocol of the external device of the Subclass.
  • the preferred embodiment can make the control more flexible.
  • the control of devices of different vendors can be implemented by the VID, the control of different types of external devices can be controlled by the PID, etc., and the specific embodiment can implement a specific one.
  • the USB device has permission restrictions, and can also implement permission restrictions on a certain type of USB device.
  • the foregoing control rule may be locally set in the terminal, or may be sent by the remote control end, so that the authority control of the local external device may be implemented, and the remote control of the local external device may be controlled.
  • the remote control terminal can also query the information of the external device of the terminal. After receiving the query message from the remote control terminal, the terminal can report the port information of the terminal and/or the port connected to the terminal according to the query message. Information about external devices.
  • an external device control device is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and has not been described again.
  • the term "module” may implement a combination of software and/or hardware of a predetermined function.
  • the apparatus described in the following embodiments is preferably implemented in software, hardware, or a combination of software and hardware, is also possible and conceivable.
  • 2 is a block diagram showing the structure of an external device control apparatus according to an embodiment of the present invention. As shown in FIG. 2, the apparatus includes a first receiving module 22, a determining module 24, and a control module 26.
  • the external device control device will be described below.
  • the first receiving module 22 is configured to receive a message from the port of the terminal for indicating that the external device is connected to the port; the determining module 24 is connected to the first receiving module 22, and is configured to determine that the external device is in accordance with the control rule.
  • the authority on the terminal; the control module 26 is connected to the determining module 24, and is configured to control the external device according to the authority.
  • the rights of the external device on the terminal include at least one of: whether the external device is allowed to be mounted on the terminal, whether the external device is allowed to be mapped to the virtual machine running on the terminal, and the external device is mounted on the terminal and/or Or read and write permissions after mapping to a virtual machine.
  • the foregoing control rule includes at least one of the following: determining the authority of the external device on the terminal according to the information of the port; determining the authority of the external device on the terminal according to the information of the external device carried in the message; The user or the user group to which the user belongs determines the authority of the external device on the terminal.
  • the user who logs in based on the operating system on the virtual machine or the user group to which the user belongs determines the authority of the external device on the terminal.
  • the information of the external device carried in the message includes at least one of the following: a vendor identifier VID of the external device, a product identifier PID of the external device, and a base class of the external device Class, subclass of external device Subclass
  • the protocol of the external device Preferably, the foregoing control rule is locally formulated at the terminal, and/or the foregoing control rule is issued by the remote control terminal.
  • FIG. 3 is a block diagram showing a preferred structure of an external device control apparatus according to an embodiment of the present invention.
  • the apparatus includes a second receiving module 32 and a reporting module 34 in addition to all the modules shown in FIG.
  • the second receiving module 32 is configured to receive the query message from the remote control end;
  • the reporting module 34 is connected to the second receiving module 32, and is configured to report the port information of the terminal according to the query message and/or the external connection connected to the port of the terminal.
  • Device information Preferably, the first receiving module 22 is further configured to initialize a port local to the socket binding terminal, and establish a thread, and receive a message by using a thread, where the socket is a non-blocking socket.
  • the USB device will be described below in conjunction with a preferred embodiment. In the past, the access control of the USB peripherals of the terminal was implemented under Windows using some solutions provided by the operating system, and manually umount (unload) and mount in the terminal command line mode under Linux.
  • the netlink message is monitored in the background, and the USB peripheral plugging and unplugging action is recognized, and the control command issued by the network management server is used to achieve the purpose of hierarchical authority control.
  • the control item can be fine Whether the USB peripheral can be mounted, mapped, read-only, user operation record monitoring and reported to the server control.
  • the preferred embodiment can acquire peripheral events by listening to the messages of the system, and then mount the peripherals according to the privilege level.
  • the achievable grading has control of all USB peripherals according to the device category and specific device control actions: whether it can be mounted, whether it can be mapped, and whether the USB storage device can be controlled to read or write. If the mount is forbidden, the user cannot mount any USB device. If the read-only setting is made, the user cannot write information to the USB device. If the mapping is disabled, the user cannot map the USB device to the virtual machine, thereby greatly improving the information security of the terminal. Among them, the permissions of a specific USB device can be controlled according to the vid (vendor ID) and pid (product Id) of the USB device.
  • USB device can be mounted, mapped, read and written, and local control and remote mapping control can be implemented.
  • a thin terminal is taken as an example for description.
  • the system and method for implementing the thin terminal USB peripheral authority hierarchical control in the preferred embodiment may be as follows: In the first step, the listening system netlink broadcast message is obtained. The step may include the following steps: initializing a socket; establishing a sending and receiving thread; listening to a port; receiving a message. The second step is the privilege level control.
  • the step may include the following steps: receiving a message; determining whether a USB peripheral; analyzing the rights configuration file; and mounting according to the rights configuration file.
  • the control mode and control category are embodied in the preferred embodiment. Through these two points, the authority of the USB peripheral of the thin terminal can be controlled; the control mode of the USB peripheral authority of the thin terminal can be controlled; and the control category of the USB peripheral authority of the thin terminal can also be controlled.
  • USB rights configuration description The configuration file is in standard ini format and contains ten sections: [USB Local Deny], [USB Local Allow], [USB Remote Deny] [USB Remote Allow], [Others Local Deny], [Others Remote Deny], [Ports Local Deny] [Ports Remote Deny], [Local ReadWrite], [Remote ReadWrite].
  • the meaning of each segment is as follows: [USB Local Deny] and [USB Local Allow] record the peripheral control permissions of the USB peripheral in the terminal 1", where some of the vidpid recorded specific USB peripherals are local to the terminal Enable or disable, the class records the enabling and disabling of some (s) type of USB peripherals locally;
  • USB Remote Deny and [USB Remote Allow] record the permission control rules of the terminal USB peripheral mapping to the virtual machine, where some (specific) terminal terminal USB peripherals recorded by the vidpid are mapped to the virtual machine enable or disabled, Class records the enabling and disabling of some (s) types of terminal USB peripherals mapped to virtual machines;
  • [Others Local Deny] and [Others Remote Deny] record the prohibition rules for other types of USB peripherals when local and mapping. Not all USB peripherals follow the USB protocol will give the correct Vid, pid, class, subclass, protocol, If you don't want USB devices that are not recognized, you can add rules here.
  • [Ports Local Deny] and [Ports Remote Deny] Record the local port and mapping when the USB port is disabled. If the port value is set, the device inserted into the terminal cannot be recognized or mapped to the virtual machine.
  • [Local ReadWrite], [Remote ReadWrite] records the control of rw.
  • the device When the value of rw is readonly, the device is read-only. The default value is read-only, which is generally for the storage device.
  • Privilege control rules The rules define that Deny's priority privilege is higher than Allow's priority privilege, vidpid's priority privilege is higher than the class's priority privilege, and the port's privilege rule is higher than the device type's privilege.
  • the thin terminal can realize the permission control of the USB peripheral from nothing, not only can control a specific specific USB device, but also control a type of USB device, thereby playing a role in the information security of the terminal. Can not be ignored.
  • FIG. 4 is a diagram of a system topology relationship in accordance with an embodiment of the present invention.
  • FIG. 5 is a block diagram of a remote control remote mapping system according to an embodiment of the present invention.
  • 6 is a system diagram of a remote control local system in accordance with an embodiment of the present invention.
  • 7 is a system framework diagram of local control remote mapping in accordance with an embodiment of the present invention.
  • Figure 4-7 is a system framework diagram depicting the relationships between the various components of the system.
  • the USB peripheral authority hierarchical control system is mainly applied to the application layer and adopts the B/S architecture design.
  • the overall system topology relationship is mainly composed of web web client, background management program (management side), server, monitoring program (client), and relay.
  • the virtual machine is composed of six parts.
  • FIG. 8 is a flowchart of a local terminal local peripheral control of a thin terminal according to an embodiment of the present invention. As shown in FIG. 8, the process includes the following steps:
  • S802 initializes the socket, binds the local port, and uses a non-blocking socket.
  • Common implementations Use the select mechanism to implement non-blocking sockets.
  • the sending thread mainly analyzes the peripheral information, and then distributes it to each module for processing; S808, when the receiving thread receives the message, determines whether the USB device is related;
  • the sending thread parses the received device string, parses out the USB port information according to the string (such as 2-1.0), and obtains the vendorid, productid, and the system in the system.
  • the string such as 2-1.0
  • Control rules are: Deny's permission rule is higher than Allow's permission rule, pidvid's permission rule is higher than class
  • the permission rule, the port's permission rule is higher than the device type permission rule, first analyze whether the port is in the section [Ports Local Deny], if the port is in this section, record the mout information as umount, and perform the next step; If the port is not in the section, continue to analyze whether the device's vendorid, roductid are in the vidpid of [USB Local Deny], if in vidpid In the case, the information of the mout is recorded as umount, and the next step is performed; otherwise, the vendorid and productid of the analysis device are in the vidpid of the [USB Local Allow], and if in the vidpid, the information of the mout is recorded as mount, and the next step is performed; otherwise Analyze whether the productclass information
  • FIG. 9 is a flow chart of controlling a local USB peripheral authority control by a remote delivery control command according to an embodiment of the present invention. As shown in FIG. 9, the process includes the following steps:
  • S902 initialize the socket, bind the local port, and adopt a non-blocking socket.
  • Common implementations Use the select mechanism to implement non-blocking sockets.
  • the thread mainly analyzes the peripheral information, and then distributes it to each module for processing;
  • the sending thread parses the received device string, parses out the USB port information according to the string (such as 2-1.0), and obtains the vendorid, productid, and the system in the system.
  • Productclass, subclass, protocol, etc. record this information into a structure;
  • sending a thread analysis permission control file the control rules are: Deny's permission rule is higher than Allow's permission rule, pidvid's permission rule is higher than class's permission rule, port's permission rule is higher than device type permission rule, first Analyze whether the port is in the section [Ports Local Deny]. If the port is in this section, record the information of mout as umount and execute the next step.
  • the port is not in the section, continue to analyze whether the device's vendorid and roductid are in [ In the vidpid of USB Local Deny], if it is in vidpid, the information of mout is recorded as umount, and the next step is performed; otherwise, the vendorid and productid of the analysis device are in the vidpid of [USB Local Allow], if it is in vidpid, the record is recorded.
  • the information of mout is mount, and the next step is performed; otherwise, the productclass information of the device is analyzed in the class of [USB Local Deny]. If it is in the class of [USB Local Deny], the information of mout is recorded as umount.
  • the remote console management interface can query and modify the following items: Control by port (corresponding to the port rules of the terminal, such as Ports Local Deny), according to the device type control (corresponding to the class rules of the terminal, such as the class under [USB Local Allow]),
  • the device type can be divided into major classes and subclasses, corresponding to the base class and subclass of the USB protocol.
  • Base class is as follows:
  • Each base class has a subclass and a protocol of this attribute, taking Base Class EOh (Wireless Controller) as an example:
  • pid control (corresponding to the terminal's vidpid rules, such as vidpid under [USB Local Allow]).
  • the types of control are turned on (while turning on local and mapped permissions), off (while turning off local and mapped permissions), turning on local only (turning off mapping permissions), and turning on mapping only (turning off local permissions).
  • the remote control terminal can query the USB peripheral information of the current device.
  • the thin terminal receives the control terminal query parameters, polls the current USB peripheral port status, including the device type and its authority, and reports the current thin terminal permission rules, and saves the current peripheral link list;
  • the thin terminal receives the remote control end configuration parameter, and writes the item corresponding to the configuration file;
  • the remote control terminal of the thin terminal USB peripheral sends a control command to control the local USB device permission flow has been completed.
  • the remote control terminal management interface sends a control message in the following section.
  • the remote console management interface can have the following items: Control by port (corresponding to the port rule of the terminal); Control by device type (corresponding to the class rule of the terminal); Control by specific device vid, pid (corresponding to the vidpid rule of the terminal); Control The types are turned on (while turning on local and mapped permissions), off (while turning off local and mapped permissions), turning on local only (turning off mapping permissions), and turning on mapping only (turning off local permissions).
  • a data sequence is sent to the thin terminal device, and the management protocol can adopt the tr069 protocol or the snmp protocol.
  • the thin terminal agent writes the rules issued by the original management terminal into the configuration file stored locally by the terminal for use by the rights management module.
  • the remote control terminal sends a control command to control the flow of the USB peripheral mapping permission of the thin terminal.
  • the flowchart is similar to that in FIG. 9. The process includes the following steps:
  • S1002 initialize the socket, bind the local port, use non-blocking socket, initialize select.
  • FI0NBI0 Under Windows, FI0NBI0 is set by ioctlsocket to implement non-blocking sockets.
  • S1004 establishing a sending and receiving thread, and the receiving thread mainly listening to the port message;
  • the thread mainly analyzes the peripheral information, and then distributes it to each module for processing;
  • the sending thread parses the received device string, parses out the USB port information according to the string (such as 2-1.0), and obtains vendorid, productid, Productclass, subclass, protocol, etc., record this information into a structure;
  • S1014 sends a thread analysis permission control file, and the control rules are: Deny's permission rule is higher than Allow's permission rule, pidvid's permission rule is higher than class's permission rule, port's permission rule is higher than device type's permission rule, first Analyze whether the port is in the section [Ports Remote Deny]. If the port is in this section, record the information of mout as umount and execute the next step.
  • the port is not in the section, continue to analyze whether the device's vendorid and productid are in [ In the vidpid of USB Remote Deny], if it is in vidpid, record the information of mout as umount and execute the next step; otherwise, if the vendorid and productid of the analysis device are in the vidpid of [USB Remote Allow], if it is in vidpid, record Mout
  • the information is mount, and the next step is performed; otherwise, the productclass information of the analysis device is in the class of [USB Remote Deny]. If the information of the mout record in the section [USB Remote Deny] is umount, perform the next step. Otherwise, record the information of mout as mount and go to the next step.
  • the storage device Analyze whether the class of the device belongs to the storage device. If it is a storage device, read the value of the rw of the section [Remote ReadWrite] stored in the usb. If rw is readolny, the information of the record rw is readonly, otherwise it is written as writeable; The storage device, rw information is null, and the next step is performed;
  • the mapping is readable and writable; if the information of mout is umount, and the information of rw is not null, then the mapping relationship of the peripheral needs to be removed; if the information of mout is If umount, and rw information is null, the mapping relationship of the peripheral is released according to the class of the device; the remote control interface can query and modify the following items: Control by port (corresponding to the port rule of the terminal); Control by device type (corresponding to the class rule of the terminal): The device type can be divided into major classes and small classes, corresponding
  • the base class and subclass of the USB protocol are the same as the above example; each base class has a subclass and protocol of this attribute, as in the above example; according to the specific device vid, pid control (corresponding to the vidpid rule of the terminal).
  • the types of control are turned on (while turning on local and mapped permissions), off (while turning off local and mapped permissions), turning on local only (turning off mapping permissions), and turning on mapping only (turning off local permissions).
  • the remote control terminal can query the USB peripheral information that the thin terminal has mapped.
  • the thin terminal receives the control node query parameters, polls the current USB peripheral port status, including the device type and its permissions, and reports the current thin terminal permission rules. Save the current list of peripherals;
  • the thin terminal receives the remote control terminal configuration parameter, and writes the item corresponding to the configuration file; S1022, if necessary, remaps the device to the peripheral device on the thin terminal according to the rules of steps S1014-S1016;
  • the remote control terminal of the thin terminal USB peripheral issues a control command to control the USB device mapping authority flow has been completed.
  • modules or steps of the present invention can be implemented by a general-purpose computing device, which can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device, such that they may be stored in the storage device by the computing device and, in some cases, may be different from the order herein.
  • the steps shown or described are performed, or they are separately fabricated into individual integrated circuit modules, or a plurality of modules or steps are fabricated as a single integrated circuit module. Thus, the invention is not limited to any specific combination of hardware and software.
  • an external device control method and apparatus provided by an embodiment of the present invention have the following beneficial effects: Solving the problem that the external device does not perform authority control on the external device, resulting in low system security. In turn, the system stability, system security and user experience are improved.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Systems (AREA)

Abstract

本发明提供了外部设备控制方法及装置,该方法包括:从终端的端口接收到用于指示外部设备连接到端口的消息;根据控制规则确定外部设备在终端上的权限;根据权限对外部设备进行控制。通过本发明解决了相关技术中存在的对外部设备没有进行权限控制,导致系统安全性较低的问题,进而达到了提高系统稳定性、系统安全性和用户体验的效果。

Description

外部设备控制方法及装置
技术领域 本发明涉及通信领域, 具体而言, 涉及一种外部设备控制方法及装置。 背景技术 随着技术的发展, 终端一般提供了端口来支持外部设备, 例如, 计算机通用串行 总线 (Universal Serial Bus, 简称为 USB)设备的应用, 极大方便了信息设备快捷使用、 增强了数据交换和存储的便利性。 下面以 USB设备为例进行说明。 USB设备虽然使 用方便, 但是, USB设备使用中监控与审计等信息安全问题也显现出来。 信息安全是 每一个组织需要关心的重点, 信息安全无处不在。 发明人发现, 相关技术中的系统没有对终端外设权限进行分级控制, 是所有 USB 外设全部在终端可读写、 可挂载、 可映射。 这种处理方式对终端造成了巨大的安全隐 患, 非授权用户可以通过 USB外设对终端进行非法操作, 轻者系统不能正常工作, 更 为严重的是资料的泄密。 因此, 在相关技术中存在着对外部设备没有进行权限控制导致系统安全性较低的 问题。 发明内容 本发明提供了一种外部设备控制方法及装置, 以至少解决相关技术中存在的对外 部设备没有进行权限控制导致系统安全性较低的问题。 根据本发明的一个方面, 提供了一种外部设备控制方法, 包括: 从终端的端口接 收到用于指示外部设备连接到所述端口的消息; 根据控制规则确定所述外部设备在所 述终端上的权限; 根据所述权限对所述外部设备进行控制。 优选地, 所述外部设备在所述终端上的权限包括以下至少之一: 是否允许所述外 部设备挂载在所述终端上、是否允许所述外部设备映射到所述终端上运行的虚拟机上、 所述外部设备在挂载在所述终端和 /或映射到所述虚拟机上之后的读写权限。 优选地, 所述控制规则包括以下至少之一: 根据所述端口的信息确定所述外部设 备在所述终端上的权限; 根据所述消息中携带的所述外部设备的信息确定所述外部设 备在所述终端上的权限; 根据所述终端上操作系统登录的用户或者该用户所属的用户 组确定所述外部设备在所述终端上的权限; 根据所述终端上运行虚拟机上的操作系统 登录的用户或者该用户所属的用户组确定所述外部设备在所述终端上的权限。 优选地, 所述消息中携带的所述外部设备的信息包括以下至少之一: 所述外部设 备的厂商标识 VID、 所述外部设备的产品标识 PID、 所述外部设备的基类 Class、 所述 外部设备的子类 Subclass 所述外部设备的协议。 优选地, 所述控制规则是在所述终端本地制定的, 和 /或, 所述控制规则是由远程 控制端下发的。 优选地, 所述方法还包括: 接收到来自所述远程控制端的查询消息; 根据所述查 询消息上报所述终端的端口信息和 /或所述终端的端口上连接的外部设备的信息。 优选地, 从所述终端的端口接收到用于指示所述外部设备连接到所述端口的消息 包括: 初始化套接字绑定所述终端本地的端口, 其中, 所述套接字为非阻塞的套接字; 建立线程, 并通过所述线程接收所述消息。 根据本发明的另一方面, 提供了一种外部设备控制装置, 包括: 第一接收模块, 设置为从终端的端口接收到用于指示外部设备连接到所述端口的消息; 确定模块, 设 置为根据控制规则确定所述外部设备在所述终端上的权限; 控制模块, 设置为根据所 述权限对所述外部设备进行控制。 优选地, 所述外部设备在所述终端上的权限包括以下至少之一: 是否允许所述外 部设备挂载在所述终端上、是否允许所述外部设备映射到所述终端上运行的虚拟机上、 所述外部设备在挂载在所述终端和 /或映射到所述虚拟机上之后的读写权限。 优选地, 所述控制规则包括以下至少之一: 根据所述端口的信息确定所述外部设 备在所述终端上的权限; 根据所述消息中携带的所述外部设备的信息确定所述外部设 备在所述终端上的权限; 根据所述终端上操作系统登录的用户或者该用户所属的用户 组确定所述外部设备在所述终端上的权限; 根据所述终端上运行虚拟机上的操作系统 登录的用户或者该用户所属的用户组确定所述外部设备在所述终端上的权限。 优选地, 在所述外部设备为通用串行总线 USB设备的情况下, 所述消息中携带的 所述外部设备的信息包括以下至少之一: 所述外部设备的厂商标识 VID、 所述外部设 备的产品标识 PID、 所述外部设备的基类 Class、 所述外部设备的子类 Subclass 所述 外部设备的协议。 优选地, 所述控制规则是在所述终端本地制定的, 和 /或, 所述控制规则是由远程 控制端下发的。 优选地, 所述装置还包括: 第二接收模块, 设置为接收到来自所述远程控制端的 查询消息; 上报模块, 设置为根据所述查询消息上报所述终端的端口信息和 /或所述终 端的端口上连接的外部设备的信息。 优选地, 所述第一接收模块设置为初始化套接字绑定所述终端本地的端口, 并建 立线程, 通过所述线程接收所述消息, 其中, 所述套接字为非阻塞的套接字。 通过本发明, 采用根据外部设备在终端上的权限对外部设备进行控制的方法解决 了在相关技术中存在的对外部设备没有进行权限控制导致系统安全性较低的问题, 进 而达到了提高系统稳定性、 系统安全性和用户体验的效果。 附图说明 此处所说明的附图用来提供对本发明的进一步理解, 构成本申请的一部分, 本发 明的示意性实施例及其说明用于解释本发明, 并不构成对本发明的不当限定。 在附图 中- 图 1是根据本发明实施例的外部设备控制方法的流程图; 图 2是根据本发明实施例的外部设备控制装置的结构框图; 图 3是根据本发明实施例的外部设备控制装置的优选结构框图; 图 4是根据本发明实施例的系统拓扑关系图; 图 5是根据本发明实施例的远端控制远端映射系统框架图; 图 6是根据本发明实施例的远端控制本地的系统框架图; 图 7是根据本发明实施例的本地控制远端映射的系统框架图; 图 8是根据本发明实施例的瘦终端本地 (local) USB外设权限控制的流程; 图 9是根据本发明实施例的远端下发控制命令控制本地 USB外设权限控制的流程 图。 具体实施方式 下文中将参考附图并结合实施例来详细说明本发明。 需要说明的是, 在不冲突的 情况下, 本申请中的实施例及实施例中的特征可以相互组合。 在本实施例中提供了一种外部设备控制方法, 图 1是根据本发明实施例的外部设 备控制方法的流程图, 如图 1所示, 该流程包括如下步骤: 步骤 S102, 从终端的端口接收到用于指示外部设备连接到端口的消息; 步骤 S104, 根据控制规则确定该外部设备在终端上的权限; 步骤 S106, 根据该权限对该外部设备进行控制。 通过上述步骤, 采用控制规则并根据外部设备在终端上的权限对外部设备进行控 制的方法, 从而解决了在相关技术中存在的对外部设备没有进行权限控制导致系统安 全性较低的问题, 提高了系统稳定性、 系统安全性和用户体验。 优选地, 从终端的端口接收到用于指示外部设备连接到端口的消息可以有多种实 现方式,在一个优选实施方式中,可以采用套接字的方式来实现,例如,上述步骤 S102 可以包括: 初始化套接字绑定终端本地的端口, 其中, 套接字为非阻塞的套接字; 建 立线程, 并通过线程接收消息。 实现非阻塞套接字的方式可以为通过 select机制来实 现非阻塞的套接字,还可以采用在操作系统 Linux下通过 ioctl设置 0_NONBLOCK实 现非阻塞的套接字, 在操作系统 Windows下通过 ioctlsocket设置 FIONBIO实现非阻 塞的套接字的方式, 还可以通过其它可实现的方式。 优选地, 外部设备在终端上的权限可以为多种多样, 例如, 可以包括以下至少之 一: 是否允许外部设备挂载在终端上、 是否允许外部设备映射到终端上运行的虚拟机 上、 外部设备在挂载在终端和 /或映射到虚拟机上之后的读写权限。 在上述权限中, 涉及到虚拟机。 虚拟机可以使用在云技术中。 随着虚拟技术的发 展, 云虚拟技术使用越来越频繁, 云虚拟机同样存在安全问题, 这是因为通过虚拟映 射技术, USB外设能够正常使用, 所以也需要终端把外设的映射权限控制起来。 通过 上述 "是否允许外部设备映射到终端上运行的虚拟机上" 就可以解决虚拟机安全的问 题。 根据上述的多种权限可以更全面的对外部设备进行控制, 保证系统安全和稳定。 优选地, 上述控制规则也可以是多样的, 例如, 可以包括以下至少之一: 根据端 口的信息确定外部设备在终端上的权限; 根据消息中携带的外部设备的信息确定外部 设备在终端上的权限; 根据终端上操作系统登录的用户或者该用户所属的用户组确定 外部设备在终端上的权限; 根据终端上运行虚拟机上的操作系统登录的用户或者该用 户所属的用户组确定外部设备在终端上的权限。 通过这些规则, 可以针对不同的端口来进行设置, 也可以根据具体的设备来进行 控制, 还可以根据用户本身来进行设置。 这些规则可以结合使用, 也可以单独使用。 外部设备的类型可能存在有很多种, 对于不同种类的设备可以得到不同的信息, 例如, 在一个优选的实施方式中, 在外部设备为通用串行总线 USB设备的情况下, 上 述消息中携带的外部设备的信息可以包括以下至少之一: 外部设备的厂商标识 VID、 外部设备的产品标识 PID、 外部设备的基类 Class、 外部设备的子类 Subclass 外部设 备的协议 Protocol。 该优选实施方式可以使控制更加灵活, 例如, 可以通过 VID可以 实现对不同厂商的设备的控制, 通过 PID可以通过不同种类的外部设备的控制等等, 通过该优选实施例可以实现对某一个具体的 USB设备进行权限限制,也可以实现对某 一类 USB设备进行权限限制。 优选地, 上述控制规则可以是在终端本地制定的, 也可以是由远程控制端下发的, 这样可以实现本地外部设备的权限控制, 又可以实现远端控制本地的外部设备的权限 控制。 优选地, 远程控制端还可以查询终端的外部设备的信息, 此时终端可以在接收到 来自远程控制端的查询消息之后; 根据该查询消息上报该终端的端口信息和 /或终端的 端口上连接的外部设备的信息。 在本实施例中还提供了一种外部设备控制装置, 该装置用于实现上述实施例及优 选实施方式, 已经进行过说明的不再赘述。 如以下所使用的, 术语 "模块" 可以实现 预定功能的软件和 /或硬件的组合。 尽管以下实施例所描述的装置较佳地以软件来实 现, 但是硬件, 或者软件和硬件的组合的实现也是可能并被构想的。 图 2是根据本发明实施例的外部设备控制装置的结构框图, 如图 2所示, 该装置 包括第一接收模块 22、 确定模块 24和控制模块 26。 下面对该外部设备控制装置进行 说明。 第一接收模块 22, 设置为从终端的端口接收到用于指示外部设备连接到端口的消 息; 确定模块 24, 连接至上述第一接收模块 22, 设置为根据控制规则确定外部设备在 终端上的权限; 控制模块 26, 连接至上述确定模块 24, 设置为根据权限对外部设备进 行控制。 优选地, 上述外部设备在终端上的权限包括以下至少之一: 是否允许外部设备挂 载在终端上、 是否允许外部设备映射到终端上运行的虚拟机上、 外部设备在挂载在终 端和 /或映射到虚拟机上之后的读写权限。 优选地, 上述控制规则包括以下至少之一: 根据端口的信息确定外部设备在终端 上的权限; 根据消息中携带的外部设备的信息确定外部设备在终端上的权限; 根据终 端上操作系统登录的用户或者该用户所属的用户组确定外部设备在终端上的权限; 根 据终端上运行虚拟机上的操作系统登录的用户或者该用户所属的用户组确定外部设备 在终端上的权限。 优选地, 在外部设备为通用串行总线 USB设备的情况下, 消息中携带的外部设备 的信息包括以下至少之一: 外部设备的厂商标识 VID、 外部设备的产品标识 PID、 外 部设备的基类 Class、 外部设备的子类 Subclass 外部设备的协议。 优选地, 上述控制规则是在终端本地制定的, 和 /或, 上述控制规则是由远程控制 端下发的。 图 3是根据本发明实施例的外部设备控制装置的优选结构框图, 如图 3所示, 该 装置除包括图 2所示的所有模块外, 还包括第二接收模块 32和上报模块 34。 下面对 该外部设备控制装置优选结构框图进行说明。 第二接收模块 32, 设置为接收到来自远程控制端的查询消息; 上报模块 34, 连接 至上述第二接收模块 32,设置为根据查询消息上报终端的端口信息和 /或终端的端口上 连接的外部设备的信息。 优选地, 上述第一接收模块 22还设置为初始化套接字绑定终端本地的端口,并建 立线程, 通过线程接收消息, 其中, 套接字为非阻塞的套接字。 下面以 USB设备为例结合优选的实施例进行说明。 以往终端的 USB外设的权限控制在 Windows下是利用操作系统提供的一些解决 方案实现的, 而在 Linux下通过终端命令行模式下手动进行 umount (卸载) 和 mount
(挂载) 实现分级权限控制的, 而对于嵌入式终端没有命令行而无法做到精确控制。 在本优选实施例中是通过后台监控 netlink消息, 识别 USB外设插拔动作, 通过网管 服务器下发的控制命令, 达到分级权限控制的目的。 在本优选实施例中控制项可以细 化到 USB外设的是否可挂载、 是否可映射、 是否只读、 用户操作记录监控并上报给服 务器控制。 本优选实施例可以通过监听系统的消息, 获取外设事件, 然后对外设按权限分级 进行挂载。可实现的分级有按设备类别、具体的设备控制动作对所有的 USB外设的控 制有: 是否可挂载、 是否可映射, 对 USB存储设备还可以控制其是否可读写等。 禁止 挂载, 用户就不能挂载任何 USB设备; 设置只读, 用户就不能写入信息到 USB设备; 禁止映射, 用户就不能将 USB设备映射到虚拟机, 从而大大提高终端的信息安全性。 其中, 可以根据 USB设备的 vid (厂商 ID)、 pid (产品 Id)控制一个具体的 USB 设备的权限。 也可以根据 USB设备的 Class (基类)、 Subclass (子类)、 Protocol (协 议) 的组合来达到控制某一类 USB设备的权限。 还可以根据用户、 用户组控制 USB 设备的权限。 从而实现 USB设备的挂载、 映射、 读写权限的控制, 也可以实现本地控 制和远端映射控制。 本优选实施例中以瘦终端为例进行说明。本优选实施例中实现瘦终端 USB外设权 限分级控制的系统和方法可以如下: 第一步, 监听系统 netlink广播消息。 该步骤可以包括如下步骤: 初始化 socket; 建立收发线程; 监听端口; 接收消息。 第二步, 权限分级控制。 该步骤可以包括如下步骤; 接收消息; 判断是否 USB外 设; 分析权限配置文件; 根据权限配置文件进行挂载。 在本优选实施例中体现了控制方式和控制类别。 通过这两点可以对瘦终端的 USB 外设的权限进行控制; 可以对瘦终端的 USB外设权限的控制方式; 还可以对瘦终端的 USB外设权限的控制类别。 权限配置文件的格式可以有很多种, 在本优选实施例中提供了一种优选的权限配 置文件的格式如下:
[USB Local Deny] version=V3.01.02T03 vidpid= class:
[USB Local Allow] version=V3.01.02T03 vidpid:
class:
[USB Remote Deny] version=V3.01.02T03 vidpid:
class:
[USB Remote Allow] version=V3.01.02T03 vidpid:
class:
[Others Local Deny] version=V3.01.02T03 dev=
[Others Remote Deny] version=V3.01.02T03 dev=
[Ports Local Deny] version=V3.01.02T03 ports:
[Ports Remote Deny] version=V3.01.02T03 ports: [Local ReadWrite] rw=readonly
[Remote ReadWrite] rw=readonly
USB权限配置描述: 配置文件采用标准的 ini格式, 包含十个 section (段): [USB Local Deny]、 [USB Local Allow]、 [USB Remote Deny] [USB Remote Allow]、 [Others Local Deny]、 [Others Remote Deny]、 [Ports Local Deny] [Ports Remote Deny]、 [Local ReadWrite]、 [Remote ReadWrite]。 每个段的意义如下: [USB Local Deny]和 [USB Local Allow]记录 USB外设在终端本地的权限控制规 贝 1」, 其中 vidpid记录的某些 (个) 具体的 USB外设在终端本地使能或者禁止, class 记录的是某些 (个) 类型的 USB外设在终端本地的使能和禁止;
[USB Remote Deny]和 [USB Remote Allow] 记录终端 USB外设映射到虚拟机的权 限控制规则, 其中 vidpid记录的某些(个)具体的终端终端 USB外设映射到虚拟机使 能或者禁止, class记录的是某些 (个) 类型的终端 USB外设映射到虚拟机的使能和 禁止;
[Others Local Deny]和 [Others Remote Deny]记录本地和映射时其他类型 USB外设 的禁止规则, 不是所有的 USB外设都遵循 USB协议会给出正确的 Vid、 pid、 class, subclass, protocol, 如果你不想那些不识别的 USB设备接入终端, 可以在此添加规则。 [Ports Local Deny]和 [Ports Remote Deny] 记录本地和映射时 USB端口的禁止规 贝 ij, 如果 port值被设置, 插入到终端上的这个设备就不能被识别或被映射到虚拟机。
[Local ReadWrite]、 [Remote ReadWrite]记录 rw的控制项, 当 rw的值为 readonly 时表示设备为只读, 默认值是只读, 一般是针对存储设备的。 权限控制规则:规则定义的是 Deny的优先级权限高于 Allow的优先级权限, vidpid 的优先级权限高于 class的优先级权限, 端口的权限规则高于设备类型的权限。 通过本优选实施例, 可以使瘦终端从无到实现了 USB外设的权限控制, 不仅可以 控制具体的某个具体的 USB设备, 还能控制一类 USB设备, 从而对终端的信息安全 起到了不可忽视的作用。 图 4是根据本发明实施例的系统拓扑关系图。 图 5是根据本发明实施例的远端控 制远端映射系统框架图。 图 6是根据本发明实施例的远端控制本地的系统框架图。 图 7是根据本发明实施例的本地控制远端映射的系统框架图。图 4-7是系统框架图,描述 系统各组成部分之间的关系。 USB外设权限分级控制系统主要针对应用层, 采用 B/S 架构设计; 整体系统拓扑关系上主要由 web 网页客户端、 后台管理程序 (管理端)、 服务器、 监控程序 (客户端)、 中继器、 虚拟机六部分组成。 web网页客户端用于访问 管理服务器下发控制命令,后台管理程序(管理端)跟终端监控程序通信实现控制 USB 外设权限分级控制的目的, 服务器由数据库服务器、 升级服务器、 日志服务器等组成, 中继器用于发送一些特殊的命令, 云虚拟机是通过终端访问的可以进行办公的系统环 境, 监控程序接受服务器的控制命令, 对 USB外设进行相应的控制。 下面结合附图对技术方案的实施作进一步的描述: 图 8是根据本发明实施例的瘦终端本地 (local) USB外设权限控制的流程图, 如 图 8所示, 该流程包括如下步骤:
S802, 初始化 socket, 绑定本地的端口, 采用非阻塞的 socket。 常见实现方式: 使用 select 机制来实现非阻塞的 socket。 可替代方式: Linux 下通过 ioctl 设置 0_N0NBL0CK实现非阻塞的 socket, Windows下通过 ioctlsocket设置 FI0NBI0实现 非阻塞的 socket;
S804, 建立收发线程, 收线程主要监听端口消息;
S806, 发线程主要分析外设信息, 然后分发给各个模块处理; S808 , 当收线程收到消息, 判断是否 USB设备相关;
S810, 如果与 USB设备无关, 则不处理, 继续监听;
S812, 如果是设备相关的信息就交给发线程来处理, 发线程解析收到的设备字符 串,根据字符串解析出 USB端口信息(如 2-1.0),并且在系统中获取 vendorid、productid、 productclass, subclass, protocol等信息, 记录这些信息到一个结构体中; S814, 发线程分析权限控制文件, 控制的规则是: Deny的权限规则高于 Allow的 权限规则, pidvid的权限规则要高于 class的权限规则, 端口的权限规则高于设备类型 的权限规则,首先分析端口是否在 section [Ports Local Deny]中,如果端口在这个 section 中, 则记录 mout的信息为 umount, 执行下一步; 而如果端口不在该 section中, 则 继续分析设备的 vendorid、 roductid是否在 [USB Local Deny]的 vidpid中,如果在 vidpid 中, 则记录 mout的信息为 umount, 执行下一步; 否则分析设备的 vendorid、 productid 是否在 [USB Local Allow]的 vidpid中,如果在 vidpid中,则记录 mout的信息为 mount, 执行下一步; 否则分析设备的 productclass 信息是否在段 [USB Local Deny]的 class中, 如果在 section [USB Local Deny]的 class中, 则记录 mout的信息为 umount, 执行下一 步; 否则记录 mout的信息为 mount, 执行下一步, 分析设备的 class是否属于存储设 备, 如果是存储设备, 那么读取 usb存储的 section [Local ReadWrite]的 rw的值, 如果 rw为 readolny,则记录 rw的信息为 readonly,否则记为 writeable;如果不是存储设备, rw的信息为 null, 执行下一步;
S816, 如果 mout的信息为 mount, 而且 rw的信息不为 null, 也就是说是需要挂 载 USB 存储设备, 那么根据 rw 的属性重新挂载 usb存储设备, 如果 rw 的属性为 readonly,那么挂载为只读,如果 rw的属性为 writeable,那么挂载为可读写;如果 mout 的信息为 umount, 而且 rw的信息不为 null, 那么需要卸载掉已经被系统挂载了的该 设备; 如果 mout的信息为 umount, 而且 rw的信息为 null, 则根据设备的 class卸载 掉相应的驱动程序; S818 , 至此, 瘦终端 USB外设的本地控制已经完成。 图 9是根据本发明实施例的远端下发控制命令控制本地 USB外设权限控制的流程 图, 如图 9所示, 该流程包括如下步骤:
S902, 初始化 socket, 绑定本地的端口, 采用非阻塞的 socket。 常见实现方式: 使用 select 机制来实现非阻塞的 socket。 可替代方式: Linux 下通过 ioctl 设置 0_NONBLOCK实现非阻塞的 socket, Windows下通过 ioctlsocket设置 FIONBIO实现 非阻塞的 socket;
S904, 建立收发线程, 收线程主要监听端口消息;
S906, 发线程主要分析外设信息, 然后分发给各个模块处理;
S908 , 当收线程收到消息, 判断是否 USB设备相关; S910, 如果与 USB设备无关, 则不处理, 继续监听;
S912, 如果是设备相关的信息就交给发线程来处理, 发线程解析收到的设备字符 串,根据字符串解析出 USB端口信息(如 2-1.0),并且在系统中获取 vendorid、productid、 productclass, subclass, protocol等信息, 记录这些信息到一个结构体中; S914, 发线程分析权限控制文件, 控制的规则是: Deny的权限规则高于 Allow的 权限规则, pidvid的权限规则要高于 class的权限规则, 端口的权限规则高于设备类型 的权限规则,首先分析端口是否在 section [Ports Local Deny]中,如果端口在这个 section 中, 则记录 mout的信息为 umount, 执行下一步; 而如果端口不在该 section中, 则 继续分析设备的 vendorid、 roductid是否在 [USB Local Deny]的 vidpid中,如果在 vidpid 中, 则记录 mout的信息为 umount, 执行下一步; 否则分析设备的 vendorid、 productid 是否在 [USB Local Allow]的 vidpid中,如果在 vidpid中,则记录 mout的信息为 mount, 执行下一步; 否则分析设备的 productclass信息是否在段 [USB Local Deny]的 class中, 如果在 section [USB Local Deny]的 class中, 则记录 mout的信息为 umount, 执行下一 步; 否则记录 mout的信息为 mount, 执行下一步, 分析设备的 class是否属于存储设 备, 如果是存储设备, 那么读取 usb存储的 section [Local ReadWrite]的 rw的值, 如果 rw为 readolny,则记录 rw的信息为 readonly,否则记为 writeable;如果不是存储设备, rw的信息为 null, 执行下一步;
S916, 如果 mout的信息为 mount, 而且 rw的信息不为 null, 也就是说是需要挂 载 USB 存储设备, 那么根据 rw 的属性重新挂载 usb存储设备, 如果 rw 的属性为 readonly,那么挂载为只读,如果 rw的属性为 writeable,那么挂载为可读写;如果 mout 的信息为 umount, 而且 rw的信息不为 null, 那么需要卸载掉已经被系统挂载了的该 设备; 如果 mout的信息为 umount, 而且 rw的信息为 null, 则根据设备的 class卸载 掉相应的驱动程序。 远程控制端管理界面可查询和修改如下项目: 按端口控制 (对应终端的 port规则, 如 Ports Local Deny ), 按设备类型控制 (对应终端的 class规则, 如 [USB Local Allow]下的 class ),
设备类型可按大类和小类来分,对应 USB协议的 base class和 subclass。 Base class 如下:
Figure imgf000014_0001
每个 base class都有本属性的 subclass禾口 protocol, 以 Base Class EOh (Wireless Controller)为例:
Figure imgf000015_0001
按具体的设备 vid、 pid控制 (对应终端的 vidpid规则, 如 [USB Local Allow]下的 vidpid )。 控制的类型有开启(同时开启本地和映射的权限)、关闭(同时关闭本地和映射的 权限)、 仅开启本地 (关闭映射权限)、 仅开启映射 (关闭本地权限)。
S918 ,远端控制端可查询当前设备的 USB外设信息。瘦终端接收控制端查询参数, 轮询当前 USB外设端口情况,包括设备类型及其权限,并上报当前瘦终端的权限规则, 保存当前外设链表;
S920, 瘦终端接收远程控制端配置参数, 并写入配置文件对应的项;
S922, 如果有必要对瘦终端上的外设按照第 S914-S916步的规则重新挂载设备;
S924, 瘦终端 USB外设的远端控制端下发控制命令控制本地 USB设备权限流程 已经完成。 在以下部分中示出了远端控制端管理界面下发控制消息。 远程控制端管理界面可以有如下项目: 按端口控制 (对应终端的 port规则); 按 设备类型控制(对应终端的 class规则);按具体的设备 vid、pid控制(对应终端的 vidpid 规则); 控制的类型有开启 (同时开启本地和映射的权限)、 关闭 (同时关闭本地和映 射的权限)、 仅开启本地 (关闭映射权限)、 仅开启映射 (关闭本地权限)。 根据管理界面选择的权限控制规则, 组成一个数据序列下发给瘦终端设备, 管理 协议可以采用 tr069协议或者 snmp协议。 瘦终端代理程序把原创管理端下发的规则写进终端本地存储的配置文件中, 供权 限管理模块使用。 远端控制端下发控制命令控制瘦终端 USB外设映射权限的流程, 其流程图与图 9 相似, 该流程包括如下步骤:
S1002, 初始化 socket, 绑定本地的端口, 采用非阻塞的 socket, 初始化 select。 常见实现方式:使用 select机制来实现非阻塞的 socket。可替代方式: Linux下通过 ioctl 设置 0_NONBLOCK实现非阻塞的 socket, Windows下通过 ioctlsocket设置 FI0NBI0 实现非阻塞的 socket。 S1004, 建立收发线程, 收线程主要监听端口消息;
S1006, 发线程主要分析外设信息, 然后分发给各个模块处理;
S1008, 当收线程收到消息, 判断是否 USB设备相关;
S1010, 如果与 USB设备无关, 则不处理, 继续监听;
S1012,如果是设备相关的信息就交给发线程来处理,发线程解析收到的设备字符 串,根据字符串解析出 USB端口信息(如 2-1.0),并且在系统中获取 vendorid、productid、 productclass, subclass, protocol等信息, 记录这些信息到一个结构体中;
S1014, 发线程分析权限控制文件, 控制的规则是: Deny 的权限规则高于 Allow 的权限规则, pidvid的权限规则要高于 class的权限规则, 端口的权限规则高于设备类 型的权限规则, 首先分析端口是否在 section [Ports Remote Deny]中, 如果端口在这个 section中, 则记录 mout的信息为 umount, 执行下一步; 而如果端口不在该 section 中, 则继续分析设备的 vendorid、 productid 是否在 [USB Remote Deny]的 vidpid中, 如 果在 vidpid中,则记录 mout的信息为 umount,执行下一步;否则分析设备的 vendorid、 productid 是否在 [USB Remote Allow]的 vidpid中, 如果在 vidpid中, 则记录 mout的 信息为 mount, 执行下一步; 否则分析设备的 productclass 信息是否在段 [USB Remote Deny]的 class中, 如果在 section [USB Remote Deny]的 class中, 贝 ij记录 mout的信息 为 umount, 执行下一步; 否则记录 mout的信息为 mount, 执行下一步。 分析设备的 class 是否属于存储设备, 如果是存储设备, 那么读取 usb 存储的 section [Remote ReadWrite]的 rw的值, 如果 rw为 readolny, 则记录 rw的信息为 readonly, 否则记为 writeable; 如果不是存储设备, rw的信息为 null, 执行下一步;
S1016, 如果 mout的信息为 mount, 而且 rw的信息不为 null, 也就是说是需要映 射 USB存储设备,那么根据 nv的属性重新发送命令给虚拟机以重映射 usb存储设备, 如果 rw的属性为 readonly, 那么映射为只读, 如果 rw的属性为 writeable, 那么映射 为可读写; 如果 mout的信息为 umount, 而且 rw的信息不为 null, 那么需要解除该外 设映射关系; 如果 mout的信息为 umount, 而且 rw的信息为 null, 则根据设备的 class 解除该外设的映射关系; 远程控制端管理界面可查询和修改如下项目: 按端口控制 (对应终端的 port规则); 按设备类型控制 (对应终端的 class规则): 设备类型可按大类和小类来分, 对应
USB协议的 base class和 subclass, 同上例; 每个 base class都有本属性的 subclass和 protocol, 同上例; 按具体的设备 vid、 pid控制 (对应终端的 vidpid规则)。 控制的类型有开启(同时开启本地和映射的权限)、关闭(同时关闭本地和映射的 权限)、 仅开启本地 (关闭映射权限)、 仅开启映射 (关闭本地权限)。
S1018, 远端控制端可查询瘦终端已经映射了的 USB外设信息。 瘦终端接收控制 端查询参数, 轮询当前 USB外设端口情况, 包括设备类型及其权限, 并上报当前瘦终 端的权限规则。 保存当前外设链表;
S1020, 瘦终端接收远程控制端配置参数, 并写入配置文件对应的项; S1022, 如果有必要将对瘦终端上的外设按照第 S1014- S1016步的规则重新映射 设备;
S1024,瘦终端 USB外设的远端控制端下发控制命令控制 USB设备映射权限流程 已经完成。 显然, 本领域的技术人员应该明白, 上述的本发明的各模块或各步骤可以用通用 的计算装置来实现, 它们可以集中在单个的计算装置上, 或者分布在多个计算装置所 组成的网络上, 可选地, 它们可以用计算装置可执行的程序代码来实现, 从而, 可以 将它们存储在存储装置中由计算装置来执行, 并且在某些情况下, 可以以不同于此处 的顺序执行所示出或描述的步骤, 或者将它们分别制作成各个集成电路模块, 或者将 它们中的多个模块或步骤制作成单个集成电路模块来实现。 这样, 本发明不限制于任 何特定的硬件和软件结合。 以上所述仅为本发明的优选实施例而已, 并不用于限制本发明, 对于本领域的技 术人员来说, 本发明可以有各种更改和变化。 凡在本发明的精神和原则之内, 所作的 任何修改、 等同替换、 改进等, 均应包含在本发明的保护范围之内。 工业实用性 如上所述, 本发明实施例提供的一种外部设备控制方法及装置具有以下有益 效果: 解决了相关技术中存在的对外部设备没有进行权限控制, 导致系统安全性较 低的问题, 进而达到了提高系统稳定性、 系统安全性和用户体验的效果。

Claims

权 利 要 求 书
1. 一种外部设备控制方法, 包括:
从终端的端口接收到用于指示外部设备连接到所述端口的消息; 根据控制规则确定所述外部设备在所述终端上的权限;
根据所述权限对所述外部设备进行控制。
2. 根据权利要求 1所述的方法, 其中, 所述外部设备在所述终端上的权限包括以 下至少之一:
是否允许所述外部设备挂载在所述终端上、 是否允许所述外部设备映射到 所述终端上运行的虚拟机上、所述外部设备在挂载在所述终端和 /或映射到所述 虚拟机上之后的读写权限。
3. 根据权利要求 1或 2所述的方法, 其中, 所述控制规则包括以下至少之一: 根据所述端口的信息确定所述外部设备在所述终端上的权限; 根据所述消息中携带的所述外部设备的信息确定所述外部设备在所述终端 上的权限;
根据所述终端上操作系统登录的用户或者该用户所属的用户组确定所述外 部设备在所述终端上的权限;
根据所述终端上运行虚拟机上的操作系统登录的用户或者该用户所属的用 户组确定所述外部设备在所述终端上的权限。
4. 根据权利要求 3所述的方法,其中,在所述外部设备为通用串行总线 USB设备 的情况下, 所述消息中携带的所述外部设备的信息包括以下至少之一:
所述外部设备的厂商标识 VID、 所述外部设备的产品标识 PID、 所述外部 设备的基类 Class、 所述外部设备的子类 Subclass 所述外部设备的协议。
5. 根据权利要求 1至 4中任一项所述的方法, 其中, 所述控制规则是在所述终端 本地制定的, 和 /或, 所述控制规则是由远程控制端下发的。
6. 根据权利要求 5所述的方法, 其中, 所述方法还包括:
接收到来自所述远程控制端的查询消息; 根据所述查询消息上报所述终端的端口信息和 /或所述终端的端口上连接 的外部设备的信息。
7. 根据权利要求 1至 4中任一项所述的方法, 其中, 从所述终端的端口接收到用 于指示所述外部设备连接到所述端口的消息包括:
初始化套接字绑定所述终端本地的端口, 其中, 所述套接字为非阻塞的套 接字;
建立线程, 并通过所述线程接收所述消息。
8. 一种外部设备控制装置, 包括:
第一接收模块, 设置为从终端的端口接收到用于指示外部设备连接到所述 端口的消息;
确定模块, 设置为根据控制规则确定所述外部设备在所述终端上的权限; 控制模块, 设置为根据所述权限对所述外部设备进行控制。
9. 根据权利要求 8所述的装置, 其中, 所述外部设备在所述终端上的权限包括以 下至少之一:
是否允许所述外部设备挂载在所述终端上、 是否允许所述外部设备映射到 所述终端上运行的虚拟机上、所述外部设备在挂载在所述终端和 /或映射到所述 虚拟机上之后的读写权限。
10. 根据权利要求 8或 9所述的装置, 其中, 所述控制规则包括以下至少之一: 根据所述端口的信息确定所述外部设备在所述终端上的权限; 根据所述消息中携带的所述外部设备的信息确定所述外部设备在所述终端 上的权限;
根据所述终端上操作系统登录的用户或者该用户所属的用户组确定所述外 部设备在所述终端上的权限;
根据所述终端上运行虚拟机上的操作系统登录的用户或者该用户所属的用 户组确定所述外部设备在所述终端上的权限。
11. 根据权利要求 10所述的装置, 其中, 在所述外部设备为通用串行总线 USB设 备的情况下, 所述消息中携带的所述外部设备的信息包括以下至少之一: 所述外部设备的厂商标识 VID、 所述外部设备的产品标识 PID、 所述外部 设备的基类 Class、 所述外部设备的子类 Subclass 所述外部设备的协议。
12. 根据权利要求 8至 11中任一项所述的装置,其中,所述控制规则是在所述终端 本地制定的, 和 /或, 所述控制规则是由远程控制端下发的。
13. 根据权利要求 12所述的装置, 其中, 所述装置还包括:
第二接收模块, 设置为接收到来自所述远程控制端的查询消息; 上报模块,设置为根据所述查询消息上报所述终端的端口信息和 /或所述终 端的端口上连接的外部设备的信息。
14. 根据权利要求 8至 11中任一项所述的装置,其中,所述第一接收模块设置为初 始化套接字绑定所述终端本地的端口, 并建立线程, 通过所述线程接收所述消 息, 其中, 所述套接字为非阻塞的套接字。
PCT/CN2014/075847 2013-11-20 2014-04-21 外部设备控制方法及装置 WO2014180244A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310590621.5A CN104657690A (zh) 2013-11-20 2013-11-20 外部设备控制方法及装置
CN201310590621.5 2013-11-20

Publications (1)

Publication Number Publication Date
WO2014180244A1 true WO2014180244A1 (zh) 2014-11-13

Family

ID=51866706

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/075847 WO2014180244A1 (zh) 2013-11-20 2014-04-21 外部设备控制方法及装置

Country Status (2)

Country Link
CN (1) CN104657690A (zh)
WO (1) WO2014180244A1 (zh)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107341039A (zh) * 2016-04-28 2017-11-10 中兴通讯股份有限公司 一种虚拟环境下对usb设备进行管理的方法、主机和系统
CN106250758A (zh) * 2016-07-06 2016-12-21 北京元心科技有限公司 一种存储设备接入控制方法和系统
CN106372490A (zh) * 2016-08-30 2017-02-01 王竞 外部设备连接方法及数据接口装置
CN106446698B (zh) * 2016-08-31 2019-06-07 杭州华途软件有限公司 一种基于mtp协议的移动终端数据防泄漏方法
CN107957900A (zh) * 2016-10-17 2018-04-24 中兴通讯股份有限公司 一种虚拟环境下对远程iso进行管控的方法及相关装置
CN108664799B (zh) * 2017-03-31 2023-03-14 腾讯科技(深圳)有限公司 设备管理应用的权限设置方法及装置
CN107943560A (zh) * 2017-11-27 2018-04-20 郑州云海信息技术有限公司 一种通用串行总线设备的挂载方法及挂载装置
CN108875428A (zh) * 2017-12-27 2018-11-23 北京安天网络安全技术有限公司 一种移动存储介质接入控制方法及装置
CN109889487B (zh) * 2018-12-29 2021-11-12 奇安信科技集团股份有限公司 外部设备接入终端的处理方法及装置
CN112035824A (zh) * 2020-08-31 2020-12-04 深信服科技股份有限公司 一种权限管理方法、装置、设备及计算机可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060053124A1 (en) * 2004-09-06 2006-03-09 Masahiro Nishio Information processing apparatus, information processing method, program, and storage medium
CN102567667A (zh) * 2011-12-13 2012-07-11 中标软件有限公司 一种智能信息设备及其操作系统
CN202795350U (zh) * 2012-09-05 2013-03-13 武汉世纪金桥安全技术有限公司 Usb端口管理装置
CN103384232A (zh) * 2012-05-02 2013-11-06 华为终端有限公司 身份认证的方法及装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4575028B2 (ja) * 2004-05-27 2010-11-04 株式会社日立製作所 ディスクアレイ装置およびその制御方法
CN101673215B (zh) * 2008-09-09 2012-12-12 联想(北京)有限公司 一种虚拟环境中用户管理装置及方法
CN101620579B (zh) * 2009-08-03 2011-07-27 福建升腾资讯有限公司 Windows中的磁盘访问控制系统及其方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060053124A1 (en) * 2004-09-06 2006-03-09 Masahiro Nishio Information processing apparatus, information processing method, program, and storage medium
CN102567667A (zh) * 2011-12-13 2012-07-11 中标软件有限公司 一种智能信息设备及其操作系统
CN103384232A (zh) * 2012-05-02 2013-11-06 华为终端有限公司 身份认证的方法及装置
CN202795350U (zh) * 2012-09-05 2013-03-13 武汉世纪金桥安全技术有限公司 Usb端口管理装置

Also Published As

Publication number Publication date
CN104657690A (zh) 2015-05-27

Similar Documents

Publication Publication Date Title
WO2014180244A1 (zh) 外部设备控制方法及装置
US10997092B2 (en) Enabling out-of-band hardware management via an in-band communications channel
US8627413B2 (en) System and method for authorization and management of connections and attachment of resources
US9578034B2 (en) Trusted peripheral device for a host in a shared electronic environment
KR101530472B1 (ko) 모바일 컴퓨팅 디바이스를 통한 관리형 usb 서비스들의 원격 전달을 위한 방법 및 장치
US11470120B2 (en) Providing different levels of resource access to a computing device that is connected to a dock
CN109067877B (zh) 一种云计算平台部署的控制方法、服务器及存储介质
CN108366051B (zh) 一种物联网感知数据共享系统
CN108108286A (zh) 数据收集方法和装置、服务器、存储介质
US9516700B1 (en) Cloud-based controller for managing access points
WO2008014647A1 (fr) Procédé d'entretien pour l'objet de gestion de capacité, procédé de gestion de capacité, système et terminal correspondants
WO2020119476A1 (zh) 联盟链信息发布控制方法及终端设备
US8103756B2 (en) Network access device capability alert mechanism
US8819663B2 (en) Acceleration of software modifications in networked devices
CN107566513B (zh) 测试设备dos环境数据采集方法和系统
CN112073555A (zh) Ip地址的配置方法、电子设备和计算机可读存储介质
US20230224216A1 (en) System and method for subscription limitation enforcement in distributed system
CN104253792A (zh) 基板管理控制器虚拟系统及方法
WO2024032474A1 (zh) 设备接入方法、数据交换方法及相关设备
CN112600744A (zh) 权限控制方法和装置、存储介质及电子装置
CN116028426B (zh) 一种多PCIe通路网卡及上送报文的单网口网卡驱动方法
JP2009098977A (ja) 周辺機器接続システム
WO2018145267A1 (zh) 一种转发器入网识别方法、sdn控制器及转发器
CN109150724A (zh) 一种通信方法和网卡
WO2019029183A1 (zh) 存储设备的访问方法、装置、存储介质及处理器

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14794806

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14794806

Country of ref document: EP

Kind code of ref document: A1