Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usbfilter ignore --product flag #4

Open
lo1ol opened this issue Jun 28, 2021 · 1 comment
Open

usbfilter ignore --product flag #4

lo1ol opened this issue Jun 28, 2021 · 1 comment

Comments

@lo1ol
Copy link

lo1ol commented Jun 28, 2021

Hi!

I noticed that when I create filter using usbfilter command the --product flag is ignored.

For example, this command:

VBoxManage.exe usbfilter add 0 --target "otus-astra-docker_default_1624884966310_75575" --name "Aktiv Rutoken ECP [0100]" --product "Rutoken ECP" --revision "0100" --productid "0030" --vendorid "0a89" --manufacturer "Aktiv"

creates this filter:

Index:                       0
Active:                      yes
Name:                        Any Rutoken ECP
VendorId:                    0a89
ProductId:                   0030
Revision:                    0100
Manufacturer:                Aktiv
Product:
Remote:
Serial Number:

I thik that the cause of this because you are forgot to set product field here.

switch (cmd.mAction)
{
case USBFilterCmd::Add:
{
if (cmd.mGlobal)
{
ComPtr<IHostUSBDeviceFilter> flt;
CHECK_ERROR_BREAK(host, CreateUSBDeviceFilter(f.mName.raw(),
flt.asOutParam()));
if (!f.mActive.isNull())
CHECK_ERROR_BREAK(flt, COMSETTER(Active)(f.mActive));
if (!f.mVendorId.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(VendorId)(f.mVendorId.raw()));
if (!f.mProductId.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(ProductId)(f.mProductId.raw()));
if (!f.mRevision.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Revision)(f.mRevision.raw()));
if (!f.mManufacturer.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Manufacturer)(f.mManufacturer.raw()));
if (!f.mSerialNumber.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(SerialNumber)(f.mSerialNumber.raw()));
if (!f.mMaskedInterfaces.isNull())
CHECK_ERROR_BREAK(flt, COMSETTER(MaskedInterfaces)(f.mMaskedInterfaces));
if (f.mAction != USBDeviceFilterAction_Null)
CHECK_ERROR_BREAK(flt, COMSETTER(Action)(f.mAction));
CHECK_ERROR_BREAK(host, InsertUSBDeviceFilter(cmd.mIndex, flt));
}
else
{
ComPtr<IUSBDeviceFilter> flt;
CHECK_ERROR_BREAK(flts, CreateDeviceFilter(f.mName.raw(),
flt.asOutParam()));
if (!f.mActive.isNull())
CHECK_ERROR_BREAK(flt, COMSETTER(Active)(f.mActive));
if (!f.mVendorId.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(VendorId)(f.mVendorId.raw()));
if (!f.mProductId.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(ProductId)(f.mProductId.raw()));
if (!f.mRevision.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Revision)(f.mRevision.raw()));
if (!f.mManufacturer.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Manufacturer)(f.mManufacturer.raw()));
if (!f.mRemote.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Remote)(f.mRemote.raw()));
if (!f.mSerialNumber.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(SerialNumber)(f.mSerialNumber.raw()));
if (!f.mMaskedInterfaces.isNull())
CHECK_ERROR_BREAK(flt, COMSETTER(MaskedInterfaces)(f.mMaskedInterfaces));
CHECK_ERROR_BREAK(flts, InsertDeviceFilter(cmd.mIndex, flt));
}
break;
}
case USBFilterCmd::Modify:
{
if (cmd.mGlobal)
{
SafeIfaceArray <IHostUSBDeviceFilter> coll;
CHECK_ERROR_BREAK(host, COMGETTER(USBDeviceFilters)(ComSafeArrayAsOutParam(coll)));
ComPtr<IHostUSBDeviceFilter> flt = coll[cmd.mIndex];
if (!f.mName.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Name)(f.mName.raw()));
if (!f.mActive.isNull())
CHECK_ERROR_BREAK(flt, COMSETTER(Active)(f.mActive));
if (!f.mVendorId.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(VendorId)(f.mVendorId.raw()));
if (!f.mProductId.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(ProductId)(f.mProductId.raw()));
if (!f.mRevision.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Revision)(f.mRevision.raw()));
if (!f.mManufacturer.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Manufacturer)(f.mManufacturer.raw()));
if (!f.mSerialNumber.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(SerialNumber)(f.mSerialNumber.raw()));
if (!f.mMaskedInterfaces.isNull())
CHECK_ERROR_BREAK(flt, COMSETTER(MaskedInterfaces)(f.mMaskedInterfaces));
if (f.mAction != USBDeviceFilterAction_Null)
CHECK_ERROR_BREAK(flt, COMSETTER(Action)(f.mAction));
}
else
{
SafeIfaceArray <IUSBDeviceFilter> coll;
CHECK_ERROR_BREAK(flts, COMGETTER(DeviceFilters)(ComSafeArrayAsOutParam(coll)));
ComPtr<IUSBDeviceFilter> flt = coll[cmd.mIndex];
if (!f.mName.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Name)(f.mName.raw()));
if (!f.mActive.isNull())
CHECK_ERROR_BREAK(flt, COMSETTER(Active)(f.mActive));
if (!f.mVendorId.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(VendorId)(f.mVendorId.raw()));
if (!f.mProductId.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(ProductId)(f.mProductId.raw()));
if (!f.mRevision.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Revision)(f.mRevision.raw()));
if (!f.mManufacturer.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Manufacturer)(f.mManufacturer.raw()));
if (!f.mRemote.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(Remote)(f.mRemote.raw()));
if (!f.mSerialNumber.isEmpty())
CHECK_ERROR_BREAK(flt, COMSETTER(SerialNumber)(f.mSerialNumber.raw()));
if (!f.mMaskedInterfaces.isNull())
CHECK_ERROR_BREAK(flt, COMSETTER(MaskedInterfaces)(f.mMaskedInterfaces));
}
break;

