|
97 | 97 |
|
98 | 98 | static int force_ca_check;
|
99 | 99 | static int check_keyring;
|
| 100 | +static int opt_verbose_listing; |
| 101 | +static int opt_list_all; |
| 102 | + |
| 103 | +static const char* const db_names[] = { "MokListRT", "MokListXRT", "PK", "KEK", "db", "dbx" }; |
100 | 104 |
|
101 | 105 | typedef struct {
|
102 | 106 | uint32_t mok_toggle_state;
|
@@ -172,22 +176,24 @@ list_keys (const uint8_t *data, const size_t data_size)
|
172 | 176 | for (unsigned int i = 0; i < mok_num; i++) {
|
173 | 177 | char *owner_str = NULL;
|
174 | 178 | int ret;
|
175 |
| - printf ("[key %d]\n", i+1); |
| 179 | + if (opt_verbose_listing) { |
| 180 | + printf ("[key %d]\n", i+1); |
176 | 181 |
|
177 |
| - ret = efi_guid_to_str(&list[i].owner, &owner_str); |
178 |
| - if (ret > 0) { |
179 |
| - printf ("Owner: %s\n", owner_str); |
180 |
| - free (owner_str); |
| 182 | + ret = efi_guid_to_str(&list[i].owner, &owner_str); |
| 183 | + if (ret > 0) { |
| 184 | + printf ("Owner: %s\n", owner_str); |
| 185 | + free (owner_str); |
| 186 | + } |
181 | 187 | }
|
182 | 188 |
|
183 | 189 | efi_guid_t sigtype = list[i].header->SignatureType;
|
184 | 190 | if (efi_guid_cmp (&sigtype, &efi_guid_x509_cert) == 0) {
|
185 |
| - print_x509 (list[i].mok, list[i].mok_size); |
| 191 | + print_x509 (list[i].mok, list[i].mok_size, opt_verbose_listing); |
186 | 192 | } else {
|
187 | 193 | print_hash_array (&sigtype,
|
188 |
| - list[i].mok, list[i].mok_size); |
| 194 | + list[i].mok, list[i].mok_size, opt_verbose_listing); |
189 | 195 | }
|
190 |
| - if (i < mok_num - 1) |
| 196 | + if (opt_verbose_listing && i < mok_num - 1) |
191 | 197 | printf ("\n");
|
192 | 198 | }
|
193 | 199 |
|
@@ -1220,6 +1226,8 @@ export_db_keys (const DBName db_name)
|
1220 | 1226 | case DBX:
|
1221 | 1227 | guid = efi_guid_security;
|
1222 | 1228 | break;
|
| 1229 | + case _DB_NAME_MAX: |
| 1230 | + return -1; |
1223 | 1231 | };
|
1224 | 1232 |
|
1225 | 1233 | db_var_name = get_db_var_name(db_name);
|
@@ -1774,6 +1782,8 @@ list_db (const DBName db_name)
|
1774 | 1782 | return list_keys_in_var ("db", efi_guid_security);
|
1775 | 1783 | case DBX:
|
1776 | 1784 | return list_keys_in_var ("dbx", efi_guid_security);
|
| 1785 | + case _DB_NAME_MAX: |
| 1786 | + return -1; |
1777 | 1787 | }
|
1778 | 1788 |
|
1779 | 1789 | return -1;
|
@@ -1873,11 +1883,13 @@ main (int argc, char *argv[])
|
1873 | 1883 | {"ca-check", no_argument, 0, 0 },
|
1874 | 1884 | {"ignore-keyring", no_argument, 0, 0 },
|
1875 | 1885 | {"version", no_argument, 0, 'v'},
|
| 1886 | + {"verbose-listing", no_argument, 0, 0}, |
| 1887 | + {"all", no_argument, 0, 'a'}, |
1876 | 1888 | {0, 0, 0, 0}
|
1877 | 1889 | };
|
1878 | 1890 |
|
1879 | 1891 | int option_index = 0;
|
1880 |
| - c = getopt_long (argc, argv, "cd:f:g::hi:lmpt:xDNPXv", |
| 1892 | + c = getopt_long (argc, argv, "acd:f:g::hi:lmpt:xDNPXv", |
1881 | 1893 | long_options, &option_index);
|
1882 | 1894 |
|
1883 | 1895 | if (c == -1)
|
@@ -2009,8 +2021,13 @@ main (int argc, char *argv[])
|
2009 | 2021 | force_ca_check = 1;
|
2010 | 2022 | } else if (strcmp (option, "ignore-keyring") == 0) {
|
2011 | 2023 | check_keyring = 0;
|
| 2024 | + } else if (strcmp (option, "verbose-listing") == 0) { |
| 2025 | + opt_verbose_listing = 1; |
2012 | 2026 | }
|
2013 | 2027 |
|
| 2028 | + break; |
| 2029 | + case 'a': |
| 2030 | + opt_list_all = 1; |
2014 | 2031 | break;
|
2015 | 2032 | case 'l':
|
2016 | 2033 | command |= LIST_ENROLLED;
|
@@ -2170,7 +2187,18 @@ main (int argc, char *argv[])
|
2170 | 2187 | switch (command) {
|
2171 | 2188 | case LIST_ENROLLED:
|
2172 | 2189 | case LIST_ENROLLED | MOKX:
|
2173 |
| - ret = list_db (db_name); |
| 2190 | + if (opt_list_all) { |
| 2191 | + ret = 0; |
| 2192 | + for (DBName db = MOK_LIST_RT; db < _DB_NAME_MAX; ++db) { |
| 2193 | + int r; |
| 2194 | + printf("[%s]\n", db_names[db]); |
| 2195 | + r = list_db (db); |
| 2196 | + if (r) |
| 2197 | + ret = r; |
| 2198 | + } |
| 2199 | + } else { |
| 2200 | + ret = list_db (db_name); |
| 2201 | + } |
2174 | 2202 | break;
|
2175 | 2203 | case LIST_NEW:
|
2176 | 2204 | ret = list_keys_in_var ("MokNew", efi_guid_shim);
|
|
0 commit comments