diff options
| author | David Zeuthen <davidz@redhat.com> | 2009-02-15 00:49:07 -0500 |
|---|---|---|
| committer | David Zeuthen <davidz@redhat.com> | 2009-02-15 00:49:07 -0500 |
| commit | e72be2d5b6d9e60e6ceed01cd3fbd09a150c1a3c (patch) | |
| tree | ae1ed7d6c6a29e3e2f2d399d6ffbb827ceda274f /src | |
| parent | f52da04b42d62b69851fd3086c1f98daa4825044 (diff) | |
export API for new cryptotext LUKS properties exposed by the DK-disks daemon
Diffstat (limited to 'src')
| -rw-r--r-- | src/gdu/gdu-device.c | 104 | ||||
| -rw-r--r-- | src/gdu/gdu-device.h | 3 |
2 files changed, 67 insertions, 40 deletions
diff --git a/src/gdu/gdu-device.c b/src/gdu/gdu-device.c index 3dba0db..d872557 100644 --- a/src/gdu/gdu-device.c +++ b/src/gdu/gdu-device.c @@ -57,6 +57,7 @@ typedef struct gboolean device_is_read_only; gboolean device_is_drive; gboolean device_is_optical_disc; + gboolean device_is_luks; gboolean device_is_luks_cleartext; gboolean device_is_mounted; gboolean device_is_busy; @@ -98,6 +99,8 @@ typedef struct GArray *partition_table_offsets; GArray *partition_table_sizes; + char *luks_holder; + char *luks_cleartext_slave; uid_t luks_cleartext_unlocked_by_uid; @@ -179,6 +182,8 @@ collect_props (const char *key, const GValue *value, DeviceProperties *props) props->device_is_drive = g_value_get_boolean (value); else if (strcmp (key, "device-is-optical-disc") == 0) props->device_is_optical_disc = g_value_get_boolean (value); + else if (strcmp (key, "device-is-luks") == 0) + props->device_is_luks = g_value_get_boolean (value); else if (strcmp (key, "device-is-luks-cleartext") == 0) props->device_is_luks_cleartext = g_value_get_boolean (value); else if (strcmp (key, "device-is-linux-md-component") == 0) @@ -263,6 +268,9 @@ collect_props (const char *key, const GValue *value, DeviceProperties *props) props->partition_table_sizes = g_value_get_boxed (&dest_value); } + else if (strcmp (key, "luks-holder") == 0) + props->luks_holder = g_strdup (g_value_get_boxed (value)); + else if (strcmp (key, "luks-cleartext-slave") == 0) props->luks_cleartext_slave = g_strdup (g_value_get_boxed (value)); else if (strcmp (key, "luks-cleartext-unlocked-by-uid") == 0) @@ -376,46 +384,6 @@ collect_props (const char *key, const GValue *value, DeviceProperties *props) g_warning ("unhandled property '%s'", key); } -static DeviceProperties * -device_properties_get (DBusGConnection *bus, - const char *object_path) -{ - DeviceProperties *props; - GError *error; - GHashTable *hash_table; - DBusGProxy *prop_proxy; - const char *ifname = "org.freedesktop.DeviceKit.Disks.Device"; - - props = g_new0 (DeviceProperties, 1); - - prop_proxy = dbus_g_proxy_new_for_name (bus, - "org.freedesktop.DeviceKit.Disks", - object_path, - "org.freedesktop.DBus.Properties"); - error = NULL; - if (!dbus_g_proxy_call (prop_proxy, - "GetAll", - &error, - G_TYPE_STRING, - ifname, - G_TYPE_INVALID, - dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), - &hash_table, - G_TYPE_INVALID)) { - g_warning ("Couldn't call GetAll() to get properties for %s: %s", object_path, error->message); - g_error_free (error); - goto out; - } - - g_hash_table_foreach (hash_table, (GHFunc) collect_props, props); - - g_hash_table_unref (hash_table); - -out: - g_object_unref (prop_proxy); - return props; -} - static void device_properties_free (DeviceProperties *props) { @@ -439,6 +407,7 @@ device_properties_free (DeviceProperties *props) g_free (props->partition_table_scheme); g_array_free (props->partition_table_offsets, TRUE); g_array_free (props->partition_table_sizes, TRUE); + g_free (props->luks_holder); g_free (props->luks_cleartext_slave); g_free (props->drive_model); g_free (props->drive_vendor); @@ -461,6 +430,49 @@ device_properties_free (DeviceProperties *props) g_free (props); } +static DeviceProperties * +device_properties_get (DBusGConnection *bus, + const char *object_path) +{ + DeviceProperties *props; + GError *error; + GHashTable *hash_table; + DBusGProxy *prop_proxy; + const char *ifname = "org.freedesktop.DeviceKit.Disks.Device"; + + props = g_new0 (DeviceProperties, 1); + + prop_proxy = dbus_g_proxy_new_for_name (bus, + "org.freedesktop.DeviceKit.Disks", + object_path, + "org.freedesktop.DBus.Properties"); + error = NULL; + if (!dbus_g_proxy_call (prop_proxy, + "GetAll", + &error, + G_TYPE_STRING, + ifname, + G_TYPE_INVALID, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE), + &hash_table, + G_TYPE_INVALID)) { + g_warning ("Couldn't call GetAll() to get properties for %s: %s", object_path, error->message); + g_error_free (error); + + device_properties_free (props); + props = NULL; + goto out; + } + + g_hash_table_foreach (hash_table, (GHFunc) collect_props, props); + + g_hash_table_unref (hash_table); + +out: + g_object_unref (prop_proxy); + return props; +} + /* --- SUCKY CODE END --- */ struct _GduDevicePrivate @@ -729,6 +741,12 @@ gdu_device_is_partition_table (GduDevice *device) } gboolean +gdu_device_is_luks (GduDevice *device) +{ + return device->priv->props->device_is_luks; +} + +gboolean gdu_device_is_luks_cleartext (GduDevice *device) { return device->priv->props->device_is_luks_cleartext; @@ -890,6 +908,12 @@ gdu_device_partition_table_get_sizes (GduDevice *device) } const char * +gdu_device_luks_get_holder (GduDevice *device) +{ + return device->priv->props->luks_holder; +} + +const char * gdu_device_luks_cleartext_get_slave (GduDevice *device) { return device->priv->props->luks_cleartext_slave; diff --git a/src/gdu/gdu-device.h b/src/gdu/gdu-device.h index ef79adf..9d35db2 100644 --- a/src/gdu/gdu-device.h +++ b/src/gdu/gdu-device.h @@ -78,6 +78,7 @@ gboolean gdu_device_is_partition (GduDevice *device); gboolean gdu_device_is_partition_table (GduDevice *device); gboolean gdu_device_is_drive (GduDevice *device); gboolean gdu_device_is_optical_disc (GduDevice *device); +gboolean gdu_device_is_luks (GduDevice *device); gboolean gdu_device_is_luks_cleartext (GduDevice *device); gboolean gdu_device_is_linux_md_component (GduDevice *device); gboolean gdu_device_is_linux_md (GduDevice *device); @@ -117,6 +118,8 @@ int gdu_device_partition_table_get_max_number (GduDevice *device); GArray *gdu_device_partition_table_get_offsets (GduDevice *device); GArray *gdu_device_partition_table_get_sizes (GduDevice *device); +const char *gdu_device_luks_get_holder (GduDevice *device); + const char *gdu_device_luks_cleartext_get_slave (GduDevice *device); uid_t gdu_device_luks_cleartext_unlocked_by_uid (GduDevice *device); |
