From: David Zeuthen Date: Wed, 23 May 2012 18:08:54 +0000 (-0400) Subject: Rename current polkit variables and also add some new ones X-Git-Tag: upstream/2.1.2~232 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3168b2bf0f212bf6a27a6d3ba22167ab21c7878e;p=platform%2Fupstream%2Fudisks2.git Rename current polkit variables and also add some new ones Signed-off-by: David Zeuthen --- diff --git a/src/udisksdaemonutil.c b/src/udisksdaemonutil.c index 0ed0d6a..a6287aa 100644 --- a/src/udisksdaemonutil.c +++ b/src/udisksdaemonutil.c @@ -398,6 +398,17 @@ udisks_daemon_util_setup_by_user (UDisksDaemon *daemon, 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. @@ -431,12 +442,36 @@ udisks_daemon_util_setup_by_user (UDisksDaemon *daemon, * * * - * udisks2.device + * device_file * If @object has a #UDisksBlock interface or #UDisksDrive interface, this property is set to the value of the Block:PreferredDevice property. If set, this is guaranteed to be a device file. * * - * udisks2.drive - * Like udisks2.device, 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 udisks2.device. + * drive + * Like device_file, 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 device_file. + * + * + * drive.wwn + * If @object has a #UDisksDrive, this is set to the World Wide Name (WWN). + * + * + * drive.serial + * If @object has a #UDisksDrive, this is set to the serial number (Serial). + * + * + * drive.vendor + * If @object has a #UDisksDrive, this is set to the vendor (Vendor). + * + * + * drive.model + * If @object has a #UDisksDrive, this is set to the model (Model). + * + * + * drive.revision + * If @object has a #UDisksDrive, this is set to the firmware revision (Revision). + * + * + * drive.removable + * If @object has a #UDisksDrive and drive is considered removable, set to true (Removable). * * * @@ -463,8 +498,8 @@ udisks_daemon_util_check_authorization_sync (UDisksDaemon *daemon, 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) @@ -495,7 +530,7 @@ udisks_daemon_util_check_authorization_sync (UDisksDaemon *daemon, } 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) @@ -520,24 +555,32 @@ udisks_daemon_util_check_authorization_sync (UDisksDaemon *daemon, 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), @@ -579,7 +622,7 @@ udisks_daemon_util_check_authorization_sync (UDisksDaemon *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); diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c index 85defd8..146f19e 100644 --- a/src/udiskslinuxblock.c +++ b/src/udiskslinuxblock.c @@ -1880,10 +1880,10 @@ handle_format (UDisksBlock *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)) { @@ -2243,10 +2243,10 @@ handle_open_for_backup (UDisksBlock *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; @@ -2307,10 +2307,10 @@ handle_open_for_restore (UDisksBlock *block, /* 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; diff --git a/src/udiskslinuxdrive.c b/src/udiskslinuxdrive.c index d8d7444..ebab037 100644 --- a/src/udiskslinuxdrive.c +++ b/src/udiskslinuxdrive.c @@ -740,10 +740,10 @@ handle_eject (UDisksDrive *_drive, /* 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)) { diff --git a/src/udiskslinuxdriveata.c b/src/udiskslinuxdriveata.c index afc6517..6c7c149 100644 --- a/src/udiskslinuxdriveata.c +++ b/src/udiskslinuxdriveata.c @@ -611,10 +611,10 @@ handle_smart_update (UDisksDriveAta *_drive, /* 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) @@ -622,10 +622,10 @@ handle_smart_update (UDisksDriveAta *_drive, /* 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 @@ -756,10 +756,10 @@ handle_smart_selftest_abort (UDisksDriveAta *_drive, /* 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; @@ -953,10 +953,10 @@ handle_smart_selftest_start (UDisksDriveAta *_drive, /* 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; diff --git a/src/udiskslinuxencrypted.c b/src/udiskslinuxencrypted.c index 9322e67..5fad4ef 100644 --- a/src/udiskslinuxencrypted.c +++ b/src/udiskslinuxencrypted.c @@ -346,10 +346,10 @@ handle_unlock (UDisksEncrypted *encrypted, /* 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")) @@ -577,10 +577,10 @@ handle_lock (UDisksEncrypted *encrypted, * 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; } @@ -698,10 +698,10 @@ handle_change_passphrase (UDisksEncrypted *encrypted, /* 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; diff --git a/src/udiskslinuxfilesystem.c b/src/udiskslinuxfilesystem.c index c46f446..b6ed08d 100644 --- a/src/udiskslinuxfilesystem.c +++ b/src/udiskslinuxfilesystem.c @@ -1216,10 +1216,10 @@ handle_mount (UDisksFilesystem *filesystem, /* 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)) @@ -1281,13 +1281,13 @@ handle_mount (UDisksFilesystem *filesystem, * 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; @@ -1377,10 +1377,10 @@ handle_mount (UDisksFilesystem *filesystem, /* 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)) @@ -1626,13 +1626,13 @@ handle_unmount (UDisksFilesystem *filesystem, * 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; @@ -1676,10 +1676,10 @@ handle_unmount (UDisksFilesystem *filesystem, * 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, @@ -1894,10 +1894,10 @@ handle_set_label (UDisksFilesystem *filesystem, /* 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"; diff --git a/src/udiskslinuxloop.c b/src/udiskslinuxloop.c index 44088bf..b83babb 100644 --- a/src/udiskslinuxloop.c +++ b/src/udiskslinuxloop.c @@ -238,10 +238,10 @@ handle_delete (UDisksLoop *loop, * 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; } @@ -416,10 +416,10 @@ handle_set_autoclear (UDisksLoop *loop, * 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; } diff --git a/src/udiskslinuxpartition.c b/src/udiskslinuxpartition.c index 7694ca6..195554d 100644 --- a/src/udiskslinuxpartition.c +++ b/src/udiskslinuxpartition.c @@ -259,10 +259,10 @@ handle_set_flags (UDisksPartition *partition, /* 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"; @@ -404,10 +404,10 @@ handle_set_name (UDisksPartition *partition, /* 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"; @@ -586,10 +586,10 @@ handle_set_type (UDisksPartition *partition, /* 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"; @@ -759,10 +759,10 @@ handle_delete (UDisksPartition *partition, /* 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"; diff --git a/src/udiskslinuxpartitiontable.c b/src/udiskslinuxpartitiontable.c index b348e69..055bd30 100644 --- a/src/udiskslinuxpartitiontable.c +++ b/src/udiskslinuxpartitiontable.c @@ -326,10 +326,10 @@ handle_create_partition (UDisksPartitionTable *table, /* 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"; diff --git a/src/udiskslinuxswapspace.c b/src/udiskslinuxswapspace.c index cf50857..2309c92 100644 --- a/src/udiskslinuxswapspace.c +++ b/src/udiskslinuxswapspace.c @@ -179,10 +179,10 @@ handle_start (UDisksSwapspace *swapspace, /* 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; @@ -253,10 +253,10 @@ handle_stop (UDisksSwapspace *swapspace, /* 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;