| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (C) 2009 Red Hat <mjg@redhat.com> | ||
| 3 | * Copyright (C) 2008 Bastien Nocera <hadess@hadess.net> | ||
| 4 | * Copyright (C) 2008 Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net> | ||
| 5 | * Copyright (C) 2019 Benjamin Berg <bberg@redhat.com> | ||
| 6 | * | ||
| 7 | * This library is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This library is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with this library; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <config.h> | ||
| 23 | |||
| 24 | #include "fpi-context.h" | ||
| 25 | #include "fpi-device.h" | ||
| 26 | |||
| 27 | static const FpIdEntry allowlist_id_table[] = { | ||
| 28 | /* Currently known and unsupported devices. | ||
| 29 | * You can generate this list from the wiki page using e.g.: | ||
| 30 | * gio cat https://gitlab.freedesktop.org/libfprint/wiki/-/wikis/Unsupported-Devices.md | sed -n 's!|.*\([0-9a-fA-F]\{4\}\):\([0-9a-fA-F]\{4\}\).*|.*! { .vid = 0x\1, .pid = 0x\2 },!p' | ||
| 31 | */ | ||
| 32 | { .vid = 0x0a5c, .pid = 0x5802 }, | ||
| 33 | { .vid = 0x047d, .pid = 0x00f2 }, | ||
| 34 | { .vid = 0x047d, .pid = 0x8054 }, | ||
| 35 | { .vid = 0x047d, .pid = 0x8055 }, | ||
| 36 | { .vid = 0x04e8, .pid = 0x730b }, | ||
| 37 | { .vid = 0x04f3, .pid = 0x036b }, | ||
| 38 | { .vid = 0x04f3, .pid = 0x0c00 }, | ||
| 39 | { .vid = 0x04f3, .pid = 0x0c4c }, | ||
| 40 | { .vid = 0x04f3, .pid = 0x0c57 }, | ||
| 41 | { .vid = 0x04f3, .pid = 0x0c5e }, | ||
| 42 | { .vid = 0x04f3, .pid = 0x0c5a }, | ||
| 43 | { .vid = 0x04f3, .pid = 0x0c60 }, | ||
| 44 | { .vid = 0x04f3, .pid = 0x0c6c }, | ||
| 45 | { .vid = 0x04f3, .pid = 0x0c70 }, | ||
| 46 | { .vid = 0x04f3, .pid = 0x0c72 }, | ||
| 47 | { .vid = 0x04f3, .pid = 0x0c77 }, | ||
| 48 | { .vid = 0x04f3, .pid = 0x0c7c }, | ||
| 49 | { .vid = 0x04f3, .pid = 0x0c7f }, | ||
| 50 | { .vid = 0x04f3, .pid = 0x0c80 }, | ||
| 51 | { .vid = 0x04f3, .pid = 0x0c85 }, | ||
| 52 | { .vid = 0x04f3, .pid = 0x0c90 }, | ||
| 53 | { .vid = 0x04f3, .pid = 0x2706 }, | ||
| 54 | { .vid = 0x04f3, .pid = 0x3032 }, | ||
| 55 | { .vid = 0x04f3, .pid = 0x3057 }, | ||
| 56 | { .vid = 0x04f3, .pid = 0x3104 }, | ||
| 57 | { .vid = 0x04f3, .pid = 0x310d }, | ||
| 58 | { .vid = 0x04f3, .pid = 0x3128 }, | ||
| 59 | { .vid = 0x04f3, .pid = 0x0c8a }, | ||
| 60 | { .vid = 0x05ba, .pid = 0x000e }, | ||
| 61 | { .vid = 0x06cb, .pid = 0x0051 }, | ||
| 62 | { .vid = 0x06cb, .pid = 0x0081 }, | ||
| 63 | { .vid = 0x06cb, .pid = 0x0088 }, | ||
| 64 | { .vid = 0x06cb, .pid = 0x008a }, | ||
| 65 | { .vid = 0x06cb, .pid = 0x009a }, | ||
| 66 | { .vid = 0x06cb, .pid = 0x009b }, | ||
| 67 | { .vid = 0x06cb, .pid = 0x00a2 }, | ||
| 68 | { .vid = 0x06cb, .pid = 0x00a8 }, | ||
| 69 | { .vid = 0x06cb, .pid = 0x00b7 }, | ||
| 70 | { .vid = 0x06cb, .pid = 0x00bb }, | ||
| 71 | { .vid = 0x06cb, .pid = 0x00be }, | ||
| 72 | { .vid = 0x06cb, .pid = 0x00cb }, | ||
| 73 | { .vid = 0x06cb, .pid = 0x00c9 }, | ||
| 74 | { .vid = 0x06cb, .pid = 0x00d8 }, | ||
| 75 | { .vid = 0x06cb, .pid = 0x00da }, | ||
| 76 | { .vid = 0x06cb, .pid = 0x00dc }, | ||
| 77 | { .vid = 0x06cb, .pid = 0x00e4 }, | ||
| 78 | { .vid = 0x06cb, .pid = 0x00e7 }, | ||
| 79 | { .vid = 0x06cb, .pid = 0x00e9 }, | ||
| 80 | { .vid = 0x06cb, .pid = 0x00fd }, | ||
| 81 | { .vid = 0x06cb, .pid = 0x00ff }, | ||
| 82 | { .vid = 0x0a5c, .pid = 0x5801 }, | ||
| 83 | { .vid = 0x0a5c, .pid = 0x5805 }, | ||
| 84 | { .vid = 0x0a5c, .pid = 0x5834 }, | ||
| 85 | { .vid = 0x0a5c, .pid = 0x5840 }, | ||
| 86 | { .vid = 0x0a5c, .pid = 0x5841 }, | ||
| 87 | { .vid = 0x0a5c, .pid = 0x5842 }, | ||
| 88 | { .vid = 0x0a5c, .pid = 0x5843 }, | ||
| 89 | { .vid = 0x0a5c, .pid = 0x5844 }, | ||
| 90 | { .vid = 0x0a5c, .pid = 0x5845 }, | ||
| 91 | { .vid = 0x0a5c, .pid = 0x5860 }, | ||
| 92 | { .vid = 0x0a5c, .pid = 0x5863 }, | ||
| 93 | { .vid = 0x0a5c, .pid = 0x5864 }, | ||
| 94 | { .vid = 0x0a5c, .pid = 0x5865 }, | ||
| 95 | { .vid = 0x0a5c, .pid = 0x5866 }, | ||
| 96 | { .vid = 0x0a5c, .pid = 0x5867 }, | ||
| 97 | { .vid = 0x0bda, .pid = 0x5812 }, | ||
| 98 | { .vid = 0x10a5, .pid = 0x0007 }, | ||
| 99 | { .vid = 0x10a5, .pid = 0x9200 }, | ||
| 100 | { .vid = 0x10a5, .pid = 0x9800 }, | ||
| 101 | { .vid = 0x10a5, .pid = 0xa120 }, | ||
| 102 | { .vid = 0x10a5, .pid = 0xa900 }, | ||
| 103 | { .vid = 0x10a5, .pid = 0xe340 }, | ||
| 104 | { .vid = 0x1188, .pid = 0x9545 }, | ||
| 105 | { .vid = 0x138a, .pid = 0x0007 }, | ||
| 106 | { .vid = 0x138a, .pid = 0x003a }, | ||
| 107 | { .vid = 0x138a, .pid = 0x003c }, | ||
| 108 | { .vid = 0x138a, .pid = 0x003d }, | ||
| 109 | { .vid = 0x138a, .pid = 0x003f }, | ||
| 110 | { .vid = 0x138a, .pid = 0x0090 }, | ||
| 111 | { .vid = 0x138a, .pid = 0x0092 }, | ||
| 112 | { .vid = 0x138a, .pid = 0x0094 }, | ||
| 113 | { .vid = 0x138a, .pid = 0x0097 }, | ||
| 114 | { .vid = 0x138a, .pid = 0x009d }, | ||
| 115 | { .vid = 0x138a, .pid = 0x00ab }, | ||
| 116 | { .vid = 0x138a, .pid = 0x00a6 }, | ||
| 117 | { .vid = 0x147e, .pid = 0x1002 }, | ||
| 118 | { .vid = 0x1491, .pid = 0x0088 }, | ||
| 119 | { .vid = 0x16d1, .pid = 0x1027 }, | ||
| 120 | { .vid = 0x1c7a, .pid = 0x0300 }, | ||
| 121 | { .vid = 0x1c7a, .pid = 0x0575 }, | ||
| 122 | { .vid = 0x1c7a, .pid = 0x0576 }, | ||
| 123 | { .vid = 0x1c7a, .pid = 0x0577 }, | ||
| 124 | { .vid = 0x1c7a, .pid = 0x057e }, | ||
| 125 | { .vid = 0x2541, .pid = 0x0236 }, | ||
| 126 | { .vid = 0x2541, .pid = 0x9711 }, | ||
| 127 | { .vid = 0x27c6, .pid = 0x5042 }, | ||
| 128 | { .vid = 0x27c6, .pid = 0x5110 }, | ||
| 129 | { .vid = 0x27c6, .pid = 0x5117 }, | ||
| 130 | { .vid = 0x27c6, .pid = 0x5120 }, | ||
| 131 | { .vid = 0x27c6, .pid = 0x5125 }, | ||
| 132 | { .vid = 0x27c6, .pid = 0x5201 }, | ||
| 133 | { .vid = 0x27c6, .pid = 0x521d }, | ||
| 134 | { .vid = 0x27c6, .pid = 0x5301 }, | ||
| 135 | { .vid = 0x27c6, .pid = 0x530c }, | ||
| 136 | { .vid = 0x27c6, .pid = 0x532d }, | ||
| 137 | { .vid = 0x27c6, .pid = 0x5335 }, | ||
| 138 | { .vid = 0x27c6, .pid = 0x533c }, | ||
| 139 | { .vid = 0x27c6, .pid = 0x5381 }, | ||
| 140 | { .vid = 0x27c6, .pid = 0x5385 }, | ||
| 141 | { .vid = 0x27c6, .pid = 0x538c }, | ||
| 142 | { .vid = 0x27c6, .pid = 0x538d }, | ||
| 143 | { .vid = 0x27c6, .pid = 0x5395 }, | ||
| 144 | { .vid = 0x27c6, .pid = 0x5503 }, | ||
| 145 | { .vid = 0x27c6, .pid = 0x550a }, | ||
| 146 | { .vid = 0x27c6, .pid = 0x550c }, | ||
| 147 | { .vid = 0x27c6, .pid = 0x5584 }, | ||
| 148 | { .vid = 0x27c6, .pid = 0x55a2 }, | ||
| 149 | { .vid = 0x27c6, .pid = 0x55a4 }, | ||
| 150 | { .vid = 0x27c6, .pid = 0x55b4 }, | ||
| 151 | { .vid = 0x27c6, .pid = 0x5740 }, | ||
| 152 | { .vid = 0x27c6, .pid = 0x5e0a }, | ||
| 153 | { .vid = 0x27c6, .pid = 0x581a }, | ||
| 154 | { .vid = 0x27c6, .pid = 0x589a }, | ||
| 155 | { .vid = 0x27c6, .pid = 0x5f10 }, | ||
| 156 | { .vid = 0x27c6, .pid = 0x6382 }, | ||
| 157 | { .vid = 0x2808, .pid = 0x9338 }, | ||
| 158 | { .vid = 0x2808, .pid = 0x9348 }, | ||
| 159 | { .vid = 0x2808, .pid = 0x93a9 }, | ||
| 160 | { .vid = 0x2808, .pid = 0xa658 }, | ||
| 161 | { .vid = 0x2808, .pid = 0xc652 }, | ||
| 162 | { .vid = 0x298d, .pid = 0x2020 }, | ||
| 163 | { .vid = 0x298d, .pid = 0x2033 }, | ||
| 164 | { .vid = 0x2df0, .pid = 0x0003 }, | ||
| 165 | { .vid = 0x3274, .pid = 0x8012 }, | ||
| 166 | { .vid = 0x3538, .pid = 0x0930 }, | ||
| 167 | { .vid = 0 }, | ||
| 168 | }; | ||
| 169 | |||
| 170 | static const FpIdEntry denylist_id_table[] = { | ||
| 171 | { .vid = 0x0483, .pid = 0x2016 }, | ||
| 172 | /* https://bugs.freedesktop.org/show_bug.cgi?id=66659 */ | ||
| 173 | { .vid = 0x045e, .pid = 0x00bb }, | ||
| 174 | { .vid = 0 }, | ||
| 175 | }; | ||
| 176 | |||
| 177 | static const FpDeviceClass allowlist = { | ||
| 178 | .type = FP_DEVICE_TYPE_USB, | ||
| 179 | .id_table = allowlist_id_table, | ||
| 180 | .id = "allowlist", | ||
| 181 | .full_name = "Hardcoded allowlist" | ||
| 182 | }; | ||
| 183 | |||
| 184 | GHashTable *printed = NULL; | ||
| 185 | |||
| 186 | static void | ||
| 187 | 30 | print_driver (const FpDeviceClass *cls) | |
| 188 | { | ||
| 189 | 30 | const FpIdEntry *entry; | |
| 190 | 30 | gint num_printed = 0; | |
| 191 | |||
| 192 |
1/2✓ Branch 0 (2→3) taken 30 times.
✗ Branch 1 (2→31) not taken.
|
30 | if (cls->type != FP_DEVICE_TYPE_USB) |
| 193 | return; | ||
| 194 | |||
| 195 |
2/2✓ Branch 0 (27→7) taken 370 times.
✓ Branch 1 (27→28) taken 30 times.
|
400 | for (entry = cls->id_table; entry->vid != 0; entry++) |
| 196 | { | ||
| 197 | const FpIdEntry *bl_entry; | ||
| 198 | char *key; | ||
| 199 | |||
| 200 |
2/2✓ Branch 0 (7→4) taken 739 times.
✓ Branch 1 (7→8) taken 368 times.
|
1107 | for (bl_entry = denylist_id_table; bl_entry->vid != 0; bl_entry++) |
| 201 |
4/4✓ Branch 0 (4→5) taken 7 times.
✓ Branch 1 (4→6) taken 732 times.
✓ Branch 2 (5→6) taken 5 times.
✓ Branch 3 (5→8) taken 2 times.
|
739 | if (entry->vid == bl_entry->vid && entry->pid == bl_entry->pid) |
| 202 | break; | ||
| 203 | |||
| 204 |
2/2✓ Branch 0 (8→9) taken 2 times.
✓ Branch 1 (8→11) taken 368 times.
|
370 | if (bl_entry->vid != 0) |
| 205 | 2 | continue; | |
| 206 | |||
| 207 | 368 | key = g_strdup_printf ("%04x:%04x", entry->vid, entry->pid); | |
| 208 | |||
| 209 |
2/2✓ Branch 0 (13→14) taken 1 times.
✓ Branch 1 (13→19) taken 367 times.
|
368 | if (g_hash_table_lookup (printed, key) != NULL) |
| 210 | { | ||
| 211 |
1/2✗ Branch 0 (14→15) not taken.
✓ Branch 1 (14→17) taken 1 times.
|
1 | if (cls == &allowlist) |
| 212 | ✗ | g_warning ("%s implemented by driver %s", | |
| 213 | key, (const char *) g_hash_table_lookup (printed, key)); | ||
| 214 | 1 | g_free (key); | |
| 215 | 1 | continue; | |
| 216 | } | ||
| 217 | |||
| 218 | 367 | g_hash_table_insert (printed, key, (void *) cls->id); | |
| 219 | |||
| 220 |
2/2✓ Branch 0 (20→21) taken 29 times.
✓ Branch 1 (20→24) taken 338 times.
|
367 | if (num_printed == 0) |
| 221 | { | ||
| 222 |
2/2✓ Branch 0 (21→22) taken 28 times.
✓ Branch 1 (21→23) taken 1 times.
|
29 | if (cls != &allowlist) |
| 223 | 28 | g_print ("\n# Supported by libfprint driver %s\n", cls->id); | |
| 224 | else | ||
| 225 | 1 | g_print ("\n# Known unsupported devices\n"); | |
| 226 | } | ||
| 227 | |||
| 228 | 367 | g_print ("usb:v%04Xp%04X*\n", | |
| 229 | 367 | entry->vid, entry->pid); | |
| 230 | 367 | num_printed++; | |
| 231 | } | ||
| 232 | |||
| 233 |
2/2✓ Branch 0 (28→29) taken 29 times.
✓ Branch 1 (28→31) taken 1 times.
|
30 | if (num_printed > 0) |
| 234 | { | ||
| 235 | 29 | g_print (" ID_AUTOSUSPEND=1\n"); | |
| 236 | 29 | g_print (" ID_PERSIST=0\n"); | |
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | static int | ||
| 241 | 120 | driver_compare (gconstpointer p1, gconstpointer p2) | |
| 242 | { | ||
| 243 | 120 | g_autoptr(FpDeviceClass) cls1 = g_type_class_ref (*(GType *) p1); | |
| 244 | 240 | g_autoptr(FpDeviceClass) cls2 = g_type_class_ref (*(GType *) p2); | |
| 245 | |||
| 246 | 120 | return g_strcmp0 (cls1->id, cls2->id); | |
| 247 | } | ||
| 248 | |||
| 249 | int | ||
| 250 | 1 | main (int argc, char **argv) | |
| 251 | { | ||
| 252 | 1 | g_autoptr(GArray) drivers = fpi_get_driver_types (); | |
| 253 | 1 | g_autofree char *program_name = NULL; | |
| 254 | 1 | guint i; | |
| 255 | |||
| 256 | 1 | program_name = g_path_get_basename (argv[0]); | |
| 257 | |||
| 258 | 1 | g_print ("# SPDX-License-Identifier: LGPL-2.1-or-later\n"); | |
| 259 | 1 | g_print ("# This file has been generated using %s with all drivers enabled\n", | |
| 260 | program_name); | ||
| 261 | |||
| 262 | 1 | printed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); | |
| 263 | 1 | g_array_sort (drivers, driver_compare); | |
| 264 | |||
| 265 |
2/2✓ Branch 0 (15→9) taken 33 times.
✓ Branch 1 (15→16) taken 1 times.
|
35 | for (i = 0; i < drivers->len; i++) |
| 266 | { | ||
| 267 | 33 | GType driver = g_array_index (drivers, GType, i); | |
| 268 | 66 | g_autoptr(FpDeviceClass) cls = g_type_class_ref (driver); | |
| 269 | |||
| 270 |
2/2✓ Branch 0 (10→11) taken 4 times.
✓ Branch 1 (10→12) taken 29 times.
|
33 | if (cls->type != FP_DEVICE_TYPE_USB) |
| 271 | 4 | continue; | |
| 272 | |||
| 273 | 29 | print_driver (cls); | |
| 274 | } | ||
| 275 | |||
| 276 | 1 | print_driver (&allowlist); | |
| 277 | |||
| 278 | 1 | g_hash_table_destroy (printed); | |
| 279 | |||
| 280 | 1 | return 0; | |
| 281 | } | ||
| 282 |