Codebase list fwupd / 3d9f2f1
Fix the DeviceID set by GetDetails The returned ID is the result of the SHA1 hash of the actual device ID. This does not match anything found by the client, and so the install fails. Richard Hughes 3 years ago
1 changed file(s) with 26 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
11791179 fwupd_device_set_name (FWUPD_DEVICE (self), new->str);
11801180 }
11811181
1182 static gboolean
1183 fu_device_id_is_valid (const gchar *device_id)
1184 {
1185 if (device_id == NULL)
1186 return FALSE;
1187 if (strlen (device_id) != 40)
1188 return FALSE;
1189 for (guint i = 0; device_id[i] != '\0'; i++) {
1190 gchar tmp = device_id[i];
1191 /* isalnum isn't case specific */
1192 if ((tmp < 'a' || tmp > 'f') && (tmp < '0' || tmp > '9'))
1193 return FALSE;
1194 }
1195 return TRUE;
1196 }
1197
11821198 /**
11831199 * fu_device_set_id:
11841200 * @self: A #FuDevice
11881204 * device, so that any similar device plugged into a different slot will
11891205 * have a different @id string.
11901206 *
1191 * The @id will be converted to a SHA1 hash before the device is added to the
1192 * daemon, and plugins should not assume that the ID that is set here is the
1193 * same as what is returned by fu_device_get_id().
1207 * The @id will be converted to a SHA1 hash if required before the device is
1208 * added to the daemon, and plugins should not assume that the ID that is set
1209 * here is the same as what is returned by fu_device_get_id().
11941210 *
11951211 * Since: 0.7.1
11961212 **/
12031219 g_return_if_fail (FU_IS_DEVICE (self));
12041220 g_return_if_fail (id != NULL);
12051221
1206 id_hash = g_compute_checksum_for_string (G_CHECKSUM_SHA1, id, -1);
1207 g_debug ("using %s for %s", id_hash, id);
1222 /* allow sane device-id to be set directly */
1223 if (fu_device_id_is_valid (id)) {
1224 id_hash = g_strdup (id);
1225 } else {
1226 id_hash = g_compute_checksum_for_string (G_CHECKSUM_SHA1, id, -1);
1227 g_debug ("using %s for %s", id_hash, id);
1228 }
12081229 fwupd_device_set_id (FWUPD_DEVICE (self), id_hash);
12091230
12101231 /* ensure the parent ID is set */