Merge pull request #17093 from poettering/dissect-tweaks2
dissect: some more tweaks
This commit is contained in:
commit
50406dc7f1
|
@ -369,11 +369,11 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
|||
r = dissected_image_acquire_metadata(m);
|
||||
if (r == -ENXIO)
|
||||
return log_error_errno(r, "No root partition discovered.");
|
||||
if (r == -EMEDIUMTYPE)
|
||||
return log_error_errno(r, "Not a valid OS image, no os-release file included.");
|
||||
if (r == -EUCLEAN)
|
||||
return log_error_errno(r, "File system check of image failed.");
|
||||
if (r == -EUNATCH)
|
||||
if (r == -EMEDIUMTYPE)
|
||||
log_warning_errno(r, "Not a valid OS image, no os-release file included. Proceeding anyway.");
|
||||
else if (r == -EUNATCH)
|
||||
log_warning_errno(r, "OS image is encrypted, proceeding without showing OS image metadata.");
|
||||
else if (r == -EBUSY)
|
||||
log_warning_errno(r, "OS image is currently in use, proceeding without showing OS image metadata.");
|
||||
|
@ -403,9 +403,13 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
|||
p == m->os_release ? "OS Release:" : " ",
|
||||
*p, *q);
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_json) {
|
||||
if (m->hostname ||
|
||||
!sd_id128_is_null(m->machine_id) ||
|
||||
!strv_isempty(m->machine_info) ||
|
||||
!strv_isempty(m->os_release))
|
||||
putc('\n', stdout);
|
||||
} else {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *mi = NULL, *osr = NULL;
|
||||
|
||||
if (!strv_isempty(m->machine_info)) {
|
||||
|
@ -431,9 +435,6 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
|||
return log_oom();
|
||||
}
|
||||
|
||||
if (!arg_json)
|
||||
putc('\n', stdout);
|
||||
|
||||
t = table_new("rw", "designator", "partition uuid", "fstype", "architecture", "verity", "node", "partno");
|
||||
if (!t)
|
||||
return log_oom();
|
||||
|
|
|
@ -793,7 +793,12 @@ int dissect_image(
|
|||
}
|
||||
}
|
||||
|
||||
if (!m->partitions[PARTITION_ROOT].found) {
|
||||
if (m->partitions[PARTITION_ROOT].found) {
|
||||
/* If we found the primary arch, then invalidate the secondary arch to avoid any ambiguities,
|
||||
* since we never want to mount the secondary arch in this case. */
|
||||
m->partitions[PARTITION_ROOT_SECONDARY].found = false;
|
||||
m->partitions[PARTITION_ROOT_SECONDARY_VERITY].found = false;
|
||||
} else {
|
||||
/* No root partition found? Then let's see if ther's one for the secondary architecture. And if not
|
||||
* either, then check if there's a single generic one, and use that. */
|
||||
|
||||
|
@ -848,12 +853,6 @@ int dissect_image(
|
|||
if (!m->partitions[PARTITION_ROOT_VERITY].found || !m->partitions[PARTITION_ROOT].found)
|
||||
return -EADDRNOTAVAIL;
|
||||
|
||||
/* If we found the primary root with the hash, then we definitely want to suppress any secondary root
|
||||
* (which would be weird, after all the root hash should only be assigned to one pair of
|
||||
* partitions... */
|
||||
m->partitions[PARTITION_ROOT_SECONDARY].found = false;
|
||||
m->partitions[PARTITION_ROOT_SECONDARY_VERITY].found = false;
|
||||
|
||||
/* If we found a verity setup, then the root partition is necessarily read-only. */
|
||||
m->partitions[PARTITION_ROOT].rw = false;
|
||||
|
||||
|
@ -1034,7 +1033,7 @@ static int mount_partition(
|
|||
/* If requested, turn on discard support. */
|
||||
if (fstype_can_discard(fstype) &&
|
||||
((flags & DISSECT_IMAGE_DISCARD) ||
|
||||
((flags & DISSECT_IMAGE_DISCARD_ON_LOOP) && is_loop_device(m->node)))) {
|
||||
((flags & DISSECT_IMAGE_DISCARD_ON_LOOP) && is_loop_device(m->node) > 0))) {
|
||||
options = strdup("discard");
|
||||
if (!options)
|
||||
return -ENOMEM;
|
||||
|
@ -1322,9 +1321,10 @@ static int decrypt_partition(
|
|||
return r == -EPERM ? -EKEYREJECTED : r;
|
||||
}
|
||||
|
||||
d->decrypted[d->n_decrypted].name = TAKE_PTR(name);
|
||||
d->decrypted[d->n_decrypted].device = TAKE_PTR(cd);
|
||||
d->n_decrypted++;
|
||||
d->decrypted[d->n_decrypted++] = (DecryptedPartition) {
|
||||
.name = TAKE_PTR(name),
|
||||
.device = TAKE_PTR(cd),
|
||||
};
|
||||
|
||||
m->decrypted_node = TAKE_PTR(node);
|
||||
|
||||
|
@ -1466,7 +1466,8 @@ static int verity_partition(
|
|||
verity->root_hash_sig_size,
|
||||
CRYPT_ACTIVATE_READONLY);
|
||||
#else
|
||||
r = log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "activation of verity device with signature requested, but not supported by cryptsetup due to missing crypt_activate_by_signed_key()");
|
||||
r = log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Activation of verity device with signature requested, but not supported by %s due to missing crypt_activate_by_signed_key().", program_invocation_short_name);
|
||||
#endif
|
||||
} else
|
||||
r = sym_crypt_activate_by_volume_key(
|
||||
|
@ -1540,9 +1541,10 @@ static int verity_partition(
|
|||
/* Everything looks good and we'll be able to mount the device, so deferred remove will be re-enabled at that point. */
|
||||
restore_deferred_remove = mfree(restore_deferred_remove);
|
||||
|
||||
d->decrypted[d->n_decrypted].name = TAKE_PTR(name);
|
||||
d->decrypted[d->n_decrypted].device = TAKE_PTR(cd);
|
||||
d->n_decrypted++;
|
||||
d->decrypted[d->n_decrypted++] = (DecryptedPartition) {
|
||||
.name = TAKE_PTR(name),
|
||||
.device = TAKE_PTR(cd),
|
||||
};
|
||||
|
||||
m->decrypted_node = TAKE_PTR(node);
|
||||
|
||||
|
@ -1588,7 +1590,7 @@ int dissected_image_decrypt(
|
|||
|
||||
for (PartitionDesignator i = 0; i < _PARTITION_DESIGNATOR_MAX; i++) {
|
||||
DissectedPartition *p = m->partitions + i;
|
||||
int k;
|
||||
PartitionDesignator k;
|
||||
|
||||
if (!p->found)
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue