idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
9,300
device_partition_create (Device *device, guint64 offset, guint64 size, const char *type, const char *label, char **flags, char **options, const char *fstype, char **fsoptions, DBusGMethodInvocation *context) { if (!device->priv->device_is_partition_table) { throw_error (context, ERROR_FAILED, "Device is not partitioned"); goto out; } daemon_local_check_auth (device->priv->daemon, device, device->priv->device_is_system_internal ? "org.freedesktop.udisks.change-system-internal" : "org.freedesktop.udisks.change", "PartitionCreate", TRUE, device_partition_create_authorized_cb, context, 8, g_memdup (&offset, sizeof(guint64)), g_free, g_memdup (&size, sizeof(guint64)), g_free, g_strdup (type), g_free, g_strdup (label), g_free, g_strdupv (flags), g_strfreev, g_strdupv (options), g_strfreev, g_strdup (fstype), g_free, g_strdupv (fsoptions), g_strfreev); out: return TRUE; }
+Info
0
device_partition_create (Device *device, guint64 offset, guint64 size, const char *type, const char *label, char **flags, char **options, const char *fstype, char **fsoptions, DBusGMethodInvocation *context) { if (!device->priv->device_is_partition_table) { throw_error (context, ERROR_FAILED, "Device is not partitioned"); goto out; } daemon_local_check_auth (device->priv->daemon, device, device->priv->device_is_system_internal ? "org.freedesktop.udisks.change-system-internal" : "org.freedesktop.udisks.change", "PartitionCreate", TRUE, device_partition_create_authorized_cb, context, 8, g_memdup (&offset, sizeof(guint64)), g_free, g_memdup (&size, sizeof(guint64)), g_free, g_strdup (type), g_free, g_strdup (label), g_free, g_strdupv (flags), g_strfreev, g_strdupv (options), g_strfreev, g_strdup (fstype), g_free, g_strdupv (fsoptions), g_strfreev); out: return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,301
device_partition_create_authorized_cb (Daemon *daemon, Device *device, DBusGMethodInvocation *context, const gchar *action_id, guint num_user_data, gpointer *user_data_elements) { guint64 offset = *((guint64*) user_data_elements[0]); guint64 size = *((guint64*) user_data_elements[1]); ; const char *type = user_data_elements[2]; const char *label = user_data_elements[3]; char **flags = user_data_elements[4]; char **options = user_data_elements[5]; const char *fstype = user_data_elements[6]; char **fsoptions = user_data_elements[7]; int n; int m; char *argv[128]; GError *error; char *offset_as_string; char *size_as_string; char *flags_as_string; offset_as_string = NULL; size_as_string = NULL; flags_as_string = NULL; error = NULL; if (!device->priv->device_is_partition_table) { throw_error (context, ERROR_FAILED, "Device is not partitioned"); goto out; } if (device_local_is_busy (device, FALSE, &error)) { dbus_g_method_return_error (context, error); g_error_free (error); goto out; } /* partutil.c / libparted will check there are no partitions in the requested slice */ offset_as_string = g_strdup_printf ("%" G_GINT64_FORMAT "", offset); size_as_string = g_strdup_printf ("%" G_GINT64_FORMAT "", size); /* TODO: check that neither of the flags include ',' */ flags_as_string = g_strjoinv (",", flags); n = 0; argv[n++] = "udisks-helper-create-partition"; if (device->priv->device_is_linux_dmmp) argv[n++] = (gchar *) get_dmmp_device_node (device); else argv[n++] = device->priv->device_file; argv[n++] = offset_as_string; argv[n++] = size_as_string; argv[n++] = (char *) type; argv[n++] = (char *) label; argv[n++] = (char *) flags_as_string; for (m = 0; options[m] != NULL; m++) { if (n >= (int) sizeof(argv) - 1) { throw_error (context, ERROR_FAILED, "Too many options"); goto out; } /* the helper will validate each option */ argv[n++] = (char *) options[m]; } argv[n++] = NULL; if (!job_new (context, "PartitionCreate", TRUE, device, argv, NULL, partition_create_completed_cb, FALSE, partition_create_data_new (context, device, offset, size, fstype, fsoptions), (GDestroyNotify) partition_create_data_unref)) { goto out; } out: g_free (offset_as_string); g_free (size_as_string); g_free (flags_as_string); }
+Info
0
device_partition_create_authorized_cb (Daemon *daemon, Device *device, DBusGMethodInvocation *context, const gchar *action_id, guint num_user_data, gpointer *user_data_elements) { guint64 offset = *((guint64*) user_data_elements[0]); guint64 size = *((guint64*) user_data_elements[1]); ; const char *type = user_data_elements[2]; const char *label = user_data_elements[3]; char **flags = user_data_elements[4]; char **options = user_data_elements[5]; const char *fstype = user_data_elements[6]; char **fsoptions = user_data_elements[7]; int n; int m; char *argv[128]; GError *error; char *offset_as_string; char *size_as_string; char *flags_as_string; offset_as_string = NULL; size_as_string = NULL; flags_as_string = NULL; error = NULL; if (!device->priv->device_is_partition_table) { throw_error (context, ERROR_FAILED, "Device is not partitioned"); goto out; } if (device_local_is_busy (device, FALSE, &error)) { dbus_g_method_return_error (context, error); g_error_free (error); goto out; } /* partutil.c / libparted will check there are no partitions in the requested slice */ offset_as_string = g_strdup_printf ("%" G_GINT64_FORMAT "", offset); size_as_string = g_strdup_printf ("%" G_GINT64_FORMAT "", size); /* TODO: check that neither of the flags include ',' */ flags_as_string = g_strjoinv (",", flags); n = 0; argv[n++] = "udisks-helper-create-partition"; if (device->priv->device_is_linux_dmmp) argv[n++] = (gchar *) get_dmmp_device_node (device); else argv[n++] = device->priv->device_file; argv[n++] = offset_as_string; argv[n++] = size_as_string; argv[n++] = (char *) type; argv[n++] = (char *) label; argv[n++] = (char *) flags_as_string; for (m = 0; options[m] != NULL; m++) { if (n >= (int) sizeof(argv) - 1) { throw_error (context, ERROR_FAILED, "Too many options"); goto out; } /* the helper will validate each option */ argv[n++] = (char *) options[m]; } argv[n++] = NULL; if (!job_new (context, "PartitionCreate", TRUE, device, argv, NULL, partition_create_completed_cb, FALSE, partition_create_data_new (context, device, offset, size, fstype, fsoptions), (GDestroyNotify) partition_create_data_unref)) { goto out; } out: g_free (offset_as_string); g_free (size_as_string); g_free (flags_as_string); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,302
device_partition_modify_authorized_cb (Daemon *daemon, Device *device, DBusGMethodInvocation *context, const gchar *action_id, guint num_user_data, gpointer *user_data_elements) { const char *type = user_data_elements[0]; const char *label = user_data_elements[1]; char **flags = user_data_elements[2]; int n; char *argv[128]; GError *error; char *offset_as_string; char *size_as_string; char *flags_as_string; Device *enclosing_device; offset_as_string = NULL; size_as_string = NULL; flags_as_string = NULL; error = NULL; if (!device->priv->device_is_partition) { throw_error (context, ERROR_FAILED, "Device is not a partition"); goto out; } enclosing_device = daemon_local_find_by_object_path (device->priv->daemon, device->priv->partition_slave); if (enclosing_device == NULL) { throw_error (context, ERROR_FAILED, "Cannot find enclosing device"); goto out; } if (device_local_is_busy (enclosing_device, FALSE, &error)) { dbus_g_method_return_error (context, error); g_error_free (error); goto out; } if (strlen (type) == 0) { throw_error (context, ERROR_FAILED, "type not specified"); goto out; } offset_as_string = g_strdup_printf ("%" G_GINT64_FORMAT "", device->priv->partition_offset); size_as_string = g_strdup_printf ("%" G_GINT64_FORMAT "", device->priv->partition_size); /* TODO: check that neither of the flags include ',' */ flags_as_string = g_strjoinv (",", flags); n = 0; argv[n++] = "udisks-helper-modify-partition"; argv[n++] = enclosing_device->priv->device_file; argv[n++] = offset_as_string; argv[n++] = size_as_string; argv[n++] = (char *) type; argv[n++] = (char *) label; argv[n++] = (char *) flags_as_string; argv[n++] = NULL; if (!job_new (context, "PartitionModify", TRUE, device, argv, NULL, partition_modify_completed_cb, FALSE, partition_modify_data_new (context, device, enclosing_device, type, label, flags), (GDestroyNotify) partition_modify_data_unref)) { goto out; } out: g_free (offset_as_string); g_free (size_as_string); g_free (flags_as_string); }
+Info
0
device_partition_modify_authorized_cb (Daemon *daemon, Device *device, DBusGMethodInvocation *context, const gchar *action_id, guint num_user_data, gpointer *user_data_elements) { const char *type = user_data_elements[0]; const char *label = user_data_elements[1]; char **flags = user_data_elements[2]; int n; char *argv[128]; GError *error; char *offset_as_string; char *size_as_string; char *flags_as_string; Device *enclosing_device; offset_as_string = NULL; size_as_string = NULL; flags_as_string = NULL; error = NULL; if (!device->priv->device_is_partition) { throw_error (context, ERROR_FAILED, "Device is not a partition"); goto out; } enclosing_device = daemon_local_find_by_object_path (device->priv->daemon, device->priv->partition_slave); if (enclosing_device == NULL) { throw_error (context, ERROR_FAILED, "Cannot find enclosing device"); goto out; } if (device_local_is_busy (enclosing_device, FALSE, &error)) { dbus_g_method_return_error (context, error); g_error_free (error); goto out; } if (strlen (type) == 0) { throw_error (context, ERROR_FAILED, "type not specified"); goto out; } offset_as_string = g_strdup_printf ("%" G_GINT64_FORMAT "", device->priv->partition_offset); size_as_string = g_strdup_printf ("%" G_GINT64_FORMAT "", device->priv->partition_size); /* TODO: check that neither of the flags include ',' */ flags_as_string = g_strjoinv (",", flags); n = 0; argv[n++] = "udisks-helper-modify-partition"; argv[n++] = enclosing_device->priv->device_file; argv[n++] = offset_as_string; argv[n++] = size_as_string; argv[n++] = (char *) type; argv[n++] = (char *) label; argv[n++] = (char *) flags_as_string; argv[n++] = NULL; if (!job_new (context, "PartitionModify", TRUE, device, argv, NULL, partition_modify_completed_cb, FALSE, partition_modify_data_new (context, device, enclosing_device, type, label, flags), (GDestroyNotify) partition_modify_data_unref)) { goto out; } out: g_free (offset_as_string); g_free (size_as_string); g_free (flags_as_string); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,303
device_partition_table_create (Device *device, const char *scheme, char **options, DBusGMethodInvocation *context) { daemon_local_check_auth (device->priv->daemon, device, device->priv->device_is_system_internal ? "org.freedesktop.udisks.change-system-internal" : "org.freedesktop.udisks.change", "PartitionTableCreate", TRUE, device_partition_table_create_authorized_cb, context, 2, g_strdup (scheme), g_free, g_strdupv (options), g_strfreev); return TRUE; }
+Info
0
device_partition_table_create (Device *device, const char *scheme, char **options, DBusGMethodInvocation *context) { daemon_local_check_auth (device->priv->daemon, device, device->priv->device_is_system_internal ? "org.freedesktop.udisks.change-system-internal" : "org.freedesktop.udisks.change", "PartitionTableCreate", TRUE, device_partition_table_create_authorized_cb, context, 2, g_strdup (scheme), g_free, g_strdupv (options), g_strfreev); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,304
device_partition_table_create_authorized_cb (Daemon *daemon, Device *device, DBusGMethodInvocation *context, const gchar *action_id, guint num_user_data, gpointer *user_data_elements) { const char *scheme = user_data_elements[0]; char **options = user_data_elements[1]; int n; int m; char *argv[128]; GError *error; error = NULL; if (device_local_is_busy (device, TRUE, &error)) { dbus_g_method_return_error (context, error); g_error_free (error); goto out; } if (strlen (scheme) == 0) { throw_error (context, ERROR_FAILED, "type not specified"); goto out; } n = 0; argv[n++] = "udisks-helper-create-partition-table"; if (device->priv->device_is_linux_dmmp) argv[n++] = (gchar *) get_dmmp_device_node (device); else argv[n++] = device->priv->device_file; argv[n++] = (char *) scheme; for (m = 0; options[m] != NULL; m++) { if (n >= (int) sizeof(argv) - 1) { throw_error (context, ERROR_FAILED, "Too many options"); goto out; } /* the helper will validate each option */ argv[n++] = (char *) options[m]; } argv[n++] = NULL; if (!job_new (context, "PartitionTableCreate", TRUE, device, argv, NULL, partition_table_create_completed_cb, FALSE, partition_table_create_data_new (context, device, scheme), (GDestroyNotify) partition_table_create_data_unref)) { goto out; } out: ; }
+Info
0
device_partition_table_create_authorized_cb (Daemon *daemon, Device *device, DBusGMethodInvocation *context, const gchar *action_id, guint num_user_data, gpointer *user_data_elements) { const char *scheme = user_data_elements[0]; char **options = user_data_elements[1]; int n; int m; char *argv[128]; GError *error; error = NULL; if (device_local_is_busy (device, TRUE, &error)) { dbus_g_method_return_error (context, error); g_error_free (error); goto out; } if (strlen (scheme) == 0) { throw_error (context, ERROR_FAILED, "type not specified"); goto out; } n = 0; argv[n++] = "udisks-helper-create-partition-table"; if (device->priv->device_is_linux_dmmp) argv[n++] = (gchar *) get_dmmp_device_node (device); else argv[n++] = device->priv->device_file; argv[n++] = (char *) scheme; for (m = 0; options[m] != NULL; m++) { if (n >= (int) sizeof(argv) - 1) { throw_error (context, ERROR_FAILED, "Too many options"); goto out; } /* the helper will validate each option */ argv[n++] = (char *) options[m]; } argv[n++] = NULL; if (!job_new (context, "PartitionTableCreate", TRUE, device, argv, NULL, partition_table_create_completed_cb, FALSE, partition_table_create_data_new (context, device, scheme), (GDestroyNotify) partition_table_create_data_unref)) { goto out; } out: ; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,305
device_removed (Device *device) { guint n; device->priv->removed = TRUE; dbus_g_connection_unregister_g_object (device->priv->system_bus_connection, G_OBJECT (device)); g_assert (dbus_g_connection_lookup_g_object (device->priv->system_bus_connection, device->priv->object_path) == NULL); /* device is now removed; update all slaves and holders */ for (n = 0; n < device->priv->slaves_objpath->len; n++) { const gchar *objpath2 = ((gchar **) device->priv->slaves_objpath->pdata)[n]; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info (device2); } } for (n = 0; n < device->priv->holders_objpath->len; n++) { const gchar *objpath2 = ((gchar **) device->priv->holders_objpath->pdata)[n]; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info (device2); } } /* If the device is busy, we possibly need to clean up if the * device itself is busy. This includes * * - force unmounting the device and/or all it's partitions * * - tearing down a luks mapping if it's a cleartext device * backed by a crypted device * * but see force_removal() for details. * * This is the normally the path where the enclosing device is * removed. Compare with device_changed() for the * other path. */ force_removal (device, NULL, NULL); }
+Info
0
device_removed (Device *device) { guint n; device->priv->removed = TRUE; dbus_g_connection_unregister_g_object (device->priv->system_bus_connection, G_OBJECT (device)); g_assert (dbus_g_connection_lookup_g_object (device->priv->system_bus_connection, device->priv->object_path) == NULL); /* device is now removed; update all slaves and holders */ for (n = 0; n < device->priv->slaves_objpath->len; n++) { const gchar *objpath2 = ((gchar **) device->priv->slaves_objpath->pdata)[n]; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info (device2); } } for (n = 0; n < device->priv->holders_objpath->len; n++) { const gchar *objpath2 = ((gchar **) device->priv->holders_objpath->pdata)[n]; Device *device2; device2 = daemon_local_find_by_object_path (device->priv->daemon, objpath2); if (device2 != NULL) { update_info (device2); } } /* If the device is busy, we possibly need to clean up if the * device itself is busy. This includes * * - force unmounting the device and/or all it's partitions * * - tearing down a luks mapping if it's a cleartext device * backed by a crypted device * * but see force_removal() for details. * * This is the normally the path where the enclosing device is * removed. Compare with device_changed() for the * other path. */ force_removal (device, NULL, NULL); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,306
diff_sorted_lists (GList *list1, GList *list2, GCompareFunc compare, GList **added, GList **removed) { int order; *added = *removed = NULL; while (list1 != NULL && list2 != NULL) { order = (*compare) (list1->data, list2->data); if (order < 0) { *removed = g_list_prepend (*removed, list1->data); list1 = list1->next; } else if (order > 0) { *added = g_list_prepend (*added, list2->data); list2 = list2->next; } else { /* same item */ list1 = list1->next; list2 = list2->next; } } while (list1 != NULL) { *removed = g_list_prepend (*removed, list1->data); list1 = list1->next; } while (list2 != NULL) { *added = g_list_prepend (*added, list2->data); list2 = list2->next; } }
+Info
0
diff_sorted_lists (GList *list1, GList *list2, GCompareFunc compare, GList **added, GList **removed) { int order; *added = *removed = NULL; while (list1 != NULL && list2 != NULL) { order = (*compare) (list1->data, list2->data); if (order < 0) { *removed = g_list_prepend (*removed, list1->data); list1 = list1->next; } else if (order > 0) { *added = g_list_prepend (*added, list2->data); list2 = list2->next; } else { /* same item */ list1 = list1->next; list2 = list2->next; } } while (list1 != NULL) { *removed = g_list_prepend (*removed, list1->data); list1 = list1->next; } while (list2 != NULL) { *added = g_list_prepend (*added, list2->data); list2 = list2->next; } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,307
drain_pending_changes (Device *device, gboolean force_update) { gboolean emit_changed; emit_changed = FALSE; /* the update-in-idle is set up if, and only if, there are pending changes - so * we should emit a 'change' event only if it is set up */ if (device->priv->emit_changed_idle_id != 0) { g_source_remove (device->priv->emit_changed_idle_id); device->priv->emit_changed_idle_id = 0; emit_changed = TRUE; } if ((!device->priv->removed) && (emit_changed || force_update)) { if (device->priv->object_path != NULL) { g_print ("**** EMITTING CHANGED for %s\n", device->priv->native_path); g_signal_emit_by_name (device, "changed"); g_signal_emit_by_name (device->priv->daemon, "device-changed", device->priv->object_path); } } }
+Info
0
drain_pending_changes (Device *device, gboolean force_update) { gboolean emit_changed; emit_changed = FALSE; /* the update-in-idle is set up if, and only if, there are pending changes - so * we should emit a 'change' event only if it is set up */ if (device->priv->emit_changed_idle_id != 0) { g_source_remove (device->priv->emit_changed_idle_id); device->priv->emit_changed_idle_id = 0; emit_changed = TRUE; } if ((!device->priv->removed) && (emit_changed || force_update)) { if (device->priv->object_path != NULL) { g_print ("**** EMITTING CHANGED for %s\n", device->priv->native_path); g_signal_emit_by_name (device, "changed"); g_signal_emit_by_name (device->priv->daemon, "device-changed", device->priv->object_path); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,308
drive_ata_smart_initiate_selftest_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { char *options[] = { NULL }; /* no matter what happened, refresh the data */ device_drive_ata_smart_refresh_data (device, options, NULL); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error running self test: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
drive_ata_smart_initiate_selftest_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { char *options[] = { NULL }; /* no matter what happened, refresh the data */ device_drive_ata_smart_refresh_data (device, options, NULL); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error running self test: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,309
drive_ata_smart_refresh_data_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { gint rc; SkDisk *d; gchar *blob; gsize blob_size; time_t time_collected; SkSmartOverall overall; PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) start", device->priv->native_path); d = NULL; blob = NULL; if (job_was_cancelled || stdout == NULL) { if (job_was_cancelled) { if (context != NULL) throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { if (context != NULL) throw_error (context, ERROR_FAILED, "Error retrieving ATA SMART data: no output", WEXITSTATUS (status), stderr); } goto out; } rc = WEXITSTATUS (status); if (rc != 0) { if (rc == 2) { if (context != NULL) { throw_error (context, ERROR_ATA_SMART_WOULD_WAKEUP, "Error retrieving ATA SMART data: %s", stderr); } } else { if (context != NULL) { throw_error (context, ERROR_FAILED, "Error retrieving ATA SMART data: helper failed with exit code %d: %s", rc, stderr); } } goto out; } PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) decode blob", device->priv->native_path); blob = (gchar *) g_base64_decode (stdout, &blob_size); PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) set blob", device->priv->native_path); if (blob == NULL) { if (context != NULL) { throw_error (context, ERROR_FAILED, "Error decoding ATA SMART data: invalid base64 format: %s", stdout); } else { g_warning ("Error decoding ATA SMART data: invalid base64 format: %s", stdout); } goto out; } if (sk_disk_open (NULL, &d) != 0) { if (context != NULL) { throw_error (context, ERROR_FAILED, "unable to open a SkDisk"); } goto out; } if (sk_disk_set_blob (d, blob, blob_size) != 0) { if (context != NULL) { throw_error (context, ERROR_FAILED, "error parsing blob: %s", strerror (errno)); } goto out; } PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) time collected", device->priv->native_path); time_collected = time (NULL); device_set_drive_ata_smart_time_collected (device, time_collected); PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) overall smart status", device->priv->native_path); if (sk_disk_smart_get_overall (d, &overall) != 0) overall = -1; device_set_drive_ata_smart_status (device, overall); device_set_drive_ata_smart_blob_steal (device, blob, blob_size); blob = NULL; /* emit change event since we've updated the smart data */ PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) drain pending changes", device->priv->native_path); drain_pending_changes (device, FALSE); if (context != NULL) dbus_g_method_return (context); out: g_free (blob); if (d != NULL) sk_disk_free (d); PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) end", device->priv->native_path); }
+Info
0
drive_ata_smart_refresh_data_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { gint rc; SkDisk *d; gchar *blob; gsize blob_size; time_t time_collected; SkSmartOverall overall; PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) start", device->priv->native_path); d = NULL; blob = NULL; if (job_was_cancelled || stdout == NULL) { if (job_was_cancelled) { if (context != NULL) throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { if (context != NULL) throw_error (context, ERROR_FAILED, "Error retrieving ATA SMART data: no output", WEXITSTATUS (status), stderr); } goto out; } rc = WEXITSTATUS (status); if (rc != 0) { if (rc == 2) { if (context != NULL) { throw_error (context, ERROR_ATA_SMART_WOULD_WAKEUP, "Error retrieving ATA SMART data: %s", stderr); } } else { if (context != NULL) { throw_error (context, ERROR_FAILED, "Error retrieving ATA SMART data: helper failed with exit code %d: %s", rc, stderr); } } goto out; } PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) decode blob", device->priv->native_path); blob = (gchar *) g_base64_decode (stdout, &blob_size); PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) set blob", device->priv->native_path); if (blob == NULL) { if (context != NULL) { throw_error (context, ERROR_FAILED, "Error decoding ATA SMART data: invalid base64 format: %s", stdout); } else { g_warning ("Error decoding ATA SMART data: invalid base64 format: %s", stdout); } goto out; } if (sk_disk_open (NULL, &d) != 0) { if (context != NULL) { throw_error (context, ERROR_FAILED, "unable to open a SkDisk"); } goto out; } if (sk_disk_set_blob (d, blob, blob_size) != 0) { if (context != NULL) { throw_error (context, ERROR_FAILED, "error parsing blob: %s", strerror (errno)); } goto out; } PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) time collected", device->priv->native_path); time_collected = time (NULL); device_set_drive_ata_smart_time_collected (device, time_collected); PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) overall smart status", device->priv->native_path); if (sk_disk_smart_get_overall (d, &overall) != 0) overall = -1; device_set_drive_ata_smart_status (device, overall); device_set_drive_ata_smart_blob_steal (device, blob, blob_size); blob = NULL; /* emit change event since we've updated the smart data */ PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) drain pending changes", device->priv->native_path); drain_pending_changes (device, FALSE); if (context != NULL) dbus_g_method_return (context); out: g_free (blob); if (d != NULL) sk_disk_free (d); PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) end", device->priv->native_path); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,310
drive_detach_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* TODO: probably wait for has_media to change to FALSE */ dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error detaching: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
drive_detach_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* TODO: probably wait for has_media to change to FALSE */ dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error detaching: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,311
drive_eject_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* TODO: probably wait for has_media to change to FALSE */ dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error ejecting: eject exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
drive_eject_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* TODO: probably wait for has_media to change to FALSE */ dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error ejecting: eject exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,312
drive_poll_media_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { device_generate_kernel_change_event (device); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error detaching: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
drive_poll_media_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { device_generate_kernel_change_event (device); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error detaching: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,313
dup_list_from_ptrarray (GPtrArray *p) { GList *ret; guint n; ret = NULL; for (n = 0; n < p->len; n++) ret = g_list_prepend (ret, g_strdup (((gchar **) p->pdata)[n])); return ret; }
+Info
0
dup_list_from_ptrarray (GPtrArray *p) { GList *ret; guint n; ret = NULL; for (n = 0; n < p->len; n++) ret = g_list_prepend (ret, g_strdup (((gchar **) p->pdata)[n])); return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,314
emit_job_changed (Device *device) { drain_pending_changes (device, FALSE); if (!device->priv->removed) { g_print ("**** EMITTING JOB-CHANGED for %s\n", device->priv->native_path); g_signal_emit_by_name (device->priv->daemon, "device-job-changed", device->priv->object_path, device->priv->job_in_progress, device->priv->job_id, device->priv->job_initiated_by_uid, device->priv->job_is_cancellable, device->priv->job_percentage, NULL); g_signal_emit (device, signals[JOB_CHANGED_SIGNAL], 0, device->priv->job_in_progress, device->priv->job_id, device->priv->job_initiated_by_uid, device->priv->job_is_cancellable, device->priv->job_percentage); } }
+Info
0
emit_job_changed (Device *device) { drain_pending_changes (device, FALSE); if (!device->priv->removed) { g_print ("**** EMITTING JOB-CHANGED for %s\n", device->priv->native_path); g_signal_emit_by_name (device->priv->daemon, "device-job-changed", device->priv->object_path, device->priv->job_in_progress, device->priv->job_id, device->priv->job_initiated_by_uid, device->priv->job_is_cancellable, device->priv->job_percentage, NULL); g_signal_emit (device, signals[JOB_CHANGED_SIGNAL], 0, device->priv->job_in_progress, device->priv->job_id, device->priv->job_initiated_by_uid, device->priv->job_is_cancellable, device->priv->job_percentage); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,315
extract_lvm_uuid (const gchar *s) { GString *str; if (s == NULL || strlen (s) < 32) return NULL; str = g_string_new_len (s, 6); g_string_append_c (str, '-'); s += 6; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 6); return g_string_free (str, FALSE); }
+Info
0
extract_lvm_uuid (const gchar *s) { GString *str; if (s == NULL || strlen (s) < 32) return NULL; str = g_string_new_len (s, 6); g_string_append_c (str, '-'); s += 6; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 4); g_string_append_c (str, '-'); s += 4; g_string_append_len (str, s, 6); return g_string_free (str, FALSE); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,316
filesystem_check_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WIFEXITED (status) && !job_was_cancelled) { int rc; gboolean fs_is_clean; fs_is_clean = FALSE; rc = WEXITSTATUS (status); if ((rc == 0) || (((rc & 1) != 0) && ((rc & 4) == 0))) { fs_is_clean = TRUE; } dbus_g_method_return (context, fs_is_clean); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error fsck'ing: fsck exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
filesystem_check_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WIFEXITED (status) && !job_was_cancelled) { int rc; gboolean fs_is_clean; fs_is_clean = FALSE; rc = WEXITSTATUS (status); if ((rc == 0) || (((rc & 1) != 0) && ((rc & 4) == 0))) { fs_is_clean = TRUE; } dbus_g_method_return (context, fs_is_clean); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error fsck'ing: fsck exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,317
filesystem_create_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { MkfsData *data = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { if (data->hook_func != NULL) data->hook_func (context, device, TRUE, data->hook_user_data); else dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else if (WEXITSTATUS (status) == 3) { throw_error (context, ERROR_FILESYSTEM_TOOLS_MISSING, "Error creating file system: Cannot run mkfs: %s", stderr); } else { throw_error (context, ERROR_FAILED, "Error creating file system: helper exited with exit code %d: %s\n%s", WEXITSTATUS (status), stderr, stdout); } if (data->hook_func != NULL) data->hook_func (context, device, FALSE, data->hook_user_data); } }
+Info
0
filesystem_create_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { MkfsData *data = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { if (data->hook_func != NULL) data->hook_func (context, device, TRUE, data->hook_user_data); else dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else if (WEXITSTATUS (status) == 3) { throw_error (context, ERROR_FILESYSTEM_TOOLS_MISSING, "Error creating file system: Cannot run mkfs: %s", stderr); } else { throw_error (context, ERROR_FAILED, "Error creating file system: helper exited with exit code %d: %s\n%s", WEXITSTATUS (status), stderr, stdout); } if (data->hook_func != NULL) data->hook_func (context, device, FALSE, data->hook_user_data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,318
filesystem_create_create_luks_device_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { MkfsLuksData *data = user_data; /* poke the kernel so we can reread the data (new uuid etc.) */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* OK! So we've got ourselves an luks device. Let's set it up so we can create a file * system. Sit and wait for the change event to appear so we can setup with the right UUID. */ data->device_changed_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-changed", (GCallback) filesystem_create_wait_for_luks_device_changed_cb, mkfse_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_changed_timeout_id = g_timeout_add (10 * 1000, filesystem_create_wait_for_luks_device_not_seen_cb, data); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error creating file system: cryptsetup exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
filesystem_create_create_luks_device_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { MkfsLuksData *data = user_data; /* poke the kernel so we can reread the data (new uuid etc.) */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* OK! So we've got ourselves an luks device. Let's set it up so we can create a file * system. Sit and wait for the change event to appear so we can setup with the right UUID. */ data->device_changed_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-changed", (GCallback) filesystem_create_wait_for_luks_device_changed_cb, mkfse_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_changed_timeout_id = g_timeout_add (10 * 1000, filesystem_create_wait_for_luks_device_not_seen_cb, data); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error creating file system: cryptsetup exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,319
filesystem_create_wait_for_luks_device_changed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { MkfsLuksData *data = user_data; Device *device; /* check if we're now a LUKS crypto device */ device = daemon_local_find_by_object_path (daemon, object_path); if (device == data->device && (device->priv->id_usage != NULL && strcmp (device->priv->id_usage, "crypto") == 0) && (device->priv->id_type != NULL && strcmp (device->priv->id_type, "crypto_LUKS") == 0)) { /* yay! we are now set up the corresponding cleartext device */ device_luks_unlock_internal (data->device, data->passphrase, NULL, filesystem_create_wait_for_cleartext_device_hook, data, data->context); g_signal_handler_disconnect (daemon, data->device_changed_signal_handler_id); g_source_remove (data->device_changed_timeout_id); } }
+Info
0
filesystem_create_wait_for_luks_device_changed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { MkfsLuksData *data = user_data; Device *device; /* check if we're now a LUKS crypto device */ device = daemon_local_find_by_object_path (daemon, object_path); if (device == data->device && (device->priv->id_usage != NULL && strcmp (device->priv->id_usage, "crypto") == 0) && (device->priv->id_type != NULL && strcmp (device->priv->id_type, "crypto_LUKS") == 0)) { /* yay! we are now set up the corresponding cleartext device */ device_luks_unlock_internal (data->device, data->passphrase, NULL, filesystem_create_wait_for_cleartext_device_hook, data, data->context); g_signal_handler_disconnect (daemon, data->device_changed_signal_handler_id); g_source_remove (data->device_changed_timeout_id); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,320
filesystem_create_wait_for_luks_device_not_seen_cb (gpointer user_data) { MkfsLuksData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error creating luks encrypted file system: timeout (10s) waiting for luks device to show up"); g_signal_handler_disconnect (data->device->priv->daemon, data->device_changed_signal_handler_id); mkfse_data_unref (data); return FALSE; }
+Info
0
filesystem_create_wait_for_luks_device_not_seen_cb (gpointer user_data) { MkfsLuksData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error creating luks encrypted file system: timeout (10s) waiting for luks device to show up"); g_signal_handler_disconnect (data->device->priv->daemon, data->device_changed_signal_handler_id); mkfse_data_unref (data); return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,321
filesystem_list_open_files_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if ((WEXITSTATUS (status) == 0 || WEXITSTATUS (status) == 1) && !job_was_cancelled) { GPtrArray *processes; processes = g_ptr_array_new (); lsof_parse (stdout, processes); dbus_g_method_return (context, processes); g_ptr_array_foreach (processes, (GFunc) g_value_array_free, NULL); g_ptr_array_free (processes, TRUE); } else { throw_error (context, ERROR_FAILED, "Error listing open files: lsof exited with exit code %d: %s", WEXITSTATUS (status), stderr); } }
+Info
0
filesystem_list_open_files_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if ((WEXITSTATUS (status) == 0 || WEXITSTATUS (status) == 1) && !job_was_cancelled) { GPtrArray *processes; processes = g_ptr_array_new (); lsof_parse (stdout, processes); dbus_g_method_return (context, processes); g_ptr_array_foreach (processes, (GFunc) g_value_array_free, NULL); g_ptr_array_free (processes, TRUE); } else { throw_error (context, ERROR_FAILED, "Error listing open files: lsof exited with exit code %d: %s", WEXITSTATUS (status), stderr); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,322
filesystem_mount_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { MountData *data = (MountData *) user_data; uid_t uid; daemon_local_get_uid (device->priv->daemon, &uid, context); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { update_info (device); drain_pending_changes (device, FALSE); unlock_cd_tray (device); dbus_g_method_return (context, data->mount_point); } else { if (data->remove_dir_on_unmount) { mount_file_remove (device->priv->device_file, data->mount_point); if (g_rmdir (data->mount_point) != 0) { g_warning ("Error removing dir in late mount error path: %m"); } } if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else if (WEXITSTATUS (status) == 32) { throw_error (context, ERROR_FILESYSTEM_DRIVER_MISSING, "Error mounting: %s", stderr); } else { throw_error (context, ERROR_FAILED, "Error mounting: mount exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
filesystem_mount_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { MountData *data = (MountData *) user_data; uid_t uid; daemon_local_get_uid (device->priv->daemon, &uid, context); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { update_info (device); drain_pending_changes (device, FALSE); unlock_cd_tray (device); dbus_g_method_return (context, data->mount_point); } else { if (data->remove_dir_on_unmount) { mount_file_remove (device->priv->device_file, data->mount_point); if (g_rmdir (data->mount_point) != 0) { g_warning ("Error removing dir in late mount error path: %m"); } } if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else if (WEXITSTATUS (status) == 32) { throw_error (context, ERROR_FILESYSTEM_DRIVER_MISSING, "Error mounting: %s", stderr); } else { throw_error (context, ERROR_FAILED, "Error mounting: mount exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,323
filesystem_mount_data_free (MountData *data) { g_free (data->mount_point); g_free (data); }
+Info
0
filesystem_mount_data_free (MountData *data) { g_free (data->mount_point); g_free (data); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,324
filesystem_mount_data_new (const char *mount_point, gboolean remove_dir_on_unmount) { MountData *data; data = g_new0 (MountData, 1); data->mount_point = g_strdup (mount_point); data->remove_dir_on_unmount = remove_dir_on_unmount; return data; }
+Info
0
filesystem_mount_data_new (const char *mount_point, gboolean remove_dir_on_unmount) { MountData *data; data = g_new0 (MountData, 1); data->mount_point = g_strdup (mount_point); data->remove_dir_on_unmount = remove_dir_on_unmount; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,325
filesystem_set_label_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { char *new_label = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* update local copy, don't wait for the kernel */ device_set_id_label (device, new_label); drain_pending_changes (device, FALSE); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error changing fslabel: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
filesystem_set_label_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { char *new_label = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* update local copy, don't wait for the kernel */ device_set_id_label (device, new_label); drain_pending_changes (device, FALSE); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error changing fslabel: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,326
find_cleartext_device (Device *device) { GList *devices; GList *l; Device *ret; ret = NULL; /* check that there isn't a cleartext device already */ devices = daemon_local_get_all_devices (device->priv->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_luks_cleartext && d->priv->luks_cleartext_slave != NULL && strcmp (d->priv->luks_cleartext_slave, device->priv->object_path) == 0) { ret = d; goto out; } } out: g_list_free (devices); return ret; }
+Info
0
find_cleartext_device (Device *device) { GList *devices; GList *l; Device *ret; ret = NULL; /* check that there isn't a cleartext device already */ devices = daemon_local_get_all_devices (device->priv->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_luks_cleartext && d->priv->luks_cleartext_slave != NULL && strcmp (d->priv->luks_cleartext_slave, device->priv->object_path) == 0) { ret = d; goto out; } } out: g_list_free (devices); return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,327
find_lvm2_lv_name_for_uuids (Daemon *daemon, const gchar *group_uuid, const gchar *uuid) { GList *l; GList *devices; gchar *ret; ret = NULL; devices = daemon_local_get_all_devices (daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_linux_lvm2_pv && g_strcmp0 (group_uuid, d->priv->linux_lvm2_pv_group_uuid) == 0) { guint n; for (n = 0; n < d->priv->linux_lvm2_pv_group_logical_volumes->len; n++) { const gchar *lv_data = d->priv->linux_lvm2_pv_group_logical_volumes->pdata[n]; gchar **tokens; guint m; tokens = g_strsplit (lv_data, ";", 0); for (m = 0; tokens != NULL && tokens[m] != NULL; m++) { if (g_str_has_prefix (tokens[m], "uuid=") && g_strcmp0 (tokens[m] + 5, uuid) == 0) { guint c; for (c = 0; tokens[c] != NULL; c++) { if (g_str_has_prefix (tokens[c], "name=")) { ret = g_strdup_printf ("%s/%s", d->priv->linux_lvm2_pv_group_name, tokens[c] + 5); break; } } } } g_strfreev (tokens); if (ret != NULL) break; } } if (ret != NULL) break; } g_list_free (devices); return ret; }
+Info
0
find_lvm2_lv_name_for_uuids (Daemon *daemon, const gchar *group_uuid, const gchar *uuid) { GList *l; GList *devices; gchar *ret; ret = NULL; devices = daemon_local_get_all_devices (daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_linux_lvm2_pv && g_strcmp0 (group_uuid, d->priv->linux_lvm2_pv_group_uuid) == 0) { guint n; for (n = 0; n < d->priv->linux_lvm2_pv_group_logical_volumes->len; n++) { const gchar *lv_data = d->priv->linux_lvm2_pv_group_logical_volumes->pdata[n]; gchar **tokens; guint m; tokens = g_strsplit (lv_data, ";", 0); for (m = 0; tokens != NULL && tokens[m] != NULL; m++) { if (g_str_has_prefix (tokens[m], "uuid=") && g_strcmp0 (tokens[m] + 5, uuid) == 0) { guint c; for (c = 0; tokens[c] != NULL; c++) { if (g_str_has_prefix (tokens[c], "name=")) { ret = g_strdup_printf ("%s/%s", d->priv->linux_lvm2_pv_group_name, tokens[c] + 5); break; } } } } g_strfreev (tokens); if (ret != NULL) break; } } if (ret != NULL) break; } g_list_free (devices); return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,328
find_lvm2_vg_name_for_uuid (Daemon *daemon, const gchar *uuid) { GList *l; GList *devices; const gchar *vg_name; vg_name = NULL; devices = daemon_local_get_all_devices (daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_linux_lvm2_pv && g_strcmp0 (uuid, d->priv->linux_lvm2_pv_group_uuid) == 0) { vg_name = d->priv->linux_lvm2_pv_group_name; break; } } g_list_free (devices); return vg_name; }
+Info
0
find_lvm2_vg_name_for_uuid (Daemon *daemon, const gchar *uuid) { GList *l; GList *devices; const gchar *vg_name; vg_name = NULL; devices = daemon_local_get_all_devices (daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_linux_lvm2_pv && g_strcmp0 (uuid, d->priv->linux_lvm2_pv_group_uuid) == 0) { vg_name = d->priv->linux_lvm2_pv_group_name; break; } } g_list_free (devices); return vg_name; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,329
force_luks_teardown (Device *device, Device *cleartext_device, ForceRemovalCompleteFunc callback, gpointer user_data) { /* first we gotta force remove the clear text device */ force_removal (cleartext_device, force_luks_teardown_cleartext_done, force_luks_teardown_data_new (device, cleartext_device->priv->dm_name, callback, user_data)); }
+Info
0
force_luks_teardown (Device *device, Device *cleartext_device, ForceRemovalCompleteFunc callback, gpointer user_data) { /* first we gotta force remove the clear text device */ force_removal (cleartext_device, force_luks_teardown_cleartext_done, force_luks_teardown_data_new (device, cleartext_device->priv->dm_name, callback, user_data)); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,330
force_luks_teardown_cleartext_done (Device *device, gboolean success, gpointer user_data) { int n; char *argv[16]; ForceLuksTeardownData *data = user_data; if (!success) { if (data->fr_callback != NULL) data->fr_callback (data->device, FALSE, data->fr_user_data); force_luks_teardown_data_unref (data); goto out; } /* ok, clear text device is out of the way; now tear it down */ n = 0; argv[n++] = "cryptsetup"; argv[n++] = "luksClose"; argv[n++] = data->dm_name; argv[n++] = NULL; if (!job_new (NULL, "ForceLuksTeardown", FALSE, data->device, argv, NULL, force_luks_teardown_completed_cb, FALSE, data, (GDestroyNotify) force_luks_teardown_data_unref)) { g_warning ("Couldn't spawn cryptsetup for force teardown for device %s", data->dm_name); if (data->fr_callback != NULL) data->fr_callback (data->device, FALSE, data->fr_user_data); force_luks_teardown_data_unref (data); } out: ; }
+Info
0
force_luks_teardown_cleartext_done (Device *device, gboolean success, gpointer user_data) { int n; char *argv[16]; ForceLuksTeardownData *data = user_data; if (!success) { if (data->fr_callback != NULL) data->fr_callback (data->device, FALSE, data->fr_user_data); force_luks_teardown_data_unref (data); goto out; } /* ok, clear text device is out of the way; now tear it down */ n = 0; argv[n++] = "cryptsetup"; argv[n++] = "luksClose"; argv[n++] = data->dm_name; argv[n++] = NULL; if (!job_new (NULL, "ForceLuksTeardown", FALSE, data->device, argv, NULL, force_luks_teardown_completed_cb, FALSE, data, (GDestroyNotify) force_luks_teardown_data_unref)) { g_warning ("Couldn't spawn cryptsetup for force teardown for device %s", data->dm_name); if (data->fr_callback != NULL) data->fr_callback (data->device, FALSE, data->fr_user_data); force_luks_teardown_data_unref (data); } out: ; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,331
force_luks_teardown_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { ForceLuksTeardownData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { g_print ("**** NOTE: Successfully teared down luks device %s\n", device->priv->device_file); if (data->fr_callback != NULL) data->fr_callback (device, TRUE, data->fr_user_data); } else { g_print ("**** NOTE: force luks teardown failed: %s\n", stderr); if (data->fr_callback != NULL) data->fr_callback (device, FALSE, data->fr_user_data); } }
+Info
0
force_luks_teardown_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { ForceLuksTeardownData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { g_print ("**** NOTE: Successfully teared down luks device %s\n", device->priv->device_file); if (data->fr_callback != NULL) data->fr_callback (device, TRUE, data->fr_user_data); } else { g_print ("**** NOTE: force luks teardown failed: %s\n", stderr); if (data->fr_callback != NULL) data->fr_callback (device, FALSE, data->fr_user_data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,332
force_luks_teardown_data_new (Device *device, const char *dm_name, ForceRemovalCompleteFunc fr_callback, gpointer fr_user_data) { ForceLuksTeardownData *data; data = g_new0 (ForceLuksTeardownData, 1); data->device = g_object_ref (device); data->dm_name = g_strdup (dm_name); data->fr_callback = fr_callback; data->fr_user_data = fr_user_data; return data; }
+Info
0
force_luks_teardown_data_new (Device *device, const char *dm_name, ForceRemovalCompleteFunc fr_callback, gpointer fr_user_data) { ForceLuksTeardownData *data; data = g_new0 (ForceLuksTeardownData, 1); data->device = g_object_ref (device); data->dm_name = g_strdup (dm_name); data->fr_callback = fr_callback; data->fr_user_data = fr_user_data; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,333
force_luks_teardown_data_unref (ForceLuksTeardownData *data) { if (data->device != NULL) g_object_unref (data->device); g_free (data->dm_name); g_free (data); }
+Info
0
force_luks_teardown_data_unref (ForceLuksTeardownData *data) { if (data->device != NULL) g_object_unref (data->device); g_free (data->dm_name); g_free (data); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,334
force_removal (Device *device, ForceRemovalCompleteFunc callback, gpointer user_data) { /* Device is going bye bye. If this device is * * - Mounted by us, then forcibly unmount it. * * - If it's a luks device, check if there's cleartext * companion. If so, tear it down if it was setup by us. * */ if (device->priv->device_is_mounted && device->priv->device_mount_paths->len > 0) { gboolean remove_dir_on_unmount; if (mount_file_has_device (device->priv->device_file, NULL, &remove_dir_on_unmount) || is_device_in_fstab (device, NULL)) { g_print ("**** NOTE: Force unmounting device %s\n", device->priv->device_file); force_unmount (device, callback, user_data); goto pending; } } if (device->priv->id_usage != NULL && strcmp (device->priv->id_usage, "crypto") == 0) { GList *devices; GList *l; /* look for cleartext device */ devices = daemon_local_get_all_devices (device->priv->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_luks_cleartext && d->priv->luks_cleartext_slave != NULL && strcmp (d->priv->luks_cleartext_slave, device->priv->object_path) == 0) { /* Check whether it is set up by us */ if (d->priv->dm_name != NULL && g_str_has_prefix (d->priv->dm_name, "udisks-luks-uuid-")) { g_print ("**** NOTE: Force luks teardown device %s (cleartext %s)\n", device->priv->device_file, d->priv->device_file); /* Gotcha */ force_luks_teardown (device, d, callback, user_data); goto pending; } } } } /* nothing to force remove */ if (callback != NULL) callback (device, TRUE, user_data); pending: ; }
+Info
0
force_removal (Device *device, ForceRemovalCompleteFunc callback, gpointer user_data) { /* Device is going bye bye. If this device is * * - Mounted by us, then forcibly unmount it. * * - If it's a luks device, check if there's cleartext * companion. If so, tear it down if it was setup by us. * */ if (device->priv->device_is_mounted && device->priv->device_mount_paths->len > 0) { gboolean remove_dir_on_unmount; if (mount_file_has_device (device->priv->device_file, NULL, &remove_dir_on_unmount) || is_device_in_fstab (device, NULL)) { g_print ("**** NOTE: Force unmounting device %s\n", device->priv->device_file); force_unmount (device, callback, user_data); goto pending; } } if (device->priv->id_usage != NULL && strcmp (device->priv->id_usage, "crypto") == 0) { GList *devices; GList *l; /* look for cleartext device */ devices = daemon_local_get_all_devices (device->priv->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_luks_cleartext && d->priv->luks_cleartext_slave != NULL && strcmp (d->priv->luks_cleartext_slave, device->priv->object_path) == 0) { /* Check whether it is set up by us */ if (d->priv->dm_name != NULL && g_str_has_prefix (d->priv->dm_name, "udisks-luks-uuid-")) { g_print ("**** NOTE: Force luks teardown device %s (cleartext %s)\n", device->priv->device_file, d->priv->device_file); /* Gotcha */ force_luks_teardown (device, d, callback, user_data); goto pending; } } } } /* nothing to force remove */ if (callback != NULL) callback (device, TRUE, user_data); pending: ; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,335
force_unmount (Device *device, ForceRemovalCompleteFunc callback, gpointer user_data) { int n; char *argv[16]; const gchar *mount_path; mount_path = ((gchar **) device->priv->device_mount_paths->pdata)[0]; n = 0; argv[n++] = "umount"; /* on Linux, we only have lazy unmount for now */ argv[n++] = "-l"; argv[n++] = (gchar *) mount_path; argv[n++] = NULL; if (!job_new (NULL, "ForceUnmount", FALSE, device, argv, NULL, force_unmount_completed_cb, FALSE, force_unmount_data_new (mount_path, callback, user_data), (GDestroyNotify) force_unmount_data_unref)) { g_warning ("Couldn't spawn unmount for force unmounting %s", mount_path); if (callback != NULL) callback (device, FALSE, user_data); } }
+Info
0
force_unmount (Device *device, ForceRemovalCompleteFunc callback, gpointer user_data) { int n; char *argv[16]; const gchar *mount_path; mount_path = ((gchar **) device->priv->device_mount_paths->pdata)[0]; n = 0; argv[n++] = "umount"; /* on Linux, we only have lazy unmount for now */ argv[n++] = "-l"; argv[n++] = (gchar *) mount_path; argv[n++] = NULL; if (!job_new (NULL, "ForceUnmount", FALSE, device, argv, NULL, force_unmount_completed_cb, FALSE, force_unmount_data_new (mount_path, callback, user_data), (GDestroyNotify) force_unmount_data_unref)) { g_warning ("Couldn't spawn unmount for force unmounting %s", mount_path); if (callback != NULL) callback (device, FALSE, user_data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,336
force_unmount_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { ForceUnmountData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { g_print ("**** NOTE: Successfully force unmounted device %s\n", device->priv->device_file); /* update_info_mount_state() will update the mounts file and clean up the directory if needed */ update_info (device); if (data->fr_callback != NULL) data->fr_callback (device, TRUE, data->fr_user_data); } else { g_print ("**** NOTE: force unmount failed: %s\n", stderr); if (data->fr_callback != NULL) data->fr_callback (device, FALSE, data->fr_user_data); } }
+Info
0
force_unmount_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { ForceUnmountData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { g_print ("**** NOTE: Successfully force unmounted device %s\n", device->priv->device_file); /* update_info_mount_state() will update the mounts file and clean up the directory if needed */ update_info (device); if (data->fr_callback != NULL) data->fr_callback (device, TRUE, data->fr_user_data); } else { g_print ("**** NOTE: force unmount failed: %s\n", stderr); if (data->fr_callback != NULL) data->fr_callback (device, FALSE, data->fr_user_data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,337
force_unmount_data_unref (ForceUnmountData *data) { g_free (data->mount_path); g_free (data); }
+Info
0
force_unmount_data_unref (ForceUnmountData *data) { g_free (data->mount_path); g_free (data); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,338
get_command_line_for_pid (pid_t pid) { char proc_name[32]; char *buf; gsize len; char *ret; unsigned int n; ret = NULL; snprintf (proc_name, sizeof(proc_name), "/proc/%d/cmdline", pid); if (g_file_get_contents (proc_name, &buf, &len, NULL)) { for (n = 0; n < len; n++) { if (buf[n] == '\0') buf[n] = ' '; } g_strstrip (buf); ret = buf; } return ret; }
+Info
0
get_command_line_for_pid (pid_t pid) { char proc_name[32]; char *buf; gsize len; char *ret; unsigned int n; ret = NULL; snprintf (proc_name, sizeof(proc_name), "/proc/%d/cmdline", pid); if (g_file_get_contents (proc_name, &buf, &len, NULL)) { for (n = 0; n < len; n++) { if (buf[n] == '\0') buf[n] = ' '; } g_strstrip (buf); ret = buf; } return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,339
get_dmmp_device_node (Device *device) { static gchar buf[1024]; g_assert (device->priv->device_is_linux_dmmp); g_snprintf (buf, sizeof (buf), "/dev/mapper/%s", device->priv->linux_dmmp_name); return buf; }
+Info
0
get_dmmp_device_node (Device *device) { static gchar buf[1024]; g_assert (device->priv->device_is_linux_dmmp); g_snprintf (buf, sizeof (buf), "/dev/mapper/%s", device->priv->linux_dmmp_name); return buf; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,340
get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { Device *device = DEVICE (object); switch (prop_id) { case PROP_NATIVE_PATH: g_value_set_string (value, device->priv->native_path); break; case PROP_DEVICE_DETECTION_TIME: g_value_set_uint64 (value, device->priv->device_detection_time); break; case PROP_DEVICE_MEDIA_DETECTION_TIME: g_value_set_uint64 (value, device->priv->device_media_detection_time); break; case PROP_DEVICE_MAJOR: g_value_set_int64 (value, major (device->priv->dev)); break; case PROP_DEVICE_MINOR: g_value_set_int64 (value, minor (device->priv->dev)); break; case PROP_DEVICE_FILE: g_value_set_string (value, device->priv->device_file); break; case PROP_DEVICE_FILE_PRESENTATION: if (device->priv->device_file_presentation != NULL) g_value_set_string (value, device->priv->device_file_presentation); else g_value_set_string (value, device->priv->device_file); break; case PROP_DEVICE_FILE_BY_ID: g_value_set_boxed (value, device->priv->device_file_by_id); break; case PROP_DEVICE_FILE_BY_PATH: g_value_set_boxed (value, device->priv->device_file_by_path); break; case PROP_DEVICE_IS_SYSTEM_INTERNAL: g_value_set_boolean (value, device->priv->device_is_system_internal); break; case PROP_DEVICE_IS_PARTITION: g_value_set_boolean (value, device->priv->device_is_partition); break; case PROP_DEVICE_IS_PARTITION_TABLE: g_value_set_boolean (value, device->priv->device_is_partition_table); break; case PROP_DEVICE_IS_REMOVABLE: g_value_set_boolean (value, device->priv->device_is_removable); break; case PROP_DEVICE_IS_MEDIA_AVAILABLE: g_value_set_boolean (value, device->priv->device_is_media_available); break; case PROP_DEVICE_IS_MEDIA_CHANGE_DETECTED: g_value_set_boolean (value, device->priv->device_is_media_change_detected); break; case PROP_DEVICE_IS_MEDIA_CHANGE_DETECTION_POLLING: g_value_set_boolean (value, device->priv->device_is_media_change_detection_polling); break; case PROP_DEVICE_IS_MEDIA_CHANGE_DETECTION_INHIBITABLE: g_value_set_boolean (value, device->priv->device_is_media_change_detection_inhibitable); break; case PROP_DEVICE_IS_MEDIA_CHANGE_DETECTION_INHIBITED: g_value_set_boolean (value, device->priv->device_is_media_change_detection_inhibited); break; case PROP_DEVICE_IS_READ_ONLY: g_value_set_boolean (value, device->priv->device_is_read_only); break; case PROP_DEVICE_IS_DRIVE: g_value_set_boolean (value, device->priv->device_is_drive); break; case PROP_DEVICE_IS_OPTICAL_DISC: g_value_set_boolean (value, device->priv->device_is_optical_disc); break; case PROP_DEVICE_IS_LUKS: g_value_set_boolean (value, device->priv->device_is_luks); break; case PROP_DEVICE_IS_LUKS_CLEARTEXT: g_value_set_boolean (value, device->priv->device_is_luks_cleartext); break; case PROP_DEVICE_IS_LINUX_MD_COMPONENT: g_value_set_boolean (value, device->priv->device_is_linux_md_component); break; case PROP_DEVICE_IS_LINUX_MD: g_value_set_boolean (value, device->priv->device_is_linux_md); break; case PROP_DEVICE_IS_LINUX_LVM2_LV: g_value_set_boolean (value, device->priv->device_is_linux_lvm2_lv); break; case PROP_DEVICE_IS_LINUX_LVM2_PV: g_value_set_boolean (value, device->priv->device_is_linux_lvm2_pv); break; case PROP_DEVICE_IS_LINUX_DMMP: g_value_set_boolean (value, device->priv->device_is_linux_dmmp); break; case PROP_DEVICE_IS_LINUX_DMMP_COMPONENT: g_value_set_boolean (value, device->priv->device_is_linux_dmmp_component); break; case PROP_DEVICE_IS_LINUX_LOOP: g_value_set_boolean (value, device->priv->device_is_linux_loop); break; case PROP_DEVICE_SIZE: g_value_set_uint64 (value, device->priv->device_size); break; case PROP_DEVICE_BLOCK_SIZE: g_value_set_uint64 (value, device->priv->device_block_size); break; case PROP_DEVICE_IS_MOUNTED: g_value_set_boolean (value, device->priv->device_is_mounted); break; case PROP_DEVICE_MOUNT_PATHS: g_value_set_boxed (value, device->priv->device_mount_paths); break; case PROP_DEVICE_MOUNTED_BY_UID: g_value_set_uint (value, device->priv->device_mounted_by_uid); break; case PROP_DEVICE_PRESENTATION_HIDE: g_value_set_boolean (value, device->priv->device_presentation_hide); break; case PROP_DEVICE_PRESENTATION_NOPOLICY: g_value_set_boolean (value, device->priv->device_presentation_nopolicy); break; case PROP_DEVICE_PRESENTATION_NAME: g_value_set_string (value, device->priv->device_presentation_name); break; case PROP_DEVICE_PRESENTATION_ICON_NAME: g_value_set_string (value, device->priv->device_presentation_icon_name); break; case PROP_JOB_IN_PROGRESS: g_value_set_boolean (value, device->priv->job_in_progress); break; case PROP_JOB_ID: g_value_set_string (value, device->priv->job_id); break; case PROP_JOB_INITIATED_BY_UID: g_value_set_uint (value, device->priv->job_initiated_by_uid); break; case PROP_JOB_IS_CANCELLABLE: g_value_set_boolean (value, device->priv->job_is_cancellable); break; case PROP_JOB_PERCENTAGE: g_value_set_double (value, device->priv->job_percentage); break; case PROP_ID_USAGE: g_value_set_string (value, device->priv->id_usage); break; case PROP_ID_TYPE: g_value_set_string (value, device->priv->id_type); break; case PROP_ID_VERSION: g_value_set_string (value, device->priv->id_version); break; case PROP_ID_UUID: g_value_set_string (value, device->priv->id_uuid); break; case PROP_ID_LABEL: g_value_set_string (value, device->priv->id_label); break; case PROP_PARTITION_SLAVE: if (device->priv->partition_slave != NULL) g_value_set_boxed (value, device->priv->partition_slave); else g_value_set_boxed (value, "/"); break; case PROP_PARTITION_SCHEME: g_value_set_string (value, device->priv->partition_scheme); break; case PROP_PARTITION_TYPE: g_value_set_string (value, device->priv->partition_type); break; case PROP_PARTITION_LABEL: g_value_set_string (value, device->priv->partition_label); break; case PROP_PARTITION_UUID: g_value_set_string (value, device->priv->partition_uuid); break; case PROP_PARTITION_FLAGS: g_value_set_boxed (value, device->priv->partition_flags); break; case PROP_PARTITION_NUMBER: g_value_set_int (value, device->priv->partition_number); break; case PROP_PARTITION_OFFSET: g_value_set_uint64 (value, device->priv->partition_offset); break; case PROP_PARTITION_SIZE: g_value_set_uint64 (value, device->priv->partition_size); break; case PROP_PARTITION_ALIGNMENT_OFFSET: g_value_set_uint64 (value, device->priv->partition_alignment_offset); break; case PROP_PARTITION_TABLE_SCHEME: g_value_set_string (value, device->priv->partition_table_scheme); break; case PROP_PARTITION_TABLE_COUNT: g_value_set_int (value, device->priv->partition_table_count); break; case PROP_LUKS_HOLDER: if (device->priv->luks_holder != NULL) g_value_set_boxed (value, device->priv->luks_holder); else g_value_set_boxed (value, "/"); break; case PROP_LUKS_CLEARTEXT_SLAVE: if (device->priv->luks_cleartext_slave != NULL) g_value_set_boxed (value, device->priv->luks_cleartext_slave); else g_value_set_boxed (value, "/"); break; case PROP_LUKS_CLEARTEXT_UNLOCKED_BY_UID: g_value_set_uint (value, device->priv->luks_cleartext_unlocked_by_uid); break; case PROP_DRIVE_VENDOR: g_value_set_string (value, device->priv->drive_vendor); break; case PROP_DRIVE_MODEL: g_value_set_string (value, device->priv->drive_model); break; case PROP_DRIVE_REVISION: g_value_set_string (value, device->priv->drive_revision); break; case PROP_DRIVE_SERIAL: g_value_set_string (value, device->priv->drive_serial); break; case PROP_DRIVE_WWN: g_value_set_string (value, device->priv->drive_wwn); break; case PROP_DRIVE_CONNECTION_INTERFACE: g_value_set_string (value, device->priv->drive_connection_interface); break; case PROP_DRIVE_CONNECTION_SPEED: g_value_set_uint64 (value, device->priv->drive_connection_speed); break; case PROP_DRIVE_MEDIA_COMPATIBILITY: g_value_set_boxed (value, device->priv->drive_media_compatibility); break; case PROP_DRIVE_MEDIA: g_value_set_string (value, device->priv->drive_media); break; case PROP_DRIVE_IS_MEDIA_EJECTABLE: g_value_set_boolean (value, device->priv->drive_is_media_ejectable); break; case PROP_DRIVE_CAN_DETACH: g_value_set_boolean (value, device->priv->drive_can_detach); break; case PROP_DRIVE_CAN_SPINDOWN: g_value_set_boolean (value, device->priv->drive_can_spindown); break; case PROP_DRIVE_IS_ROTATIONAL: g_value_set_boolean (value, device->priv->drive_is_rotational); break; case PROP_DRIVE_WRITE_CACHE: g_value_set_string (value, device->priv->drive_write_cache); break; case PROP_DRIVE_ROTATION_RATE: g_value_set_uint (value, device->priv->drive_rotation_rate); break; case PROP_DRIVE_ADAPTER: if (device->priv->drive_adapter != NULL) g_value_set_boxed (value, device->priv->drive_adapter); else g_value_set_boxed (value, "/"); break; case PROP_DRIVE_PORTS: g_value_set_boxed (value, device->priv->drive_ports); break; case PROP_DRIVE_SIMILAR_DEVICES: g_value_set_boxed (value, device->priv->drive_similar_devices); break; case PROP_OPTICAL_DISC_IS_BLANK: g_value_set_boolean (value, device->priv->optical_disc_is_blank); break; case PROP_OPTICAL_DISC_IS_APPENDABLE: g_value_set_boolean (value, device->priv->optical_disc_is_appendable); break; case PROP_OPTICAL_DISC_IS_CLOSED: g_value_set_boolean (value, device->priv->optical_disc_is_closed); break; case PROP_OPTICAL_DISC_NUM_TRACKS: g_value_set_uint (value, device->priv->optical_disc_num_tracks); break; case PROP_OPTICAL_DISC_NUM_AUDIO_TRACKS: g_value_set_uint (value, device->priv->optical_disc_num_audio_tracks); break; case PROP_OPTICAL_DISC_NUM_SESSIONS: g_value_set_uint (value, device->priv->optical_disc_num_sessions); break; case PROP_DRIVE_ATA_SMART_IS_AVAILABLE: g_value_set_boolean (value, device->priv->drive_ata_smart_is_available); break; case PROP_DRIVE_ATA_SMART_TIME_COLLECTED: g_value_set_uint64 (value, device->priv->drive_ata_smart_time_collected); break; case PROP_DRIVE_ATA_SMART_STATUS: { const gchar *status; if (device->priv->drive_ata_smart_status == (SkSmartOverall) - 1) status = ""; else status = sk_smart_overall_to_string (device->priv->drive_ata_smart_status); g_value_set_string (value, status); } break; case PROP_DRIVE_ATA_SMART_BLOB: { GArray *a; a = g_array_new (FALSE, FALSE, 1); if (device->priv->drive_ata_smart_blob != NULL) { g_array_append_vals (a, device->priv->drive_ata_smart_blob, device->priv->drive_ata_smart_blob_size); } g_value_set_boxed (value, a); g_array_unref (a); } break; case PROP_LINUX_MD_COMPONENT_LEVEL: g_value_set_string (value, device->priv->linux_md_component_level); break; case PROP_LINUX_MD_COMPONENT_POSITION: g_value_set_int (value, device->priv->linux_md_component_position); break; case PROP_LINUX_MD_COMPONENT_NUM_RAID_DEVICES: g_value_set_int (value, device->priv->linux_md_component_num_raid_devices); break; case PROP_LINUX_MD_COMPONENT_UUID: g_value_set_string (value, device->priv->linux_md_component_uuid); break; case PROP_LINUX_MD_COMPONENT_HOME_HOST: g_value_set_string (value, device->priv->linux_md_component_home_host); break; case PROP_LINUX_MD_COMPONENT_NAME: g_value_set_string (value, device->priv->linux_md_component_name); break; case PROP_LINUX_MD_COMPONENT_VERSION: g_value_set_string (value, device->priv->linux_md_component_version); break; case PROP_LINUX_MD_COMPONENT_HOLDER: if (device->priv->linux_md_component_holder != NULL) g_value_set_boxed (value, device->priv->linux_md_component_holder); else g_value_set_boxed (value, "/"); break; case PROP_LINUX_MD_COMPONENT_STATE: g_value_set_boxed (value, device->priv->linux_md_component_state); break; case PROP_LINUX_MD_STATE: g_value_set_string (value, device->priv->linux_md_state); break; case PROP_LINUX_MD_LEVEL: g_value_set_string (value, device->priv->linux_md_level); break; case PROP_LINUX_MD_NUM_RAID_DEVICES: g_value_set_int (value, device->priv->linux_md_num_raid_devices); break; case PROP_LINUX_MD_UUID: g_value_set_string (value, device->priv->linux_md_uuid); break; case PROP_LINUX_MD_HOME_HOST: g_value_set_string (value, device->priv->linux_md_home_host); break; case PROP_LINUX_MD_NAME: g_value_set_string (value, device->priv->linux_md_name); break; case PROP_LINUX_MD_VERSION: g_value_set_string (value, device->priv->linux_md_version); break; case PROP_LINUX_MD_SLAVES: g_value_set_boxed (value, device->priv->linux_md_slaves); break; case PROP_LINUX_MD_IS_DEGRADED: g_value_set_boolean (value, device->priv->linux_md_is_degraded); break; case PROP_LINUX_MD_SYNC_ACTION: g_value_set_string (value, device->priv->linux_md_sync_action); break; case PROP_LINUX_MD_SYNC_PERCENTAGE: g_value_set_double (value, device->priv->linux_md_sync_percentage); break; case PROP_LINUX_MD_SYNC_SPEED: g_value_set_uint64 (value, device->priv->linux_md_sync_speed); break; case PROP_LINUX_LVM2_LV_NAME: g_value_set_string (value, device->priv->linux_lvm2_lv_name); break; case PROP_LINUX_LVM2_LV_UUID: g_value_set_string (value, device->priv->linux_lvm2_lv_uuid); break; case PROP_LINUX_LVM2_LV_GROUP_NAME: g_value_set_string (value, device->priv->linux_lvm2_lv_group_name); break; case PROP_LINUX_LVM2_LV_GROUP_UUID: g_value_set_string (value, device->priv->linux_lvm2_lv_group_uuid); break; case PROP_LINUX_LVM2_PV_UUID: g_value_set_string (value, device->priv->linux_lvm2_pv_uuid); break; case PROP_LINUX_LVM2_PV_NUM_METADATA_AREAS: g_value_set_uint (value, device->priv->linux_lvm2_pv_num_metadata_areas); break; case PROP_LINUX_LVM2_PV_GROUP_NAME: g_value_set_string (value, device->priv->linux_lvm2_pv_group_name); break; case PROP_LINUX_LVM2_PV_GROUP_UUID: g_value_set_string (value, device->priv->linux_lvm2_pv_group_uuid); break; case PROP_LINUX_LVM2_PV_GROUP_SIZE: g_value_set_uint64 (value, device->priv->linux_lvm2_pv_group_size); break; case PROP_LINUX_LVM2_PV_GROUP_UNALLOCATED_SIZE: g_value_set_uint64 (value, device->priv->linux_lvm2_pv_group_unallocated_size); break; case PROP_LINUX_LVM2_PV_GROUP_SEQUENCE_NUMBER: g_value_set_uint64 (value, device->priv->linux_lvm2_pv_group_sequence_number); break; case PROP_LINUX_LVM2_PV_GROUP_EXTENT_SIZE: g_value_set_uint64 (value, device->priv->linux_lvm2_pv_group_extent_size); break; case PROP_LINUX_LVM2_PV_GROUP_PHYSICAL_VOLUMES: g_value_set_boxed (value, device->priv->linux_lvm2_pv_group_physical_volumes); break; case PROP_LINUX_LVM2_PV_GROUP_LOGICAL_VOLUMES: g_value_set_boxed (value, device->priv->linux_lvm2_pv_group_logical_volumes); break; case PROP_LINUX_DMMP_COMPONENT_HOLDER: if (device->priv->linux_dmmp_component_holder != NULL) g_value_set_boxed (value, device->priv->linux_dmmp_component_holder); else g_value_set_boxed (value, "/"); break; case PROP_LINUX_DMMP_NAME: g_value_set_string (value, device->priv->linux_dmmp_name); break; case PROP_LINUX_DMMP_PARAMETERS: g_value_set_string (value, device->priv->linux_dmmp_parameters); break; case PROP_LINUX_DMMP_SLAVES: g_value_set_boxed (value, device->priv->linux_dmmp_slaves); break; case PROP_LINUX_LOOP_FILENAME: g_value_set_string (value, device->priv->linux_loop_filename); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
+Info
0
get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { Device *device = DEVICE (object); switch (prop_id) { case PROP_NATIVE_PATH: g_value_set_string (value, device->priv->native_path); break; case PROP_DEVICE_DETECTION_TIME: g_value_set_uint64 (value, device->priv->device_detection_time); break; case PROP_DEVICE_MEDIA_DETECTION_TIME: g_value_set_uint64 (value, device->priv->device_media_detection_time); break; case PROP_DEVICE_MAJOR: g_value_set_int64 (value, major (device->priv->dev)); break; case PROP_DEVICE_MINOR: g_value_set_int64 (value, minor (device->priv->dev)); break; case PROP_DEVICE_FILE: g_value_set_string (value, device->priv->device_file); break; case PROP_DEVICE_FILE_PRESENTATION: if (device->priv->device_file_presentation != NULL) g_value_set_string (value, device->priv->device_file_presentation); else g_value_set_string (value, device->priv->device_file); break; case PROP_DEVICE_FILE_BY_ID: g_value_set_boxed (value, device->priv->device_file_by_id); break; case PROP_DEVICE_FILE_BY_PATH: g_value_set_boxed (value, device->priv->device_file_by_path); break; case PROP_DEVICE_IS_SYSTEM_INTERNAL: g_value_set_boolean (value, device->priv->device_is_system_internal); break; case PROP_DEVICE_IS_PARTITION: g_value_set_boolean (value, device->priv->device_is_partition); break; case PROP_DEVICE_IS_PARTITION_TABLE: g_value_set_boolean (value, device->priv->device_is_partition_table); break; case PROP_DEVICE_IS_REMOVABLE: g_value_set_boolean (value, device->priv->device_is_removable); break; case PROP_DEVICE_IS_MEDIA_AVAILABLE: g_value_set_boolean (value, device->priv->device_is_media_available); break; case PROP_DEVICE_IS_MEDIA_CHANGE_DETECTED: g_value_set_boolean (value, device->priv->device_is_media_change_detected); break; case PROP_DEVICE_IS_MEDIA_CHANGE_DETECTION_POLLING: g_value_set_boolean (value, device->priv->device_is_media_change_detection_polling); break; case PROP_DEVICE_IS_MEDIA_CHANGE_DETECTION_INHIBITABLE: g_value_set_boolean (value, device->priv->device_is_media_change_detection_inhibitable); break; case PROP_DEVICE_IS_MEDIA_CHANGE_DETECTION_INHIBITED: g_value_set_boolean (value, device->priv->device_is_media_change_detection_inhibited); break; case PROP_DEVICE_IS_READ_ONLY: g_value_set_boolean (value, device->priv->device_is_read_only); break; case PROP_DEVICE_IS_DRIVE: g_value_set_boolean (value, device->priv->device_is_drive); break; case PROP_DEVICE_IS_OPTICAL_DISC: g_value_set_boolean (value, device->priv->device_is_optical_disc); break; case PROP_DEVICE_IS_LUKS: g_value_set_boolean (value, device->priv->device_is_luks); break; case PROP_DEVICE_IS_LUKS_CLEARTEXT: g_value_set_boolean (value, device->priv->device_is_luks_cleartext); break; case PROP_DEVICE_IS_LINUX_MD_COMPONENT: g_value_set_boolean (value, device->priv->device_is_linux_md_component); break; case PROP_DEVICE_IS_LINUX_MD: g_value_set_boolean (value, device->priv->device_is_linux_md); break; case PROP_DEVICE_IS_LINUX_LVM2_LV: g_value_set_boolean (value, device->priv->device_is_linux_lvm2_lv); break; case PROP_DEVICE_IS_LINUX_LVM2_PV: g_value_set_boolean (value, device->priv->device_is_linux_lvm2_pv); break; case PROP_DEVICE_IS_LINUX_DMMP: g_value_set_boolean (value, device->priv->device_is_linux_dmmp); break; case PROP_DEVICE_IS_LINUX_DMMP_COMPONENT: g_value_set_boolean (value, device->priv->device_is_linux_dmmp_component); break; case PROP_DEVICE_IS_LINUX_LOOP: g_value_set_boolean (value, device->priv->device_is_linux_loop); break; case PROP_DEVICE_SIZE: g_value_set_uint64 (value, device->priv->device_size); break; case PROP_DEVICE_BLOCK_SIZE: g_value_set_uint64 (value, device->priv->device_block_size); break; case PROP_DEVICE_IS_MOUNTED: g_value_set_boolean (value, device->priv->device_is_mounted); break; case PROP_DEVICE_MOUNT_PATHS: g_value_set_boxed (value, device->priv->device_mount_paths); break; case PROP_DEVICE_MOUNTED_BY_UID: g_value_set_uint (value, device->priv->device_mounted_by_uid); break; case PROP_DEVICE_PRESENTATION_HIDE: g_value_set_boolean (value, device->priv->device_presentation_hide); break; case PROP_DEVICE_PRESENTATION_NOPOLICY: g_value_set_boolean (value, device->priv->device_presentation_nopolicy); break; case PROP_DEVICE_PRESENTATION_NAME: g_value_set_string (value, device->priv->device_presentation_name); break; case PROP_DEVICE_PRESENTATION_ICON_NAME: g_value_set_string (value, device->priv->device_presentation_icon_name); break; case PROP_JOB_IN_PROGRESS: g_value_set_boolean (value, device->priv->job_in_progress); break; case PROP_JOB_ID: g_value_set_string (value, device->priv->job_id); break; case PROP_JOB_INITIATED_BY_UID: g_value_set_uint (value, device->priv->job_initiated_by_uid); break; case PROP_JOB_IS_CANCELLABLE: g_value_set_boolean (value, device->priv->job_is_cancellable); break; case PROP_JOB_PERCENTAGE: g_value_set_double (value, device->priv->job_percentage); break; case PROP_ID_USAGE: g_value_set_string (value, device->priv->id_usage); break; case PROP_ID_TYPE: g_value_set_string (value, device->priv->id_type); break; case PROP_ID_VERSION: g_value_set_string (value, device->priv->id_version); break; case PROP_ID_UUID: g_value_set_string (value, device->priv->id_uuid); break; case PROP_ID_LABEL: g_value_set_string (value, device->priv->id_label); break; case PROP_PARTITION_SLAVE: if (device->priv->partition_slave != NULL) g_value_set_boxed (value, device->priv->partition_slave); else g_value_set_boxed (value, "/"); break; case PROP_PARTITION_SCHEME: g_value_set_string (value, device->priv->partition_scheme); break; case PROP_PARTITION_TYPE: g_value_set_string (value, device->priv->partition_type); break; case PROP_PARTITION_LABEL: g_value_set_string (value, device->priv->partition_label); break; case PROP_PARTITION_UUID: g_value_set_string (value, device->priv->partition_uuid); break; case PROP_PARTITION_FLAGS: g_value_set_boxed (value, device->priv->partition_flags); break; case PROP_PARTITION_NUMBER: g_value_set_int (value, device->priv->partition_number); break; case PROP_PARTITION_OFFSET: g_value_set_uint64 (value, device->priv->partition_offset); break; case PROP_PARTITION_SIZE: g_value_set_uint64 (value, device->priv->partition_size); break; case PROP_PARTITION_ALIGNMENT_OFFSET: g_value_set_uint64 (value, device->priv->partition_alignment_offset); break; case PROP_PARTITION_TABLE_SCHEME: g_value_set_string (value, device->priv->partition_table_scheme); break; case PROP_PARTITION_TABLE_COUNT: g_value_set_int (value, device->priv->partition_table_count); break; case PROP_LUKS_HOLDER: if (device->priv->luks_holder != NULL) g_value_set_boxed (value, device->priv->luks_holder); else g_value_set_boxed (value, "/"); break; case PROP_LUKS_CLEARTEXT_SLAVE: if (device->priv->luks_cleartext_slave != NULL) g_value_set_boxed (value, device->priv->luks_cleartext_slave); else g_value_set_boxed (value, "/"); break; case PROP_LUKS_CLEARTEXT_UNLOCKED_BY_UID: g_value_set_uint (value, device->priv->luks_cleartext_unlocked_by_uid); break; case PROP_DRIVE_VENDOR: g_value_set_string (value, device->priv->drive_vendor); break; case PROP_DRIVE_MODEL: g_value_set_string (value, device->priv->drive_model); break; case PROP_DRIVE_REVISION: g_value_set_string (value, device->priv->drive_revision); break; case PROP_DRIVE_SERIAL: g_value_set_string (value, device->priv->drive_serial); break; case PROP_DRIVE_WWN: g_value_set_string (value, device->priv->drive_wwn); break; case PROP_DRIVE_CONNECTION_INTERFACE: g_value_set_string (value, device->priv->drive_connection_interface); break; case PROP_DRIVE_CONNECTION_SPEED: g_value_set_uint64 (value, device->priv->drive_connection_speed); break; case PROP_DRIVE_MEDIA_COMPATIBILITY: g_value_set_boxed (value, device->priv->drive_media_compatibility); break; case PROP_DRIVE_MEDIA: g_value_set_string (value, device->priv->drive_media); break; case PROP_DRIVE_IS_MEDIA_EJECTABLE: g_value_set_boolean (value, device->priv->drive_is_media_ejectable); break; case PROP_DRIVE_CAN_DETACH: g_value_set_boolean (value, device->priv->drive_can_detach); break; case PROP_DRIVE_CAN_SPINDOWN: g_value_set_boolean (value, device->priv->drive_can_spindown); break; case PROP_DRIVE_IS_ROTATIONAL: g_value_set_boolean (value, device->priv->drive_is_rotational); break; case PROP_DRIVE_WRITE_CACHE: g_value_set_string (value, device->priv->drive_write_cache); break; case PROP_DRIVE_ROTATION_RATE: g_value_set_uint (value, device->priv->drive_rotation_rate); break; case PROP_DRIVE_ADAPTER: if (device->priv->drive_adapter != NULL) g_value_set_boxed (value, device->priv->drive_adapter); else g_value_set_boxed (value, "/"); break; case PROP_DRIVE_PORTS: g_value_set_boxed (value, device->priv->drive_ports); break; case PROP_DRIVE_SIMILAR_DEVICES: g_value_set_boxed (value, device->priv->drive_similar_devices); break; case PROP_OPTICAL_DISC_IS_BLANK: g_value_set_boolean (value, device->priv->optical_disc_is_blank); break; case PROP_OPTICAL_DISC_IS_APPENDABLE: g_value_set_boolean (value, device->priv->optical_disc_is_appendable); break; case PROP_OPTICAL_DISC_IS_CLOSED: g_value_set_boolean (value, device->priv->optical_disc_is_closed); break; case PROP_OPTICAL_DISC_NUM_TRACKS: g_value_set_uint (value, device->priv->optical_disc_num_tracks); break; case PROP_OPTICAL_DISC_NUM_AUDIO_TRACKS: g_value_set_uint (value, device->priv->optical_disc_num_audio_tracks); break; case PROP_OPTICAL_DISC_NUM_SESSIONS: g_value_set_uint (value, device->priv->optical_disc_num_sessions); break; case PROP_DRIVE_ATA_SMART_IS_AVAILABLE: g_value_set_boolean (value, device->priv->drive_ata_smart_is_available); break; case PROP_DRIVE_ATA_SMART_TIME_COLLECTED: g_value_set_uint64 (value, device->priv->drive_ata_smart_time_collected); break; case PROP_DRIVE_ATA_SMART_STATUS: { const gchar *status; if (device->priv->drive_ata_smart_status == (SkSmartOverall) - 1) status = ""; else status = sk_smart_overall_to_string (device->priv->drive_ata_smart_status); g_value_set_string (value, status); } break; case PROP_DRIVE_ATA_SMART_BLOB: { GArray *a; a = g_array_new (FALSE, FALSE, 1); if (device->priv->drive_ata_smart_blob != NULL) { g_array_append_vals (a, device->priv->drive_ata_smart_blob, device->priv->drive_ata_smart_blob_size); } g_value_set_boxed (value, a); g_array_unref (a); } break; case PROP_LINUX_MD_COMPONENT_LEVEL: g_value_set_string (value, device->priv->linux_md_component_level); break; case PROP_LINUX_MD_COMPONENT_POSITION: g_value_set_int (value, device->priv->linux_md_component_position); break; case PROP_LINUX_MD_COMPONENT_NUM_RAID_DEVICES: g_value_set_int (value, device->priv->linux_md_component_num_raid_devices); break; case PROP_LINUX_MD_COMPONENT_UUID: g_value_set_string (value, device->priv->linux_md_component_uuid); break; case PROP_LINUX_MD_COMPONENT_HOME_HOST: g_value_set_string (value, device->priv->linux_md_component_home_host); break; case PROP_LINUX_MD_COMPONENT_NAME: g_value_set_string (value, device->priv->linux_md_component_name); break; case PROP_LINUX_MD_COMPONENT_VERSION: g_value_set_string (value, device->priv->linux_md_component_version); break; case PROP_LINUX_MD_COMPONENT_HOLDER: if (device->priv->linux_md_component_holder != NULL) g_value_set_boxed (value, device->priv->linux_md_component_holder); else g_value_set_boxed (value, "/"); break; case PROP_LINUX_MD_COMPONENT_STATE: g_value_set_boxed (value, device->priv->linux_md_component_state); break; case PROP_LINUX_MD_STATE: g_value_set_string (value, device->priv->linux_md_state); break; case PROP_LINUX_MD_LEVEL: g_value_set_string (value, device->priv->linux_md_level); break; case PROP_LINUX_MD_NUM_RAID_DEVICES: g_value_set_int (value, device->priv->linux_md_num_raid_devices); break; case PROP_LINUX_MD_UUID: g_value_set_string (value, device->priv->linux_md_uuid); break; case PROP_LINUX_MD_HOME_HOST: g_value_set_string (value, device->priv->linux_md_home_host); break; case PROP_LINUX_MD_NAME: g_value_set_string (value, device->priv->linux_md_name); break; case PROP_LINUX_MD_VERSION: g_value_set_string (value, device->priv->linux_md_version); break; case PROP_LINUX_MD_SLAVES: g_value_set_boxed (value, device->priv->linux_md_slaves); break; case PROP_LINUX_MD_IS_DEGRADED: g_value_set_boolean (value, device->priv->linux_md_is_degraded); break; case PROP_LINUX_MD_SYNC_ACTION: g_value_set_string (value, device->priv->linux_md_sync_action); break; case PROP_LINUX_MD_SYNC_PERCENTAGE: g_value_set_double (value, device->priv->linux_md_sync_percentage); break; case PROP_LINUX_MD_SYNC_SPEED: g_value_set_uint64 (value, device->priv->linux_md_sync_speed); break; case PROP_LINUX_LVM2_LV_NAME: g_value_set_string (value, device->priv->linux_lvm2_lv_name); break; case PROP_LINUX_LVM2_LV_UUID: g_value_set_string (value, device->priv->linux_lvm2_lv_uuid); break; case PROP_LINUX_LVM2_LV_GROUP_NAME: g_value_set_string (value, device->priv->linux_lvm2_lv_group_name); break; case PROP_LINUX_LVM2_LV_GROUP_UUID: g_value_set_string (value, device->priv->linux_lvm2_lv_group_uuid); break; case PROP_LINUX_LVM2_PV_UUID: g_value_set_string (value, device->priv->linux_lvm2_pv_uuid); break; case PROP_LINUX_LVM2_PV_NUM_METADATA_AREAS: g_value_set_uint (value, device->priv->linux_lvm2_pv_num_metadata_areas); break; case PROP_LINUX_LVM2_PV_GROUP_NAME: g_value_set_string (value, device->priv->linux_lvm2_pv_group_name); break; case PROP_LINUX_LVM2_PV_GROUP_UUID: g_value_set_string (value, device->priv->linux_lvm2_pv_group_uuid); break; case PROP_LINUX_LVM2_PV_GROUP_SIZE: g_value_set_uint64 (value, device->priv->linux_lvm2_pv_group_size); break; case PROP_LINUX_LVM2_PV_GROUP_UNALLOCATED_SIZE: g_value_set_uint64 (value, device->priv->linux_lvm2_pv_group_unallocated_size); break; case PROP_LINUX_LVM2_PV_GROUP_SEQUENCE_NUMBER: g_value_set_uint64 (value, device->priv->linux_lvm2_pv_group_sequence_number); break; case PROP_LINUX_LVM2_PV_GROUP_EXTENT_SIZE: g_value_set_uint64 (value, device->priv->linux_lvm2_pv_group_extent_size); break; case PROP_LINUX_LVM2_PV_GROUP_PHYSICAL_VOLUMES: g_value_set_boxed (value, device->priv->linux_lvm2_pv_group_physical_volumes); break; case PROP_LINUX_LVM2_PV_GROUP_LOGICAL_VOLUMES: g_value_set_boxed (value, device->priv->linux_lvm2_pv_group_logical_volumes); break; case PROP_LINUX_DMMP_COMPONENT_HOLDER: if (device->priv->linux_dmmp_component_holder != NULL) g_value_set_boxed (value, device->priv->linux_dmmp_component_holder); else g_value_set_boxed (value, "/"); break; case PROP_LINUX_DMMP_NAME: g_value_set_string (value, device->priv->linux_dmmp_name); break; case PROP_LINUX_DMMP_PARAMETERS: g_value_set_string (value, device->priv->linux_dmmp_parameters); break; case PROP_LINUX_DMMP_SLAVES: g_value_set_boxed (value, device->priv->linux_dmmp_slaves); break; case PROP_LINUX_LOOP_FILENAME: g_value_set_string (value, device->priv->linux_loop_filename); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,341
is_device_in_fstab (Device *device, char **out_mount_point) { GList *l; GList *mount_points; gboolean ret; ret = FALSE; mount_points = g_unix_mount_points_get (NULL); for (l = mount_points; l != NULL; l = l->next) { GUnixMountPoint *mount_point = l->data; char canonical_device_file[PATH_MAX]; char *device_path; char *s; device_path = g_strdup (g_unix_mount_point_get_device_path (mount_point)); /* get the canonical path; e.g. resolve * * /dev/disk/by-path/pci-0000:00:1d.7-usb-0:3:1.0-scsi-0:0:0:3-part5 * UUID=78af6939-adac-4ea5-a2a8-576e141da010 * LABEL=foobar * * into something like /dev/sde5. */ if (g_str_has_prefix (device_path, "UUID=")) { s = device_path; device_path = g_strdup_printf ("/dev/disk/by-uuid/%s", device_path + 5); g_free (s); } else if (g_str_has_prefix (device_path, "LABEL=")) { s = device_path; device_path = g_strdup_printf ("/dev/disk/by-label/%s", device_path + 6); g_free (s); } if (realpath (device_path, canonical_device_file) == NULL) { g_free (device_path); continue; } g_free (device_path); if (strcmp (device->priv->device_file, canonical_device_file) == 0) { ret = TRUE; if (out_mount_point != NULL) *out_mount_point = g_strdup (g_unix_mount_point_get_mount_path (mount_point)); break; } } g_list_foreach (mount_points, (GFunc) g_unix_mount_point_free, NULL); g_list_free (mount_points); return ret; }
+Info
0
is_device_in_fstab (Device *device, char **out_mount_point) { GList *l; GList *mount_points; gboolean ret; ret = FALSE; mount_points = g_unix_mount_points_get (NULL); for (l = mount_points; l != NULL; l = l->next) { GUnixMountPoint *mount_point = l->data; char canonical_device_file[PATH_MAX]; char *device_path; char *s; device_path = g_strdup (g_unix_mount_point_get_device_path (mount_point)); /* get the canonical path; e.g. resolve * * /dev/disk/by-path/pci-0000:00:1d.7-usb-0:3:1.0-scsi-0:0:0:3-part5 * UUID=78af6939-adac-4ea5-a2a8-576e141da010 * LABEL=foobar * * into something like /dev/sde5. */ if (g_str_has_prefix (device_path, "UUID=")) { s = device_path; device_path = g_strdup_printf ("/dev/disk/by-uuid/%s", device_path + 5); g_free (s); } else if (g_str_has_prefix (device_path, "LABEL=")) { s = device_path; device_path = g_strdup_printf ("/dev/disk/by-label/%s", device_path + 6); g_free (s); } if (realpath (device_path, canonical_device_file) == NULL) { g_free (device_path); continue; } g_free (device_path); if (strcmp (device->priv->device_file, canonical_device_file) == 0) { ret = TRUE; if (out_mount_point != NULL) *out_mount_point = g_strdup (g_unix_mount_point_get_mount_path (mount_point)); break; } } g_list_foreach (mount_points, (GFunc) g_unix_mount_point_free, NULL); g_list_free (mount_points); return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,342
is_mount_option_allowed (const FSMountOptions *fsmo, const char *option, uid_t caller_uid) { int n; char *endp; uid_t uid; gid_t gid; gboolean allowed; const char *ep; gsize ep_len; allowed = FALSE; /* first run through the allowed mount options */ if (fsmo != NULL) { for (n = 0; fsmo->allow != NULL && fsmo->allow[n] != NULL; n++) { ep = strstr (fsmo->allow[n], "="); if (ep != NULL && ep[1] == '\0') { ep_len = ep - fsmo->allow[n] + 1; if (strncmp (fsmo->allow[n], option, ep_len) == 0) { allowed = TRUE; goto out; } } else { if (strcmp (fsmo->allow[n], option) == 0) { allowed = TRUE; goto out; } } } } for (n = 0; any_allow[n] != NULL; n++) { ep = strstr (any_allow[n], "="); if (ep != NULL && ep[1] == '\0') { ep_len = ep - any_allow[n] + 1; if (strncmp (any_allow[n], option, ep_len) == 0) { allowed = TRUE; goto out; } } else { if (strcmp (any_allow[n], option) == 0) { allowed = TRUE; goto out; } } } /* .. then check for mount options where the caller is allowed to pass * in his own uid */ if (fsmo != NULL) { for (n = 0; fsmo->allow_uid_self != NULL && fsmo->allow_uid_self[n] != NULL; n++) { const char *r_mount_option = fsmo->allow_uid_self[n]; if (g_str_has_prefix (option, r_mount_option)) { uid = strtol (option + strlen (r_mount_option), &endp, 10); if (*endp != '\0') continue; if (uid == caller_uid) { allowed = TRUE; goto out; } } } } /* .. ditto for gid */ if (fsmo != NULL) { for (n = 0; fsmo->allow_gid_self != NULL && fsmo->allow_gid_self[n] != NULL; n++) { const char *r_mount_option = fsmo->allow_gid_self[n]; if (g_str_has_prefix (option, r_mount_option)) { gid = strtol (option + strlen (r_mount_option), &endp, 10); if (*endp != '\0') continue; if (is_uid_in_gid (caller_uid, gid)) { allowed = TRUE; goto out; } } } } out: return allowed; }
+Info
0
is_mount_option_allowed (const FSMountOptions *fsmo, const char *option, uid_t caller_uid) { int n; char *endp; uid_t uid; gid_t gid; gboolean allowed; const char *ep; gsize ep_len; allowed = FALSE; /* first run through the allowed mount options */ if (fsmo != NULL) { for (n = 0; fsmo->allow != NULL && fsmo->allow[n] != NULL; n++) { ep = strstr (fsmo->allow[n], "="); if (ep != NULL && ep[1] == '\0') { ep_len = ep - fsmo->allow[n] + 1; if (strncmp (fsmo->allow[n], option, ep_len) == 0) { allowed = TRUE; goto out; } } else { if (strcmp (fsmo->allow[n], option) == 0) { allowed = TRUE; goto out; } } } } for (n = 0; any_allow[n] != NULL; n++) { ep = strstr (any_allow[n], "="); if (ep != NULL && ep[1] == '\0') { ep_len = ep - any_allow[n] + 1; if (strncmp (any_allow[n], option, ep_len) == 0) { allowed = TRUE; goto out; } } else { if (strcmp (any_allow[n], option) == 0) { allowed = TRUE; goto out; } } } /* .. then check for mount options where the caller is allowed to pass * in his own uid */ if (fsmo != NULL) { for (n = 0; fsmo->allow_uid_self != NULL && fsmo->allow_uid_self[n] != NULL; n++) { const char *r_mount_option = fsmo->allow_uid_self[n]; if (g_str_has_prefix (option, r_mount_option)) { uid = strtol (option + strlen (r_mount_option), &endp, 10); if (*endp != '\0') continue; if (uid == caller_uid) { allowed = TRUE; goto out; } } } } /* .. ditto for gid */ if (fsmo != NULL) { for (n = 0; fsmo->allow_gid_self != NULL && fsmo->allow_gid_self[n] != NULL; n++) { const char *r_mount_option = fsmo->allow_gid_self[n]; if (g_str_has_prefix (option, r_mount_option)) { gid = strtol (option + strlen (r_mount_option), &endp, 10); if (*endp != '\0') continue; if (is_uid_in_gid (caller_uid, gid)) { allowed = TRUE; goto out; } } } } out: return allowed; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,343
is_uid_in_gid (uid_t uid, gid_t gid) { gboolean ret; struct passwd *pw; static gid_t supplementary_groups[128]; int num_supplementary_groups = 128; int n; /* TODO: use some #define instead of harcoding some random number like 128 */ ret = FALSE; pw = getpwuid (uid); if (pw == NULL) { g_warning ("Couldn't look up uid %d: %m", uid); goto out; } if (pw->pw_gid == gid) { ret = TRUE; goto out; } if (getgrouplist (pw->pw_name, pw->pw_gid, supplementary_groups, &num_supplementary_groups) < 0) { g_warning ("Couldn't find supplementary groups for uid %d: %m", uid); goto out; } for (n = 0; n < num_supplementary_groups; n++) { if (supplementary_groups[n] == gid) { ret = TRUE; goto out; } } out: return ret; }
+Info
0
is_uid_in_gid (uid_t uid, gid_t gid) { gboolean ret; struct passwd *pw; static gid_t supplementary_groups[128]; int num_supplementary_groups = 128; int n; /* TODO: use some #define instead of harcoding some random number like 128 */ ret = FALSE; pw = getpwuid (uid); if (pw == NULL) { g_warning ("Couldn't look up uid %d: %m", uid); goto out; } if (pw->pw_gid == gid) { ret = TRUE; goto out; } if (getgrouplist (pw->pw_name, pw->pw_gid, supplementary_groups, &num_supplementary_groups) < 0) { g_warning ("Couldn't find supplementary groups for uid %d: %m", uid); goto out; } for (n = 0; n < num_supplementary_groups; n++) { if (supplementary_groups[n] == gid) { ret = TRUE; goto out; } } out: return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,344
job_cancel (Device *device) { g_return_if_fail (device->priv->job != NULL); device->priv->job->was_cancelled = TRUE; /* TODO: maybe wait and user a bigger hammer? (SIGKILL) */ kill (device->priv->job->pid, SIGTERM); }
+Info
0
job_cancel (Device *device) { g_return_if_fail (device->priv->job != NULL); device->priv->job->was_cancelled = TRUE; /* TODO: maybe wait and user a bigger hammer? (SIGKILL) */ kill (device->priv->job->pid, SIGTERM); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,345
job_child_watch_cb (GPid pid, int status, gpointer user_data) { char *buf; gsize buf_size; Job *job = user_data; if (g_io_channel_read_to_end (job->error_channel, &buf, &buf_size, NULL) == G_IO_STATUS_NORMAL) { g_string_append_len (job->error_string, buf, buf_size); g_free (buf); } if (g_io_channel_read_to_end (job->out_channel, &buf, &buf_size, NULL) == G_IO_STATUS_NORMAL) { g_string_append_len (job->stdout_string, buf, buf_size); g_free (buf); } PROFILE ("job finish (id=%s, pid=%i, device=%s)", job->job_id, job->pid, job->device ? job->device->priv->device_file : "none"); g_print ("helper(pid %5d): completed with exit code %d\n", job->pid, WEXITSTATUS (status)); job->status = status; /* if requested, run 'udevadm settle' on success */ if (!job->was_cancelled && WIFEXITED (status) && WEXITSTATUS (status) == 0 && job->udev_settle) { GError *error; gchar *argv[] = { "udevadm", "settle", "--quiet", NULL }; GPid udevadm_pid; error = NULL; if (!g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &udevadm_pid, &error)) { g_warning ("Error running 'udevadm settle --quiet': %s", error->message); g_error_free (error); job_complete (job); } else { g_child_watch_add (udevadm_pid, job_udevadm_settle_child_cb, job); } } else { /* return immediately on error */ job_complete (job); } }
+Info
0
job_child_watch_cb (GPid pid, int status, gpointer user_data) { char *buf; gsize buf_size; Job *job = user_data; if (g_io_channel_read_to_end (job->error_channel, &buf, &buf_size, NULL) == G_IO_STATUS_NORMAL) { g_string_append_len (job->error_string, buf, buf_size); g_free (buf); } if (g_io_channel_read_to_end (job->out_channel, &buf, &buf_size, NULL) == G_IO_STATUS_NORMAL) { g_string_append_len (job->stdout_string, buf, buf_size); g_free (buf); } PROFILE ("job finish (id=%s, pid=%i, device=%s)", job->job_id, job->pid, job->device ? job->device->priv->device_file : "none"); g_print ("helper(pid %5d): completed with exit code %d\n", job->pid, WEXITSTATUS (status)); job->status = status; /* if requested, run 'udevadm settle' on success */ if (!job->was_cancelled && WIFEXITED (status) && WEXITSTATUS (status) == 0 && job->udev_settle) { GError *error; gchar *argv[] = { "udevadm", "settle", "--quiet", NULL }; GPid udevadm_pid; error = NULL; if (!g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &udevadm_pid, &error)) { g_warning ("Error running 'udevadm settle --quiet': %s", error->message); g_error_free (error); job_complete (job); } else { g_child_watch_add (udevadm_pid, job_udevadm_settle_child_cb, job); } } else { /* return immediately on error */ job_complete (job); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,346
job_complete (Job *job) { if (job->device != NULL && job->job_id != NULL) { job->device->priv->job_in_progress = FALSE; g_free (job->device->priv->job_id); job->device->priv->job_id = NULL; job->device->priv->job_initiated_by_uid = 0; job->device->priv->job_is_cancellable = FALSE; job->device->priv->job_percentage = -1.0; job->device->priv->job = NULL; } job->job_completed_func (job->context, job->device, job->was_cancelled, job->status, job->error_string->str, job->stdout_string->str, job->user_data); if (job->device != NULL && job->job_id != NULL) { emit_job_changed (job->device); } job_free (job); }
+Info
0
job_complete (Job *job) { if (job->device != NULL && job->job_id != NULL) { job->device->priv->job_in_progress = FALSE; g_free (job->device->priv->job_id); job->device->priv->job_id = NULL; job->device->priv->job_initiated_by_uid = 0; job->device->priv->job_is_cancellable = FALSE; job->device->priv->job_percentage = -1.0; job->device->priv->job = NULL; } job->job_completed_func (job->context, job->device, job->was_cancelled, job->status, job->error_string->str, job->stdout_string->str, job->user_data); if (job->device != NULL && job->job_id != NULL) { emit_job_changed (job->device); } job_free (job); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,347
job_free (Job *job) { if (job->user_data_destroy_func != NULL) job->user_data_destroy_func (job->user_data); if (job->device != NULL) g_object_unref (job->device); if (job->stderr_fd >= 0) close (job->stderr_fd); if (job->stdout_fd >= 0) close (job->stdout_fd); if (job->stdin_fd >= 0) { close (job->stdin_fd); g_source_remove (job->in_channel_source_id); g_io_channel_unref (job->in_channel); } g_source_remove (job->error_channel_source_id); g_source_remove (job->out_channel_source_id); g_io_channel_unref (job->error_channel); g_io_channel_unref (job->out_channel); g_string_free (job->error_string, TRUE); /* scrub stdin (may contain secrets) */ if (job->stdin_str != NULL) { memset (job->stdin_str, '\0', strlen (job->stdin_str)); } g_string_free (job->stdout_string, TRUE); g_free (job->stdin_str); g_free (job->job_id); g_free (job); }
+Info
0
job_free (Job *job) { if (job->user_data_destroy_func != NULL) job->user_data_destroy_func (job->user_data); if (job->device != NULL) g_object_unref (job->device); if (job->stderr_fd >= 0) close (job->stderr_fd); if (job->stdout_fd >= 0) close (job->stdout_fd); if (job->stdin_fd >= 0) { close (job->stdin_fd); g_source_remove (job->in_channel_source_id); g_io_channel_unref (job->in_channel); } g_source_remove (job->error_channel_source_id); g_source_remove (job->out_channel_source_id); g_io_channel_unref (job->error_channel); g_io_channel_unref (job->out_channel); g_string_free (job->error_string, TRUE); /* scrub stdin (may contain secrets) */ if (job->stdin_str != NULL) { memset (job->stdin_str, '\0', strlen (job->stdin_str)); } g_string_free (job->stdout_string, TRUE); g_free (job->stdin_str); g_free (job->job_id); g_free (job); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,348
job_local_end (Device *device) { if (!device->priv->job_in_progress || device->priv->job != NULL) { g_warning ("There is no job running"); goto out; } device->priv->job_in_progress = FALSE; g_free (device->priv->job_id); device->priv->job_id = NULL; device->priv->job_initiated_by_uid = 0; device->priv->job_is_cancellable = FALSE; device->priv->job_percentage = -1.0; emit_job_changed (device); out: ; }
+Info
0
job_local_end (Device *device) { if (!device->priv->job_in_progress || device->priv->job != NULL) { g_warning ("There is no job running"); goto out; } device->priv->job_in_progress = FALSE; g_free (device->priv->job_id); device->priv->job_id = NULL; device->priv->job_initiated_by_uid = 0; device->priv->job_is_cancellable = FALSE; device->priv->job_percentage = -1.0; emit_job_changed (device); out: ; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,349
job_new (DBusGMethodInvocation *context, const char *job_id, gboolean is_cancellable, Device *device, char **argv, const char *stdin_str, JobCompletedFunc job_completed_func, gboolean udev_settle, /* if TRUE, runs udevsettle before returning if the command succeeded */ gpointer user_data, GDestroyNotify user_data_destroy_func) { Job *job; gboolean ret; GError *error; ret = FALSE; job = NULL; PROFILE ("job_new(id=%s, device=%s): start", job_id ? job_id : argv[0], device ? device->priv->device_file : "none"); if (device != NULL) { if (device->priv->job != NULL || device->priv->job_in_progress) { throw_error (context, ERROR_BUSY, "There is already a job running"); goto out; } } job = g_new0 (Job, 1); job->context = context; job->device = device != NULL ? DEVICE (g_object_ref (device)) : NULL; job->job_completed_func = job_completed_func; job->user_data = user_data; job->user_data_destroy_func = user_data_destroy_func; job->stderr_fd = -1; job->stdout_fd = -1; job->stdin_fd = -1; job->stdin_str = g_strdup (stdin_str); job->stdin_cursor = job->stdin_str; job->stdout_string = g_string_sized_new (1024); job->job_id = g_strdup (job_id); job->udev_settle = udev_settle; if (device != NULL && job_id != NULL) { g_free (job->device->priv->job_id); job->device->priv->job_id = g_strdup (job_id); } error = NULL; if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &(job->pid), stdin_str != NULL ? &(job->stdin_fd) : NULL, &(job->stdout_fd), &(job->stderr_fd), &error)) { throw_error (context, ERROR_FAILED, "Error starting job: %s", error->message); g_error_free (error); goto out; } g_child_watch_add (job->pid, job_child_watch_cb, job); job->error_string = g_string_new (""); job->error_channel = g_io_channel_unix_new (job->stderr_fd); error = NULL; if (g_io_channel_set_flags (job->error_channel, G_IO_FLAG_NONBLOCK, &error) != G_IO_STATUS_NORMAL) { g_warning ("Cannon set stderr fd for child to be non blocking: %s", error->message); g_error_free (error); } job->error_channel_source_id = g_io_add_watch (job->error_channel, G_IO_IN, job_read_error, job); job->out_channel = g_io_channel_unix_new (job->stdout_fd); error = NULL; if (g_io_channel_set_flags (job->out_channel, G_IO_FLAG_NONBLOCK, &error) != G_IO_STATUS_NORMAL) { g_warning ("Cannon set stdout fd for child to be non blocking: %s", error->message); g_error_free (error); } job->out_channel_source_id = g_io_add_watch (job->out_channel, G_IO_IN, job_read_out, job); if (job->stdin_fd >= 0) { job->in_channel = g_io_channel_unix_new (job->stdin_fd); if (g_io_channel_set_flags (job->in_channel, G_IO_FLAG_NONBLOCK, &error) != G_IO_STATUS_NORMAL) { g_warning ("Cannon set stdin fd for child to be non blocking: %s", error->message); g_error_free (error); } job->in_channel_source_id = g_io_add_watch (job->in_channel, G_IO_OUT, job_write_in, job); } ret = TRUE; if (device != NULL && job_id != NULL) { device->priv->job_in_progress = TRUE; device->priv->job_is_cancellable = is_cancellable; device->priv->job_percentage = -1.0; device->priv->job_initiated_by_uid = 0; if (context != NULL) { daemon_local_get_uid (device->priv->daemon, &(device->priv->job_initiated_by_uid), context); } device->priv->job = job; emit_job_changed (device); } if (device != NULL) { g_print ("helper(pid %5d): launched job %s on %s\n", job->pid, argv[0], device->priv->device_file); } else { g_print ("helper(pid %5d): launched job %s on daemon\n", job->pid, argv[0]); } out: if (!ret && job != NULL) job_free (job); PROFILE ("job_new(id=%s, device=%s): end", job_id, device ? device->priv->device_file : "none"); return ret; }
+Info
0
job_new (DBusGMethodInvocation *context, const char *job_id, gboolean is_cancellable, Device *device, char **argv, const char *stdin_str, JobCompletedFunc job_completed_func, gboolean udev_settle, /* if TRUE, runs udevsettle before returning if the command succeeded */ gpointer user_data, GDestroyNotify user_data_destroy_func) { Job *job; gboolean ret; GError *error; ret = FALSE; job = NULL; PROFILE ("job_new(id=%s, device=%s): start", job_id ? job_id : argv[0], device ? device->priv->device_file : "none"); if (device != NULL) { if (device->priv->job != NULL || device->priv->job_in_progress) { throw_error (context, ERROR_BUSY, "There is already a job running"); goto out; } } job = g_new0 (Job, 1); job->context = context; job->device = device != NULL ? DEVICE (g_object_ref (device)) : NULL; job->job_completed_func = job_completed_func; job->user_data = user_data; job->user_data_destroy_func = user_data_destroy_func; job->stderr_fd = -1; job->stdout_fd = -1; job->stdin_fd = -1; job->stdin_str = g_strdup (stdin_str); job->stdin_cursor = job->stdin_str; job->stdout_string = g_string_sized_new (1024); job->job_id = g_strdup (job_id); job->udev_settle = udev_settle; if (device != NULL && job_id != NULL) { g_free (job->device->priv->job_id); job->device->priv->job_id = g_strdup (job_id); } error = NULL; if (!g_spawn_async_with_pipes (NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &(job->pid), stdin_str != NULL ? &(job->stdin_fd) : NULL, &(job->stdout_fd), &(job->stderr_fd), &error)) { throw_error (context, ERROR_FAILED, "Error starting job: %s", error->message); g_error_free (error); goto out; } g_child_watch_add (job->pid, job_child_watch_cb, job); job->error_string = g_string_new (""); job->error_channel = g_io_channel_unix_new (job->stderr_fd); error = NULL; if (g_io_channel_set_flags (job->error_channel, G_IO_FLAG_NONBLOCK, &error) != G_IO_STATUS_NORMAL) { g_warning ("Cannon set stderr fd for child to be non blocking: %s", error->message); g_error_free (error); } job->error_channel_source_id = g_io_add_watch (job->error_channel, G_IO_IN, job_read_error, job); job->out_channel = g_io_channel_unix_new (job->stdout_fd); error = NULL; if (g_io_channel_set_flags (job->out_channel, G_IO_FLAG_NONBLOCK, &error) != G_IO_STATUS_NORMAL) { g_warning ("Cannon set stdout fd for child to be non blocking: %s", error->message); g_error_free (error); } job->out_channel_source_id = g_io_add_watch (job->out_channel, G_IO_IN, job_read_out, job); if (job->stdin_fd >= 0) { job->in_channel = g_io_channel_unix_new (job->stdin_fd); if (g_io_channel_set_flags (job->in_channel, G_IO_FLAG_NONBLOCK, &error) != G_IO_STATUS_NORMAL) { g_warning ("Cannon set stdin fd for child to be non blocking: %s", error->message); g_error_free (error); } job->in_channel_source_id = g_io_add_watch (job->in_channel, G_IO_OUT, job_write_in, job); } ret = TRUE; if (device != NULL && job_id != NULL) { device->priv->job_in_progress = TRUE; device->priv->job_is_cancellable = is_cancellable; device->priv->job_percentage = -1.0; device->priv->job_initiated_by_uid = 0; if (context != NULL) { daemon_local_get_uid (device->priv->daemon, &(device->priv->job_initiated_by_uid), context); } device->priv->job = job; emit_job_changed (device); } if (device != NULL) { g_print ("helper(pid %5d): launched job %s on %s\n", job->pid, argv[0], device->priv->device_file); } else { g_print ("helper(pid %5d): launched job %s on daemon\n", job->pid, argv[0]); } out: if (!ret && job != NULL) job_free (job); PROFILE ("job_new(id=%s, device=%s): end", job_id, device ? device->priv->device_file : "none"); return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,350
job_read_out (GIOChannel *channel, GIOCondition condition, gpointer user_data) { char *s; char *line; char buf[1024]; gsize bytes_read; Job *job = user_data; g_io_channel_read_chars (channel, buf, sizeof buf, &bytes_read, NULL); g_string_append_len (job->stdout_string, buf, bytes_read); do { gsize line_len; s = strstr (job->stdout_string->str + job->stdout_string_cursor, "\n"); if (s == NULL) break; line_len = s - (job->stdout_string->str + job->stdout_string_cursor); line = g_strndup (job->stdout_string->str + job->stdout_string_cursor, line_len); job->stdout_string_cursor += line_len + 1; if (strlen (line) < 256) { double cur_percentage; ; if (sscanf (line, "udisks-helper-progress: %lg", &cur_percentage) == 1) { if (job->device != NULL && job->job_id != NULL) { job->device->priv->job_percentage = cur_percentage; emit_job_changed (job->device); } } } g_free (line); } while (TRUE); return TRUE; }
+Info
0
job_read_out (GIOChannel *channel, GIOCondition condition, gpointer user_data) { char *s; char *line; char buf[1024]; gsize bytes_read; Job *job = user_data; g_io_channel_read_chars (channel, buf, sizeof buf, &bytes_read, NULL); g_string_append_len (job->stdout_string, buf, bytes_read); do { gsize line_len; s = strstr (job->stdout_string->str + job->stdout_string_cursor, "\n"); if (s == NULL) break; line_len = s - (job->stdout_string->str + job->stdout_string_cursor); line = g_strndup (job->stdout_string->str + job->stdout_string_cursor, line_len); job->stdout_string_cursor += line_len + 1; if (strlen (line) < 256) { double cur_percentage; ; if (sscanf (line, "udisks-helper-progress: %lg", &cur_percentage) == 1) { if (job->device != NULL && job->job_id != NULL) { job->device->priv->job_percentage = cur_percentage; emit_job_changed (job->device); } } } g_free (line); } while (TRUE); return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,351
job_udevadm_settle_child_cb (GPid pid, gint status, gpointer user_data) { Job *job = user_data; job_complete (job); }
+Info
0
job_udevadm_settle_child_cb (GPid pid, gint status, gpointer user_data) { Job *job = user_data; job_complete (job); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,352
job_write_in (GIOChannel *channel, GIOCondition condition, gpointer user_data) { Job *job = user_data; gsize bytes_written; if (job->stdin_cursor == NULL || job->stdin_cursor[0] == '\0') { /* nothing left to write; remove ourselves */ return FALSE; } g_io_channel_write_chars (channel, job->stdin_cursor, strlen (job->stdin_cursor), &bytes_written, NULL); g_io_channel_flush (channel, NULL); job->stdin_cursor += bytes_written; return TRUE; }
+Info
0
job_write_in (GIOChannel *channel, GIOCondition condition, gpointer user_data) { Job *job = user_data; gsize bytes_written; if (job->stdin_cursor == NULL || job->stdin_cursor[0] == '\0') { /* nothing left to write; remove ourselves */ return FALSE; } g_io_channel_write_chars (channel, job->stdin_cursor, strlen (job->stdin_cursor), &bytes_written, NULL); g_io_channel_flush (channel, NULL); job->stdin_cursor += bytes_written; return TRUE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,353
linux_lvm2_lv_create_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { CreateLvm2LVData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { Device *d; d = lvm2_lv_create_has_lv (data); if (d != NULL) { /* yay! it is.. now create the file system if requested */ lvm2_lv_create_found_device (device, data); } else { /* otherwise sit around and wait for the new LV to appear */ data->device_added_signal_handler_id = g_signal_connect_after (data->daemon, "device-added", G_CALLBACK (lvm2_lv_create_device_added_cb), data); data->device_changed_signal_handler_id = g_signal_connect_after (data->daemon, "device-changed", G_CALLBACK (lvm2_lv_create_device_changed_cb), data); data->device_added_timeout_id = g_timeout_add (10 * 1000, lvm2_lv_create_device_not_seen_cb, data); lvm2_lv_create_data_ref (data); } } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error creating LVM2 Logical Volume: lvcreate exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_lvm2_lv_create_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { CreateLvm2LVData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { Device *d; d = lvm2_lv_create_has_lv (data); if (d != NULL) { /* yay! it is.. now create the file system if requested */ lvm2_lv_create_found_device (device, data); } else { /* otherwise sit around and wait for the new LV to appear */ data->device_added_signal_handler_id = g_signal_connect_after (data->daemon, "device-added", G_CALLBACK (lvm2_lv_create_device_added_cb), data); data->device_changed_signal_handler_id = g_signal_connect_after (data->daemon, "device-changed", G_CALLBACK (lvm2_lv_create_device_changed_cb), data); data->device_added_timeout_id = g_timeout_add (10 * 1000, lvm2_lv_create_device_not_seen_cb, data); lvm2_lv_create_data_ref (data); } } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error creating LVM2 Logical Volume: lvcreate exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,354
linux_lvm2_lv_remove_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error removing LVM2 Logical Volume: lvremove exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_lvm2_lv_remove_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error removing LVM2 Logical Volume: lvremove exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,355
linux_lvm2_lv_start_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error starting LVM2 Logical Volume: lvchange exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_lvm2_lv_start_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error starting LVM2 Logical Volume: lvchange exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,356
linux_lvm2_vg_remove_pv_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error removing PV for LVM2 Volume Group: vgreduce exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_lvm2_vg_remove_pv_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error removing PV for LVM2 Volume Group: vgreduce exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,357
linux_lvm2_vg_set_name_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error setting name for LVM2 Volume Group: vgrename exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_lvm2_vg_set_name_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error setting name for LVM2 Volume Group: vgrename exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,358
linux_lvm2_vg_start_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error starting LVM2 Volume Group: vgchange exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_lvm2_vg_start_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error starting LVM2 Volume Group: vgchange exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,359
linux_lvm2_vg_stop_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error stopping LVM2 Volume Group: vgchange exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_lvm2_vg_stop_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error stopping LVM2 Volume Group: vgchange exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,360
linux_md_add_spare_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { Device *slave = DEVICE (user_data); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* the slave got new metadata on it; reread that */ device_generate_kernel_change_event (slave); /* the kernel side of md currently doesn't emit a 'changed' event so * generate one since state may have changed (e.g. rebuild started etc.) */ device_generate_kernel_change_event (device); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error adding spare: mdadm exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_md_add_spare_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { Device *slave = DEVICE (user_data); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* the slave got new metadata on it; reread that */ device_generate_kernel_change_event (slave); /* the kernel side of md currently doesn't emit a 'changed' event so * generate one since state may have changed (e.g. rebuild started etc.) */ device_generate_kernel_change_event (device); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error adding spare: mdadm exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,361
linux_md_check_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { guint64 num_errors; num_errors = sysfs_get_uint64 (device->priv->native_path, "md/mismatch_cnt"); dbus_g_method_return (context, num_errors); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error checking array: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_md_check_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { guint64 num_errors; num_errors = sysfs_get_uint64 (device->priv->native_path, "md/mismatch_cnt"); dbus_g_method_return (context, num_errors); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error checking array: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,362
linux_md_create_data_new (DBusGMethodInvocation *context, Daemon *daemon, const char *first_component_objpath) { LinuxMdCreateData *data; data = g_new0 (LinuxMdCreateData, 1); data->refcount = 1; data->context = context; data->daemon = g_object_ref (daemon); data->first_component_objpath = g_strdup (first_component_objpath); return data; }
+Info
0
linux_md_create_data_new (DBusGMethodInvocation *context, Daemon *daemon, const char *first_component_objpath) { LinuxMdCreateData *data; data = g_new0 (LinuxMdCreateData, 1); data->refcount = 1; data->context = context; data->daemon = g_object_ref (daemon); data->first_component_objpath = g_strdup (first_component_objpath); return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,363
linux_md_create_data_ref (LinuxMdCreateData *data) { data->refcount++; return data; }
+Info
0
linux_md_create_data_ref (LinuxMdCreateData *data) { data->refcount++; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,364
linux_md_create_data_unref (LinuxMdCreateData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->daemon); g_free (data->first_component_objpath); g_free (data); } }
+Info
0
linux_md_create_data_unref (LinuxMdCreateData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->daemon); g_free (data->first_component_objpath); g_free (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,365
linux_md_create_device_not_seen_cb (gpointer user_data) { LinuxMdCreateData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error assembling array: timeout (10s) waiting for array to show up"); g_signal_handler_disconnect (data->daemon, data->device_added_signal_handler_id); linux_md_create_data_unref (data); return FALSE; }
+Info
0
linux_md_create_device_not_seen_cb (gpointer user_data) { LinuxMdCreateData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error assembling array: timeout (10s) waiting for array to show up"); g_signal_handler_disconnect (data->daemon, data->device_added_signal_handler_id); linux_md_create_data_unref (data); return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,366
linux_md_expand_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* the kernel side of md currently doesn't emit a 'changed' event so * generate one since state may have changed (e.g. rebuild started etc.) */ device_generate_kernel_change_event (device); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error expanding array: helper script exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_md_expand_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* the kernel side of md currently doesn't emit a 'changed' event so * generate one since state may have changed (e.g. rebuild started etc.) */ device_generate_kernel_change_event (device); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error expanding array: helper script exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,367
linux_md_remove_component_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { RemoveComponentData *data = user_data; /* the slave got new metadata on it; reread that */ device_generate_kernel_change_event (data->slave); /* the kernel side of md currently doesn't emit a 'changed' event so * generate one since state may have changed (e.g. rebuild started etc.) */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* wait for the slave to be busy, then start erasing it */ data->device_changed_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-changed", (GCallback) linux_md_remove_component_device_changed_cb, remove_component_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_changed_timeout_id = g_timeout_add (10 * 1000, linux_md_remove_component_device_not_seen_cb, data); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error removing component: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_md_remove_component_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { RemoveComponentData *data = user_data; /* the slave got new metadata on it; reread that */ device_generate_kernel_change_event (data->slave); /* the kernel side of md currently doesn't emit a 'changed' event so * generate one since state may have changed (e.g. rebuild started etc.) */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* wait for the slave to be busy, then start erasing it */ data->device_changed_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-changed", (GCallback) linux_md_remove_component_device_changed_cb, remove_component_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_changed_timeout_id = g_timeout_add (10 * 1000, linux_md_remove_component_device_not_seen_cb, data); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error removing component: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,368
linux_md_remove_component_device_changed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { RemoveComponentData *data = user_data; Device *device; GError *error; error = NULL; device = daemon_local_find_by_object_path (daemon, object_path); if (device == data->slave) { if (device_local_is_busy (data->slave, FALSE, &error)) { dbus_g_method_return_error (data->context, error); g_error_free (error); } else { gchar *fs_create_options[] = { NULL }; /* yay! now scrub it! */ device_filesystem_create (data->slave, "empty", fs_create_options, data->context); /* TODO: leaking data? */ g_signal_handler_disconnect (daemon, data->device_changed_signal_handler_id); g_source_remove (data->device_changed_timeout_id); } } }
+Info
0
linux_md_remove_component_device_changed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { RemoveComponentData *data = user_data; Device *device; GError *error; error = NULL; device = daemon_local_find_by_object_path (daemon, object_path); if (device == data->slave) { if (device_local_is_busy (data->slave, FALSE, &error)) { dbus_g_method_return_error (data->context, error); g_error_free (error); } else { gchar *fs_create_options[] = { NULL }; /* yay! now scrub it! */ device_filesystem_create (data->slave, "empty", fs_create_options, data->context); /* TODO: leaking data? */ g_signal_handler_disconnect (daemon, data->device_changed_signal_handler_id); g_source_remove (data->device_changed_timeout_id); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,369
linux_md_remove_component_device_not_seen_cb (gpointer user_data) { RemoveComponentData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error removing component: timeout (10s) waiting for slave to stop being busy"); g_signal_handler_disconnect (data->slave->priv->daemon, data->device_changed_signal_handler_id); remove_component_data_unref (data); return FALSE; }
+Info
0
linux_md_remove_component_device_not_seen_cb (gpointer user_data) { RemoveComponentData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error removing component: timeout (10s) waiting for slave to stop being busy"); g_signal_handler_disconnect (data->slave->priv->daemon, data->device_changed_signal_handler_id); remove_component_data_unref (data); return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,370
linux_md_start_data_new (DBusGMethodInvocation *context, Daemon *daemon, const char *uuid) { LinuxMdStartData *data; data = g_new0 (LinuxMdStartData, 1); data->refcount = 1; data->context = context; data->daemon = g_object_ref (daemon); data->uuid = g_strdup (uuid); return data; }
+Info
0
linux_md_start_data_new (DBusGMethodInvocation *context, Daemon *daemon, const char *uuid) { LinuxMdStartData *data; data = g_new0 (LinuxMdStartData, 1); data->refcount = 1; data->context = context; data->daemon = g_object_ref (daemon); data->uuid = g_strdup (uuid); return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,371
linux_md_start_data_ref (LinuxMdStartData *data) { data->refcount++; return data; }
+Info
0
linux_md_start_data_ref (LinuxMdStartData *data) { data->refcount++; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,372
linux_md_start_data_unref (LinuxMdStartData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->daemon); g_free (data->uuid); g_free (data); } }
+Info
0
linux_md_start_data_unref (LinuxMdStartData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->daemon); g_free (data->uuid); g_free (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,373
linux_md_start_device_added_cb (Daemon *daemon, const char *object_path, gpointer user_data) { LinuxMdStartData *data = user_data; Device *device; /* check the device is the one we're looking for */ device = daemon_local_find_by_object_path (daemon, object_path); if (device != NULL && device->priv->device_is_linux_md) { /* TODO: actually check this properly by looking at slaves vs. components */ /* yay! it is.. return value to the user */ dbus_g_method_return (data->context, object_path); g_signal_handler_disconnect (daemon, data->device_added_signal_handler_id); g_source_remove (data->device_added_timeout_id); linux_md_start_data_unref (data); } }
+Info
0
linux_md_start_device_added_cb (Daemon *daemon, const char *object_path, gpointer user_data) { LinuxMdStartData *data = user_data; Device *device; /* check the device is the one we're looking for */ device = daemon_local_find_by_object_path (daemon, object_path); if (device != NULL && device->priv->device_is_linux_md) { /* TODO: actually check this properly by looking at slaves vs. components */ /* yay! it is.. return value to the user */ dbus_g_method_return (data->context, object_path); g_signal_handler_disconnect (daemon, data->device_added_signal_handler_id); g_source_remove (data->device_added_timeout_id); linux_md_start_data_unref (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,374
linux_md_stop_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* the kernel side of md currently doesn't emit a 'changed' event so * generate one such that the md device can disappear from our * database */ device_generate_kernel_change_event (device); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error stopping array: mdadm exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
linux_md_stop_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* the kernel side of md currently doesn't emit a 'changed' event so * generate one such that the md device can disappear from our * database */ device_generate_kernel_change_event (device); dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error stopping array: mdadm exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,375
lock_encryption_data_new (DBusGMethodInvocation *context, Device *luks_device, Device *cleartext_device) { LockEncryptionData *data; data = g_new0 (LockEncryptionData, 1); data->refcount = 1; data->context = context; data->luks_device = g_object_ref (luks_device); data->cleartext_device = g_object_ref (cleartext_device); return data; }
+Info
0
lock_encryption_data_new (DBusGMethodInvocation *context, Device *luks_device, Device *cleartext_device) { LockEncryptionData *data; data = g_new0 (LockEncryptionData, 1); data->refcount = 1; data->context = context; data->luks_device = g_object_ref (luks_device); data->cleartext_device = g_object_ref (cleartext_device); return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,376
lock_encryption_data_ref (LockEncryptionData *data) { data->refcount++; return data; }
+Info
0
lock_encryption_data_ref (LockEncryptionData *data) { data->refcount++; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,377
lock_encryption_data_unref (LockEncryptionData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->luks_device); g_object_unref (data->cleartext_device); g_free (data); } }
+Info
0
lock_encryption_data_unref (LockEncryptionData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->luks_device); g_object_unref (data->cleartext_device); g_free (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,378
lsof_parse (const char *stdout, GPtrArray *processes) { int n; char **tokens; tokens = g_strsplit (stdout, "\n", 0); for (n = 0; tokens[n] != NULL; n++) { pid_t pid; uid_t uid; char *command_line; GValue elem = { 0 }; if (strlen (tokens[n]) == 0) continue; pid = strtol (tokens[n], NULL, 0); uid = get_uid_for_pid (pid); command_line = get_command_line_for_pid (pid); g_value_init (&elem, LSOF_DATA_STRUCT_TYPE); g_value_take_boxed (&elem, dbus_g_type_specialized_construct (LSOF_DATA_STRUCT_TYPE)); dbus_g_type_struct_set (&elem, 0, pid, 1, uid, 2, command_line != NULL ? command_line : "", G_MAXUINT); g_ptr_array_add (processes, g_value_get_boxed (&elem)); g_free (command_line); } g_strfreev (tokens); }
+Info
0
lsof_parse (const char *stdout, GPtrArray *processes) { int n; char **tokens; tokens = g_strsplit (stdout, "\n", 0); for (n = 0; tokens[n] != NULL; n++) { pid_t pid; uid_t uid; char *command_line; GValue elem = { 0 }; if (strlen (tokens[n]) == 0) continue; pid = strtol (tokens[n], NULL, 0); uid = get_uid_for_pid (pid); command_line = get_command_line_for_pid (pid); g_value_init (&elem, LSOF_DATA_STRUCT_TYPE); g_value_take_boxed (&elem, dbus_g_type_specialized_construct (LSOF_DATA_STRUCT_TYPE)); dbus_g_type_struct_set (&elem, 0, pid, 1, uid, 2, command_line != NULL ? command_line : "", G_MAXUINT); g_ptr_array_add (processes, g_value_get_boxed (&elem)); g_free (command_line); } g_strfreev (tokens); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,379
luks_change_passphrase_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else if (WEXITSTATUS (status) == 3) { throw_error (context, ERROR_FILESYSTEM_TOOLS_MISSING, "Error changing fs label: tool not available: %s", stderr); } else { throw_error (context, ERROR_FAILED, "Error changing secret on device: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
luks_change_passphrase_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { dbus_g_method_return (context); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else if (WEXITSTATUS (status) == 3) { throw_error (context, ERROR_FILESYSTEM_TOOLS_MISSING, "Error changing fs label: tool not available: %s", stderr); } else { throw_error (context, ERROR_FAILED, "Error changing secret on device: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,380
luks_get_uid_from_dm_name (const char *dm_name, uid_t *out_uid) { int n; gboolean ret; uid_t uid; char *endp; ret = FALSE; if (!g_str_has_prefix (dm_name, "udisks-luks-uuid")) goto out; /* determine who unlocked the device */ for (n = strlen (dm_name) - 1; n >= 0; n--) { if (dm_name[n] == '-') break; } if (strncmp (dm_name + n, "-uid", 4) != 0) goto out; uid = strtol (dm_name + n + 4, &endp, 10); if (endp == NULL || *endp != '\0') goto out; if (out_uid != NULL) *out_uid = uid; ret = TRUE; out: return ret; }
+Info
0
luks_get_uid_from_dm_name (const char *dm_name, uid_t *out_uid) { int n; gboolean ret; uid_t uid; char *endp; ret = FALSE; if (!g_str_has_prefix (dm_name, "udisks-luks-uuid")) goto out; /* determine who unlocked the device */ for (n = strlen (dm_name) - 1; n >= 0; n--) { if (dm_name[n] == '-') break; } if (strncmp (dm_name + n, "-uid", 4) != 0) goto out; uid = strtol (dm_name + n + 4, &endp, 10); if (endp == NULL || *endp != '\0') goto out; if (out_uid != NULL) *out_uid = uid; ret = TRUE; out: return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,381
luks_lock_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { LockEncryptionData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* if device is already removed, just return */ if (data->cleartext_device->priv->removed) { /* update and emit a Changed() signal on the holder since the luks-holder * property indicates the cleartext device */ update_info (data->luks_device); drain_pending_changes (data->luks_device, FALSE); dbus_g_method_return (context); } else { /* otherwise sit and wait for the device to disappear */ data->device_removed_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-removed", (GCallback) luks_lock_wait_for_cleartext_device_removed_cb, lock_encryption_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_removed_timeout_id = g_timeout_add (10 * 1000, luks_lock_wait_for_cleartext_device_not_seen_cb, data); job_local_start (device, "LuksLock"); } } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error locking device: cryptsetup exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
luks_lock_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { LockEncryptionData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { /* if device is already removed, just return */ if (data->cleartext_device->priv->removed) { /* update and emit a Changed() signal on the holder since the luks-holder * property indicates the cleartext device */ update_info (data->luks_device); drain_pending_changes (data->luks_device, FALSE); dbus_g_method_return (context); } else { /* otherwise sit and wait for the device to disappear */ data->device_removed_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-removed", (GCallback) luks_lock_wait_for_cleartext_device_removed_cb, lock_encryption_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_removed_timeout_id = g_timeout_add (10 * 1000, luks_lock_wait_for_cleartext_device_not_seen_cb, data); job_local_start (device, "LuksLock"); } } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error locking device: cryptsetup exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,382
luks_lock_wait_for_cleartext_device_not_seen_cb (gpointer user_data) { LockEncryptionData *data = user_data; job_local_end (data->luks_device); throw_error (data->context, ERROR_FAILED, "Error locking luks device: timeout (10s) waiting for cleartext device to be removed"); g_signal_handler_disconnect (data->cleartext_device->priv->daemon, data->device_removed_signal_handler_id); lock_encryption_data_unref (data); return FALSE; }
+Info
0
luks_lock_wait_for_cleartext_device_not_seen_cb (gpointer user_data) { LockEncryptionData *data = user_data; job_local_end (data->luks_device); throw_error (data->context, ERROR_FAILED, "Error locking luks device: timeout (10s) waiting for cleartext device to be removed"); g_signal_handler_disconnect (data->cleartext_device->priv->daemon, data->device_removed_signal_handler_id); lock_encryption_data_unref (data); return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,383
luks_lock_wait_for_cleartext_device_removed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { Device *device; LockEncryptionData *data = user_data; device = daemon_local_find_by_object_path (daemon, object_path); if (device == data->cleartext_device) { job_local_end (data->luks_device); /* update and emit a Changed() signal on the holder since the luks-holder * property indicates the cleartext device */ update_info (data->luks_device); drain_pending_changes (data->luks_device, FALSE); dbus_g_method_return (data->context); g_signal_handler_disconnect (daemon, data->device_removed_signal_handler_id); g_source_remove (data->device_removed_timeout_id); lock_encryption_data_unref (data); } }
+Info
0
luks_lock_wait_for_cleartext_device_removed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { Device *device; LockEncryptionData *data = user_data; device = daemon_local_find_by_object_path (daemon, object_path); if (device == data->cleartext_device) { job_local_end (data->luks_device); /* update and emit a Changed() signal on the holder since the luks-holder * property indicates the cleartext device */ update_info (data->luks_device); drain_pending_changes (data->luks_device, FALSE); dbus_g_method_return (data->context); g_signal_handler_disconnect (daemon, data->device_removed_signal_handler_id); g_source_remove (data->device_removed_timeout_id); lock_encryption_data_unref (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,384
luks_unlock_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { UnlockEncryptionData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { luks_unlock_start_waiting_for_cleartext_device (unlock_encryption_data_ref (data)); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error unlocking device: cryptsetup exited with exit code %d: %s", WEXITSTATUS (status), stderr); } if (data->hook_func != NULL) { data->hook_func (data->context, NULL, data->hook_user_data); } } }
+Info
0
luks_unlock_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { UnlockEncryptionData *data = user_data; if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { luks_unlock_start_waiting_for_cleartext_device (unlock_encryption_data_ref (data)); } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error unlocking device: cryptsetup exited with exit code %d: %s", WEXITSTATUS (status), stderr); } if (data->hook_func != NULL) { data->hook_func (data->context, NULL, data->hook_user_data); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,385
luks_unlock_device_not_seen_cb (gpointer user_data) { UnlockEncryptionData *data = user_data; g_signal_handler_disconnect (data->device->priv->daemon, data->device_added_signal_handler_id); g_signal_handler_disconnect (data->device->priv->daemon, data->device_changed_signal_handler_id); throw_error (data->context, ERROR_FAILED, "Error unlocking device: timeout (10s) waiting for cleartext device to show up"); if (data->hook_func != NULL) { data->hook_func (data->context, NULL, data->hook_user_data); } unlock_encryption_data_unref (data); return FALSE; }
+Info
0
luks_unlock_device_not_seen_cb (gpointer user_data) { UnlockEncryptionData *data = user_data; g_signal_handler_disconnect (data->device->priv->daemon, data->device_added_signal_handler_id); g_signal_handler_disconnect (data->device->priv->daemon, data->device_changed_signal_handler_id); throw_error (data->context, ERROR_FAILED, "Error unlocking device: timeout (10s) waiting for cleartext device to show up"); if (data->hook_func != NULL) { data->hook_func (data->context, NULL, data->hook_user_data); } unlock_encryption_data_unref (data); return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,386
luks_unlock_start_waiting_for_cleartext_device (UnlockEncryptionData *data) { Device *cleartext_device; cleartext_device = find_cleartext_device (data->device); if (cleartext_device != NULL) { /* update and emit a Changed() signal on the holder since the luks-holder * property indicates the cleartext device */ update_info (data->device); drain_pending_changes (data->device, FALSE); if (data->hook_func != NULL) { data->hook_func (data->context, cleartext_device, data->hook_user_data); } else { dbus_g_method_return (data->context, cleartext_device->priv->object_path); } unlock_encryption_data_unref (data); } else { /* sit around wait for the cleartext device to appear */ data->device_added_signal_handler_id = g_signal_connect_after (data->device->priv->daemon, "device-added", (GCallback) luks_unlock_device_added_cb, data); data->device_changed_signal_handler_id = g_signal_connect_after (data->device->priv->daemon, "device-changed", (GCallback) luks_unlock_device_added_cb, data); /* set up timeout for error reporting if waiting failed */ data->device_added_timeout_id = g_timeout_add (15 * 1000, luks_unlock_device_not_seen_cb, data); /* Note that the signal and timeout handlers share the ref to data - one will cancel the other */ } }
+Info
0
luks_unlock_start_waiting_for_cleartext_device (UnlockEncryptionData *data) { Device *cleartext_device; cleartext_device = find_cleartext_device (data->device); if (cleartext_device != NULL) { /* update and emit a Changed() signal on the holder since the luks-holder * property indicates the cleartext device */ update_info (data->device); drain_pending_changes (data->device, FALSE); if (data->hook_func != NULL) { data->hook_func (data->context, cleartext_device, data->hook_user_data); } else { dbus_g_method_return (data->context, cleartext_device->priv->object_path); } unlock_encryption_data_unref (data); } else { /* sit around wait for the cleartext device to appear */ data->device_added_signal_handler_id = g_signal_connect_after (data->device->priv->daemon, "device-added", (GCallback) luks_unlock_device_added_cb, data); data->device_changed_signal_handler_id = g_signal_connect_after (data->device->priv->daemon, "device-changed", (GCallback) luks_unlock_device_added_cb, data); /* set up timeout for error reporting if waiting failed */ data->device_added_timeout_id = g_timeout_add (15 * 1000, luks_unlock_device_not_seen_cb, data); /* Note that the signal and timeout handlers share the ref to data - one will cancel the other */ } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,387
lvm2_lv_create_data_new (DBusGMethodInvocation *context, Daemon *daemon, const gchar *vg_uuid, const gchar *lv_name, const char *fstype, char **fsoptions) { CreateLvm2LVData *data; data = g_new0 (CreateLvm2LVData, 1); data->refcount = 1; data->context = context; data->daemon = g_object_ref (daemon); data->vg_uuid = g_strdup (vg_uuid); data->lv_name = g_strdup (lv_name); data->fstype = g_strdup (fstype); data->fsoptions = g_strdupv (fsoptions); return data; }
+Info
0
lvm2_lv_create_data_new (DBusGMethodInvocation *context, Daemon *daemon, const gchar *vg_uuid, const gchar *lv_name, const char *fstype, char **fsoptions) { CreateLvm2LVData *data; data = g_new0 (CreateLvm2LVData, 1); data->refcount = 1; data->context = context; data->daemon = g_object_ref (daemon); data->vg_uuid = g_strdup (vg_uuid); data->lv_name = g_strdup (lv_name); data->fstype = g_strdup (fstype); data->fsoptions = g_strdupv (fsoptions); return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,388
lvm2_lv_create_data_ref (CreateLvm2LVData *data) { data->refcount++; return data; }
+Info
0
lvm2_lv_create_data_ref (CreateLvm2LVData *data) { data->refcount++; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,389
lvm2_lv_create_device_changed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { CreateLvm2LVData *data = user_data; Device *device; g_debug ("changed %s", object_path); device = lvm2_lv_create_has_lv (data); if (device != NULL) { /* yay! it is.. now create the file system if requested */ lvm2_lv_create_found_device (device, data); g_signal_handler_disconnect (daemon, data->device_added_signal_handler_id); g_signal_handler_disconnect (daemon, data->device_changed_signal_handler_id); g_source_remove (data->device_added_timeout_id); lvm2_lv_create_data_unref (data); } }
+Info
0
lvm2_lv_create_device_changed_cb (Daemon *daemon, const char *object_path, gpointer user_data) { CreateLvm2LVData *data = user_data; Device *device; g_debug ("changed %s", object_path); device = lvm2_lv_create_has_lv (data); if (device != NULL) { /* yay! it is.. now create the file system if requested */ lvm2_lv_create_found_device (device, data); g_signal_handler_disconnect (daemon, data->device_added_signal_handler_id); g_signal_handler_disconnect (daemon, data->device_changed_signal_handler_id); g_source_remove (data->device_added_timeout_id); lvm2_lv_create_data_unref (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,390
lvm2_lv_create_device_not_seen_cb (gpointer user_data) { CreateLvm2LVData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error creating Logical Volume: timeout (10s) waiting for LV to show up"); g_signal_handler_disconnect (data->daemon, data->device_added_signal_handler_id); g_signal_handler_disconnect (data->daemon, data->device_changed_signal_handler_id); lvm2_lv_create_data_unref (data); return FALSE; }
+Info
0
lvm2_lv_create_device_not_seen_cb (gpointer user_data) { CreateLvm2LVData *data = user_data; throw_error (data->context, ERROR_FAILED, "Error creating Logical Volume: timeout (10s) waiting for LV to show up"); g_signal_handler_disconnect (data->daemon, data->device_added_signal_handler_id); g_signal_handler_disconnect (data->daemon, data->device_changed_signal_handler_id); lvm2_lv_create_data_unref (data); return FALSE; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,391
lvm2_lv_create_filesystem_create_hook (DBusGMethodInvocation *context, Device *device, gboolean filesystem_create_succeeded, gpointer user_data) { if (!filesystem_create_succeeded) { /* dang.. FilesystemCreate already reported an error */ } else { /* it worked.. */ dbus_g_method_return (context, device->priv->object_path); } }
+Info
0
lvm2_lv_create_filesystem_create_hook (DBusGMethodInvocation *context, Device *device, gboolean filesystem_create_succeeded, gpointer user_data) { if (!filesystem_create_succeeded) { /* dang.. FilesystemCreate already reported an error */ } else { /* it worked.. */ dbus_g_method_return (context, device->priv->object_path); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,392
lvm2_lv_create_has_lv (CreateLvm2LVData *data) { GList *devices; Device *ret; GList *l; ret = NULL; devices = daemon_local_get_all_devices (data->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_linux_lvm2_lv && g_strcmp0 (d->priv->linux_lvm2_lv_group_uuid, data->vg_uuid) == 0 && g_strcmp0 (d->priv->linux_lvm2_lv_name, data->lv_name) == 0) { GList *m; const gchar *lv_uuid; lv_uuid = d->priv->linux_lvm2_lv_uuid; /* OK, we've found the LV... now check that one of more PVs actually reference this LV */ for (m = devices; m != NULL; m = m->next) { Device *pv = DEVICE (m->data); if (pv->priv->device_is_linux_lvm2_pv && g_strcmp0 (pv->priv->linux_lvm2_pv_group_uuid, data->vg_uuid) == 0) { guint n; for (n = 0; n < pv->priv->linux_lvm2_pv_group_logical_volumes->len; n++) { const gchar *str = pv->priv->linux_lvm2_pv_group_logical_volumes->pdata[n]; if (str_has_lv_uuid (str, lv_uuid)) { /* Return the LV, not the PV */ ret = d; break; } } } } /* for all PVs */ break; } /* if (found LV) */ } return ret; }
+Info
0
lvm2_lv_create_has_lv (CreateLvm2LVData *data) { GList *devices; Device *ret; GList *l; ret = NULL; devices = daemon_local_get_all_devices (data->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_linux_lvm2_lv && g_strcmp0 (d->priv->linux_lvm2_lv_group_uuid, data->vg_uuid) == 0 && g_strcmp0 (d->priv->linux_lvm2_lv_name, data->lv_name) == 0) { GList *m; const gchar *lv_uuid; lv_uuid = d->priv->linux_lvm2_lv_uuid; /* OK, we've found the LV... now check that one of more PVs actually reference this LV */ for (m = devices; m != NULL; m = m->next) { Device *pv = DEVICE (m->data); if (pv->priv->device_is_linux_lvm2_pv && g_strcmp0 (pv->priv->linux_lvm2_pv_group_uuid, data->vg_uuid) == 0) { guint n; for (n = 0; n < pv->priv->linux_lvm2_pv_group_logical_volumes->len; n++) { const gchar *str = pv->priv->linux_lvm2_pv_group_logical_volumes->pdata[n]; if (str_has_lv_uuid (str, lv_uuid)) { /* Return the LV, not the PV */ ret = d; break; } } } } /* for all PVs */ break; } /* if (found LV) */ } return ret; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,393
mkfs_data_unref (MkfsData *data) { g_free (data); }
+Info
0
mkfs_data_unref (MkfsData *data) { g_free (data); }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,394
mkfse_data_ref (MkfsLuksData *data) { data->refcount++; return data; }
+Info
0
mkfse_data_ref (MkfsLuksData *data) { data->refcount++; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,395
mkfse_data_unref (MkfsLuksData *data) { data->refcount--; if (data->refcount == 0) { if (data->passphrase != NULL) { memset (data->passphrase, '\0', strlen (data->passphrase)); g_free (data->passphrase); } if (data->device != NULL) g_object_unref (data->device); g_strfreev (data->options); g_free (data->fstype); g_free (data); } }
+Info
0
mkfse_data_unref (MkfsLuksData *data) { data->refcount--; if (data->refcount == 0) { if (data->passphrase != NULL) { memset (data->passphrase, '\0', strlen (data->passphrase)); g_free (data->passphrase); } if (data->device != NULL) g_object_unref (data->device); g_strfreev (data->options); g_free (data->fstype); g_free (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,396
partition_create_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { CreatePartitionData *data = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { int n; int m; guint64 offset; guint64 size; char **tokens; /* Find the * * job-create-partition-offset: * job-create-partition-size: * * lines and parse the new start and end. We need this * for waiting on the created partition (since the requested * start and size passed may not be honored due to disk/cylinder/sector * alignment reasons). */ offset = 0; size = 0; m = 0; tokens = g_strsplit (stderr, "\n", 0); for (n = 0; tokens[n] != NULL; n++) { char *line = tokens[n]; char *endp; if (m == 2) break; if (g_str_has_prefix (line, "job-create-partition-offset: ")) { offset = strtoll (line + sizeof("job-create-partition-offset: ") - 1, &endp, 10); if (*endp == '\0') m++; } else if (g_str_has_prefix (line, "job-create-partition-size: ")) { size = strtoll (line + sizeof("job-create-partition-size: ") - 1, &endp, 10); if (*endp == '\0') m++; } } g_strfreev (tokens); if (m != 2) { throw_error (context, ERROR_FAILED, "Error creating partition: internal error, expected to find new " "start and end but m=%d", m); } else { gboolean found_device; GList *devices; GList *l; data->created_offset = offset; data->created_size = size; /* check if the device is already there */ found_device = FALSE; devices = daemon_local_get_all_devices (device->priv->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_partition && strcmp (d->priv->partition_slave, data->device->priv->object_path) == 0 && data->created_offset == d->priv->partition_offset && data->created_size == d->priv->partition_size) { /* yay! it is.. now create the file system if requested */ partition_create_found_device (d, data); found_device = TRUE; break; } } if (!found_device) { /* otherwise sit around and wait for the new partition to appear */ data->device_added_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-added", (GCallback) partition_create_device_added_cb, partition_create_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_added_timeout_id = g_timeout_add (10 * 1000, partition_create_device_not_seen_cb, data); } } } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error creating partition: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
+Info
0
partition_create_completed_cb (DBusGMethodInvocation *context, Device *device, gboolean job_was_cancelled, int status, const char *stderr, const char *stdout, gpointer user_data) { CreatePartitionData *data = user_data; /* poke the kernel so we can reread the data */ device_generate_kernel_change_event (device); if (WEXITSTATUS (status) == 0 && !job_was_cancelled) { int n; int m; guint64 offset; guint64 size; char **tokens; /* Find the * * job-create-partition-offset: * job-create-partition-size: * * lines and parse the new start and end. We need this * for waiting on the created partition (since the requested * start and size passed may not be honored due to disk/cylinder/sector * alignment reasons). */ offset = 0; size = 0; m = 0; tokens = g_strsplit (stderr, "\n", 0); for (n = 0; tokens[n] != NULL; n++) { char *line = tokens[n]; char *endp; if (m == 2) break; if (g_str_has_prefix (line, "job-create-partition-offset: ")) { offset = strtoll (line + sizeof("job-create-partition-offset: ") - 1, &endp, 10); if (*endp == '\0') m++; } else if (g_str_has_prefix (line, "job-create-partition-size: ")) { size = strtoll (line + sizeof("job-create-partition-size: ") - 1, &endp, 10); if (*endp == '\0') m++; } } g_strfreev (tokens); if (m != 2) { throw_error (context, ERROR_FAILED, "Error creating partition: internal error, expected to find new " "start and end but m=%d", m); } else { gboolean found_device; GList *devices; GList *l; data->created_offset = offset; data->created_size = size; /* check if the device is already there */ found_device = FALSE; devices = daemon_local_get_all_devices (device->priv->daemon); for (l = devices; l != NULL; l = l->next) { Device *d = DEVICE (l->data); if (d->priv->device_is_partition && strcmp (d->priv->partition_slave, data->device->priv->object_path) == 0 && data->created_offset == d->priv->partition_offset && data->created_size == d->priv->partition_size) { /* yay! it is.. now create the file system if requested */ partition_create_found_device (d, data); found_device = TRUE; break; } } if (!found_device) { /* otherwise sit around and wait for the new partition to appear */ data->device_added_signal_handler_id = g_signal_connect_after (device->priv->daemon, "device-added", (GCallback) partition_create_device_added_cb, partition_create_data_ref (data)); /* set up timeout for error reporting if waiting failed * * (the signal handler and the timeout handler share the ref to data * as one will cancel the other) */ data->device_added_timeout_id = g_timeout_add (10 * 1000, partition_create_device_not_seen_cb, data); } } } else { if (job_was_cancelled) { throw_error (context, ERROR_CANCELLED, "Job was cancelled"); } else { throw_error (context, ERROR_FAILED, "Error creating partition: helper exited with exit code %d: %s", WEXITSTATUS (status), stderr); } } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,397
partition_create_data_new (DBusGMethodInvocation *context, Device *device, guint64 offset, guint64 size, const char *fstype, char **fsoptions) { CreatePartitionData *data; data = g_new0 (CreatePartitionData, 1); data->refcount = 1; data->context = context; data->device = g_object_ref (device); data->offset = offset; data->size = size; data->fstype = g_strdup (fstype); data->fsoptions = g_strdupv (fsoptions); return data; }
+Info
0
partition_create_data_new (DBusGMethodInvocation *context, Device *device, guint64 offset, guint64 size, const char *fstype, char **fsoptions) { CreatePartitionData *data; data = g_new0 (CreatePartitionData, 1); data->refcount = 1; data->context = context; data->device = g_object_ref (device); data->offset = offset; data->size = size; data->fstype = g_strdup (fstype); data->fsoptions = g_strdupv (fsoptions); return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,398
partition_create_data_ref (CreatePartitionData *data) { data->refcount++; return data; }
+Info
0
partition_create_data_ref (CreatePartitionData *data) { data->refcount++; return data; }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null
9,399
partition_create_data_unref (CreatePartitionData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->device); g_free (data->fstype); g_strfreev (data->fsoptions); g_free (data); } }
+Info
0
partition_create_data_unref (CreatePartitionData *data) { data->refcount--; if (data->refcount == 0) { g_object_unref (data->device); g_free (data->fstype); g_strfreev (data->fsoptions); g_free (data); } }
@@ -3336,6 +3336,8 @@ update_info_partition_on_linux_dmmp (Device *device) goto out; targets_type = g_udev_device_get_property_as_strv (device->priv->d, "UDISKS_DM_TARGETS_TYPE"); + /* If we ever need this for other types than "linear", remember to update + udisks-dm-export.c as well. */ if (targets_type == NULL || g_strcmp0 (targets_type[0], "linear") != 0) goto out;
CWE-200
null
null