Allowing users to recognize which USB devices they have forwarded to the remote Linux host

ID: FR04Q03811 Priority: Low
Products: NoMachine Device Services Target: 6
Status: Approved  
When different users connected simultaneously to the same remote Linux host and forward their local USB devices, it is not possible to identify which user forwarded a specific USB device. All the forwarded devices are treated as devices physically connected to the remote host and there's no way to retrieve information from the system about the user who connected them.

NoMachine should implement a mechanism to store on the remote host information about each user who forwarded a device. Such information is saved in the /usr/NX/var/run/nxdevice/D-<sessionID>/usb file according to this format:

<username>,<session display>,<device name>,<device hub number>-<device port number>,<status>,<device nodes>
 
<device nodes> may contain one or more device nodes separated by a semicolon, ';'.  If nodes for the device are not available, this field will remain empty.
 
The 'usb' file should be accessible only by the user who created it (or a privileged user like root or a 'sudo' user).
 
A new node command allows to retrieve information for all the forwarded devices and the correspondent user who forwarded them. This command reads all /usr/NX/var/run/nxdevice/D-*/usb files and merge their content.

The description of the node command is:

--usblist [--nodes]

List all the USB devices connected to this host. If --node is given,
displays also also the list of connected device nodes. This command
is available only on Linux.
 
Note that the output of this command, when run from command line reports by default the following information:
Username | Session ID | Device name | Hub-Port | Status
 
If the --nodes option is provided, the output will be formatted in this way:
Username | Session ID | Device name | Hub-Port | Status | Nodes
 
This feature should be supported on all Linux kernels with version higher than v. 3.0.
It's propaedeutic to https://www.nomachine.com/FR04Q03828.