@lo1ol
Copy link
Author

lo1ol commented Jun 30, 2021

diff --git a/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp b/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
index cffa6aa5..92dda786 100644
--- a/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
+++ b/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
@@ -422,6 +422,8 @@ RTEXITCODE handleUSBFilter(HandlerArg *a)
                     CHECK_ERROR_BREAK(flt, COMSETTER(Revision)(f.mRevision.raw()));
                 if (!f.mManufacturer.isEmpty())
                     CHECK_ERROR_BREAK(flt, COMSETTER(Manufacturer)(f.mManufacturer.raw()));
+		if (!f.mProduct.isEmpty())
+                    CHECK_ERROR_BREAK(flt, COMSETTER(Product)(f.mProduct.raw()));
                 if (!f.mSerialNumber.isEmpty())
                     CHECK_ERROR_BREAK(flt, COMSETTER(SerialNumber)(f.mSerialNumber.raw()));
                 if (!f.mMaskedInterfaces.isNull())
@@ -448,6 +450,8 @@ RTEXITCODE handleUSBFilter(HandlerArg *a)
                     CHECK_ERROR_BREAK(flt, COMSETTER(Revision)(f.mRevision.raw()));
                 if (!f.mManufacturer.isEmpty())
                     CHECK_ERROR_BREAK(flt, COMSETTER(Manufacturer)(f.mManufacturer.raw()));
+                if (!f.mProduct.isEmpty())
+                    CHECK_ERROR_BREAK(flt, COMSETTER(Product)(f.mProduct.raw()));
                 if (!f.mRemote.isEmpty())
                     CHECK_ERROR_BREAK(flt, COMSETTER(Remote)(f.mRemote.raw()));
                 if (!f.mSerialNumber.isEmpty())
@@ -480,6 +484,8 @@ RTEXITCODE handleUSBFilter(HandlerArg *a)
                     CHECK_ERROR_BREAK(flt, COMSETTER(Revision)(f.mRevision.raw()));
                 if (!f.mManufacturer.isEmpty())
                     CHECK_ERROR_BREAK(flt, COMSETTER(Manufacturer)(f.mManufacturer.raw()));
+                if (!f.mProduct.isEmpty())
+                    CHECK_ERROR_BREAK(flt, COMSETTER(Product)(f.mProduct.raw()));
                 if (!f.mSerialNumber.isEmpty())
                     CHECK_ERROR_BREAK(flt, COMSETTER(SerialNumber)(f.mSerialNumber.raw()));
                 if (!f.mMaskedInterfaces.isNull())
@@ -507,6 +513,8 @@ RTEXITCODE handleUSBFilter(HandlerArg *a)
                     CHECK_ERROR_BREAK(flt, COMSETTER(Revision)(f.mRevision.raw()));
                 if (!f.mManufacturer.isEmpty())
                     CHECK_ERROR_BREAK(flt, COMSETTER(Manufacturer)(f.mManufacturer.raw()));
+                if (!f.mProduct.isEmpty())
+                    CHECK_ERROR_BREAK(flt, COMSETTER(Product)(f.mProduct.raw()));
                 if (!f.mRemote.isEmpty())
                     CHECK_ERROR_BREAK(flt, COMSETTER(Remote)(f.mRemote.raw()));
                 if (!f.mSerialNumber.isEmpty())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant