return ret;
}
+/* Need this until we can depend on a libpolkit with this bugfix
+ *
+ * http://cgit.freedesktop.org/polkit/commit/?h=wip/js-rule-files&id=224f7b892478302dccbe7e567b013d3c73d376fd
+ */
+static void
+_safe_polkit_details_insert (PolkitDetails *details, const gchar *key, const gchar *value)
+{
+ if (value != NULL)
+ polkit_details_insert (details, key, value);
+}
+
/**
* udisks_daemon_util_check_authorization_sync:
* @daemon: A #UDisksDaemon.
* </thead>
* <tbody>
* <row>
- * <entry><parameter>udisks2.device</parameter></entry>
+ * <entry><parameter>device_file</parameter></entry>
* <entry>If @object has a #UDisksBlock interface or #UDisksDrive interface, this property is set to the value of the <link linkend="gdbus-property-org-freedesktop-UDisks2-Block.PreferredDevice">Block:PreferredDevice</link> property. If set, this is guaranteed to be a device file.</entry>
* </row>
* <row>
- * <entry><parameter>udisks2.drive</parameter></entry>
- * <entry>Like <parameter>udisks2.device</parameter>, but also includes Vital Product Data about the drive e.g. vendor/model (if available), for example "INTEL SSDSA2MH080G1GC (/dev/sda1)". Otherwise is just set to the same value as <parameter>udisks2.device</parameter>.</entry>
+ * <entry><parameter>drive</parameter></entry>
+ * <entry>Like <parameter>device_file</parameter>, but also includes Vital Product Data about the drive e.g. vendor/model (if available), for example "INTEL SSDSA2MH080G1GC (/dev/sda1)". Otherwise is just set to the same value as <parameter>device_file</parameter>.</entry>
+ * </row>
+ * <row>
+ * <entry><parameter>drive.wwn</parameter></entry>
+ * <entry>If @object has a #UDisksDrive, this is set to the World Wide Name (<link linkend="gdbus-property-org-freedesktop-UDisks2-Drive.WWN">WWN</link>).</entry>
+ * </row>
+ * <row>
+ * <entry><parameter>drive.serial</parameter></entry>
+ * <entry>If @object has a #UDisksDrive, this is set to the serial number (<link linkend="gdbus-property-org-freedesktop-UDisks2-Drive.Serial">Serial</link>).</entry>
+ * </row>
+ * <row>
+ * <entry><parameter>drive.vendor</parameter></entry>
+ * <entry>If @object has a #UDisksDrive, this is set to the vendor (<link linkend="gdbus-property-org-freedesktop-UDisks2-Drive.Vendor">Vendor</link>).</entry>
+ * </row>
+ * <row>
+ * <entry><parameter>drive.model</parameter></entry>
+ * <entry>If @object has a #UDisksDrive, this is set to the model (<link linkend="gdbus-property-org-freedesktop-UDisks2-Drive.Model">Model</link>).</entry>
+ * </row>
+ * <row>
+ * <entry><parameter>drive.revision</parameter></entry>
+ * <entry>If @object has a #UDisksDrive, this is set to the firmware revision (<link linkend="gdbus-property-org-freedesktop-UDisks2-Drive.Revision">Revision</link>).</entry>
+ * </row>
+ * <row>
+ * <entry><parameter>drive.removable</parameter></entry>
+ * <entry>If @object has a #UDisksDrive and drive is considered removable, set to <quote>true</quote> (<link linkend="gdbus-property-org-freedesktop-UDisks2-Drive.Removable">Removable</link>).</entry>
* </row>
* </tbody>
* </tgroup>
UDisksObject *block_object = NULL;
UDisksObject *drive_object = NULL;
gboolean auth_no_user_interaction = FALSE;
- const gchar *details_udisks2_device = NULL;
- gchar *details_udisks2_drive = NULL;
+ const gchar *details_device = NULL;
+ gchar *details_drive = NULL;
subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (invocation));
if (options != NULL)
}
if (block != NULL)
- details_udisks2_device = udisks_block_get_preferred_device (block);
+ details_device = udisks_block_get_preferred_device (block);
/* If we have a drive, use vendor/model in the message (in addition to Block:preferred-device) */
if (drive != NULL)
if (block != NULL)
{
- details_udisks2_drive = g_strdup_printf ("%s (%s)", s, udisks_block_get_preferred_device (block));
+ details_drive = g_strdup_printf ("%s (%s)", s, udisks_block_get_preferred_device (block));
}
else
{
- details_udisks2_drive = s;
+ details_drive = s;
s = NULL;
}
g_free (s);
+
+ _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.model", udisks_drive_get_model (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");
}
/* Fall back to Block:preferred-device */
- if (details_udisks2_drive == NULL && block != NULL)
- details_udisks2_drive = udisks_block_dup_preferred_device (block);
+ if (details_drive == NULL && block != NULL)
+ details_drive = udisks_block_dup_preferred_device (block);
- if (details_udisks2_device != NULL)
- polkit_details_insert (details, "udisks2.device", details_udisks2_device);
- if (details_udisks2_drive != NULL)
- polkit_details_insert (details, "udisks2.drive", details_udisks2_drive);
+ if (details_device != NULL)
+ polkit_details_insert (details, "device_file", details_device);
+ if (details_drive != NULL)
+ polkit_details_insert (details, "drive", details_drive);
error = NULL;
result = polkit_authority_check_authorization_sync (udisks_daemon_get_authority (daemon),
ret = TRUE;
out:
- g_free (details_udisks2_drive);
+ g_free (details_drive);
g_clear_object (&block_object);
g_clear_object (&drive_object);
g_clear_object (&block);
* device. This includes both creating a filesystem or partition
* table.
*
- * Do not translate $(udisks2.drive), it's a placeholder and will
+ * Do not translate $(drive), it's a placeholder and will
* be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to format $(udisks2.drive)");
+ message = N_("Authentication is required to format $(drive)");
action_id = "org.freedesktop.udisks2.modify-device";
if (udisks_block_get_hint_system (block))
{
/* Translators: Shown in authentication dialog when creating a
* disk image file.
*
- * Do not translate $(udisks2.drive), it's a placeholder and will
+ * Do not translate $(drive), it's a placeholder and will
* be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to open $(udisks2.drive) for reading"),
+ N_("Authentication is required to open $(drive) for reading"),
invocation))
goto out;
/* Translators: Shown in authentication dialog when restoring
* from a disk image file.
*
- * Do not translate $(udisks2.drive), it's a placeholder and will
+ * Do not translate $(drive), it's a placeholder and will
* be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to open $(udisks2.drive) for writing"),
+ N_("Authentication is required to open $(drive) for writing"),
invocation))
goto out;
/* Translators: Shown in authentication dialog when the user
* requests ejecting media from a drive.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to eject $(udisks2.drive)");
+ message = N_("Authentication is required to eject $(drive)");
action_id = "org.freedesktop.udisks2.eject-media";
if (udisks_block_get_hint_system (block))
{
/* Translators: Shown in authentication dialog when the user
* refreshes SMART data from a disk.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to update SMART data from $(udisks2.drive)");
+ message = N_("Authentication is required to update SMART data from $(drive)");
action_id = "org.freedesktop.udisks2.ata-smart-update";
if (atasmart_blob != NULL)
/* Translators: Shown in authentication dialog when the user
* tries to simulate SMART data from a libatasmart blob.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to set SMART data from a blob on $(udisks2.drive)");
+ message = N_("Authentication is required to set SMART data from a blob on $(drive)");
action_id = "org.freedesktop.udisks2.ata-smart-simulate";
}
else
/* Translators: Shown in authentication dialog when the user
* aborts a running SMART self-test.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to abort a SMART self-test on $(udisks2.drive)"),
+ N_("Authentication is required to abort a SMART self-test on $(drive)"),
invocation))
goto out;
/* Translators: Shown in authentication dialog when the user
* initiates a SMART self-test.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to start a SMART self-test on $(udisks2.drive)"),
+ N_("Authentication is required to start a SMART self-test on $(drive)"),
invocation))
goto out;
/* Translators: Shown in authentication dialog when the user
* requests unlocking an encrypted device.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to unlock the encrypted device $(udisks2.drive)");
+ message = N_("Authentication is required to unlock the encrypted device $(drive)");
if (!udisks_daemon_util_setup_by_user (daemon, object, caller_uid))
{
if (is_in_crypttab && has_option (crypttab_options, "x-udisks-auth"))
* requests locking an encrypted device that was previously.
* unlocked by another user.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to lock the encrypted device $(udisks2.drive) unlocked by another user"),
+ N_("Authentication is required to lock the encrypted device $(drive) unlocked by another user"),
invocation))
goto out;
}
/* Translators: Shown in authentication dialog when the user
* requests unlocking an encrypted device.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to unlock the encrypted device $(udisks2.drive)"),
+ N_("Authentication is required to unlock the encrypted device $(drive)"),
invocation))
goto out;
/* Translators: Shown in authentication dialog when the user
* requests mounting a filesystem.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to mount $(udisks2.drive)");
+ message = N_("Authentication is required to mount $(drive)");
if (!udisks_daemon_util_setup_by_user (daemon, object, caller_uid))
{
if (udisks_block_get_hint_system (block))
* user requests mounting a filesystem that is in
* /etc/fstab file with the x-udisks-auth option.
*
- * Do not translate $(udisks2.drive), it's a
+ * Do not translate $(drive), it's a
* placeholder and will be replaced by the name of
* the drive/device in question
*
* Do not translate /etc/fstab
*/
- N_("Authentication is required to mount $(udisks2.drive) referenced in the /etc/fstab file"),
+ N_("Authentication is required to mount $(drive) referenced in the /etc/fstab file"),
invocation))
goto out;
mount_fstab_as_root = TRUE;
/* Translators: Shown in authentication dialog when the user
* requests mounting a filesystem.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to mount $(udisks2.drive)");
+ message = N_("Authentication is required to mount $(drive)");
if (!udisks_daemon_util_setup_by_user (daemon, object, caller_uid))
{
if (udisks_block_get_hint_system (block))
* user requests unmounting a filesystem that is in
* /etc/fstab file with the x-udisks-auth option.
*
- * Do not translate $(udisks2.drive), it's a
+ * Do not translate $(drive), it's a
* placeholder and will be replaced by the name of
* the drive/device in question
*
* Do not translate /etc/fstab
*/
- N_("Authentication is required to unmount $(udisks2.drive) referenced in the /etc/fstab file"),
+ N_("Authentication is required to unmount $(drive) referenced in the /etc/fstab file"),
invocation))
goto out;
unmount_fstab_as_root = TRUE;
* requests unmounting a filesystem previously mounted by
* another user.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to unmount $(udisks2.drive) mounted by another user");
+ message = N_("Authentication is required to unmount $(drive) mounted by another user");
if (!udisks_daemon_util_check_authorization_sync (daemon,
object,
/* Translators: Shown in authentication dialog when the user
* requests changing the filesystem label.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to change the filesystem label on $(udisks2.drive)");
+ message = N_("Authentication is required to change the filesystem label on $(drive)");
if (udisks_block_get_hint_system (block))
{
action_id = "org.freedesktop.udisks2.modify-device-system";
* requests deleting a loop device previously set up by
* another user.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to delete the loop device $(udisks2.drive)"),
+ N_("Authentication is required to delete the loop device $(drive)"),
invocation))
goto out;
}
* requests changing autoclear on a loop device set up by
* another user.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to modify the loop device $(udisks2.drive)"),
+ N_("Authentication is required to modify the loop device $(drive)"),
invocation))
goto out;
}
/* Translators: Shown in authentication dialog when the user
* requests modifying a partition (changing type, flags, name etc.).
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to modify the partition on device $(udisks2.drive)");
+ message = N_("Authentication is required to modify the partition on device $(drive)");
if (udisks_block_get_hint_system (block))
{
action_id = "org.freedesktop.udisks2.modify-device-system";
/* Translators: Shown in authentication dialog when the user
* requests modifying a partition (changing type, flags, name etc.).
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to modify the partition on device $(udisks2.drive)");
+ message = N_("Authentication is required to modify the partition on device $(drive)");
if (udisks_block_get_hint_system (block))
{
action_id = "org.freedesktop.udisks2.modify-device-system";
/* Translators: Shown in authentication dialog when the user
* requests modifying a partition (changing type, flags, name etc.).
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to modify the partition on device $(udisks2.drive)");
+ message = N_("Authentication is required to modify the partition on device $(drive)");
if (udisks_block_get_hint_system (block))
{
action_id = "org.freedesktop.udisks2.modify-device-system";
/* Translators: Shown in authentication dialog when the user
* requests deleting a partition.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to delete the partition $(udisks2.drive)");
+ message = N_("Authentication is required to delete the partition $(drive)");
if (udisks_block_get_hint_system (block))
{
action_id = "org.freedesktop.udisks2.modify-device-system";
/* Translators: Shown in authentication dialog when the user
* requests creating a new partition.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- message = N_("Authentication is required to create a partition on $(udisks2.drive)");
+ message = N_("Authentication is required to create a partition on $(drive)");
if (udisks_block_get_hint_system (block))
{
action_id = "org.freedesktop.udisks2.modify-device-system";
/* Translators: Shown in authentication dialog when the user
* requests activating a swap device.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to activate swapspace on $(udisks2.drive)"),
+ N_("Authentication is required to activate swapspace on $(drive)"),
invocation))
goto out;
/* Translators: Shown in authentication dialog when the user
* requests deactivating a swap device.
*
- * Do not translate $(udisks2.drive), it's a placeholder and
+ * Do not translate $(drive), it's a placeholder and
* will be replaced by the name of the drive/device in question
*/
- N_("Authentication is required to deactivate swapspace on $(udisks2.drive)"),
+ N_("Authentication is required to deactivate swapspace on $(drive)"),
invocation))
goto out;