If you want to add PolicyKit rules for single USB storage devices, e.g. for access restrictions, it's very inconvenient to use the mapped strings from the usb.ids file.
The attached patch adds the vendor and product hex strings to udisks and the exported PolicyKit properties. --- data/org.freedesktop.UDisks2.xml | 4 ++++ doc/udisks2-sections.txt | 2 ++ src/udisksdaemonutil.c | 2 ++ src/udiskslinuxdrive.c | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/data/org.freedesktop.UDisks2.xml b/data/org.freedesktop.UDisks2.xml index 6e40c9b..19e502e 100644 --- a/data/org.freedesktop.UDisks2.xml +++ b/data/org.freedesktop.UDisks2.xml @@ -102,8 +102,12 @@ <interface name="org.freedesktop.UDisks2.Drive"> <!-- Vendor: A name for the vendor of the drive or blank if unknown. --> <property name="Vendor" type="s" access="read"/> + <!-- VendorId: 16 bit hex value as string 0xXXXX. --> + <property name="VendorId" type="s" access="read"/> <!-- Model: A name for the model of the drive or blank if unknown. --> <property name="Model" type="s" access="read"/> + <!-- ModelId: 16 bit hex value as string 0xXXXX. --> + <property name="ModelId" type="s" access="read"/> <!-- Revision: Firmware Revision or blank if unknown. --> <property name="Revision" type="s" access="read"/> <!-- Serial: Serial number of the drive or blank if unknown. --> diff --git a/doc/udisks2-sections.txt b/doc/udisks2-sections.txt index 897f48a..dcbe368 100644 --- a/doc/udisks2-sections.txt +++ b/doc/udisks2-sections.txt @@ -607,10 +607,12 @@ udisks_drive_get_optical_num_audio_tracks udisks_drive_get_optical_num_data_tracks udisks_drive_get_optical_num_sessions udisks_drive_get_model +udisks_drive_get_model_id udisks_drive_get_revision udisks_drive_get_rotation_rate udisks_drive_get_serial udisks_drive_get_vendor +udisks_drive_get_vendor_id udisks_drive_get_wwn udisks_drive_get_sort_key udisks_drive_get_configuration diff --git a/src/udisksdaemonutil.c b/src/udisksdaemonutil.c index fb50a0f..31dda31 100644 --- a/src/udisksdaemonutil.c +++ b/src/udisksdaemonutil.c @@ -634,7 +634,9 @@ udisks_daemon_util_check_authorization_sync (UDisksDaemon *daemon, _safe_polkit_details_insert (details, "drive.wwn", udisks_drive_get_wwn (drive)); _safe_polkit_details_insert (details, "drive.serial", udisks_drive_get_serial (drive)); _safe_polkit_details_insert (details, "drive.vendor", udisks_drive_get_vendor (drive)); + _safe_polkit_details_insert (details, "drive.vendor_id", udisks_drive_get_vendor_id (drive)); _safe_polkit_details_insert (details, "drive.model", udisks_drive_get_model (drive)); + _safe_polkit_details_insert (details, "drive.model_id", udisks_drive_get_model_id (drive)); _safe_polkit_details_insert (details, "drive.revision", udisks_drive_get_revision (drive)); if (udisks_drive_get_removable (drive)) polkit_details_insert (details, "drive.removable", "true"); diff --git a/src/udiskslinuxdrive.c b/src/udiskslinuxdrive.c index 170ba27..a9a9d73 100644 --- a/src/udiskslinuxdrive.c +++ b/src/udiskslinuxdrive.c @@ -781,6 +781,8 @@ udisks_linux_drive_update (UDisksLinuxDrive *drive, const gchar *model; const gchar *name; const gchar *serial; + const gchar *model_id; + const gchar *vendor_id; name = g_udev_device_get_name (device->udev_device); @@ -842,6 +844,22 @@ udisks_linux_drive_update (UDisksLinuxDrive *drive, } } + model_id = g_udev_device_get_property (device->udev_device, "ID_MODEL_ID"); + if (model_id != NULL) + { + gchar *hex = g_strconcat ("0x", model_id, NULL); + udisks_drive_set_model_id (iface, hex); + g_free (hex); + } + + vendor_id = g_udev_device_get_property (device->udev_device, "ID_VENDOR_ID"); + if (vendor_id != NULL) + { + gchar *hex = g_strconcat ("0x", vendor_id, NULL); + udisks_drive_set_vendor_id (iface, hex); + g_free (hex); + } + serial = g_udev_device_get_property (device->udev_device, "ID_SERIAL_SHORT"); if (serial == NULL) serial = g_udev_device_get_property (device->udev_device, "ID_SERIAL"); -- 1.8.3.3 _______________________________________________ devkit-devel mailing list devkit-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/devkit-devel