aboutsummaryrefslogtreecommitdiff
path: root/lib/geom
diff options
context:
space:
mode:
authorBen Woods <woodsb02@FreeBSD.org>2018-07-22 13:40:52 +0000
committerBen Woods <woodsb02@FreeBSD.org>2018-07-22 13:40:52 +0000
commit4b8e4d53fa6f9e262c5bbaae48ecfda99a7d652e (patch)
tree56ad4a888418522411c9c742330fbe81c56c99fa /lib/geom
parentcca6b506e010310b11ea0e3f58c5e425c7eb7076 (diff)
downloadsrc-4b8e4d53fa6f9e262c5bbaae48ecfda99a7d652e.tar.gz
src-4b8e4d53fa6f9e262c5bbaae48ecfda99a7d652e.zip
geli attach: Fix exit codes and errors not being printed after r335673
Now that multiple providers can be attached at once, exit codes and error messages must be handled correctly if there are failures in on any of the providers. Reported by: asomers (Kyua test failures via continuous integration) Reviewed by: asomers Approved by: allanjude Differential Revision: https://reviews.freebsd.org/D16386
Notes
Notes: svn path=/head/; revision=336602
Diffstat (limited to 'lib/geom')
-rw-r--r--lib/geom/eli/geom_eli.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/geom/eli/geom_eli.c b/lib/geom/eli/geom_eli.c
index 15e584049da6..db87c419523a 100644
--- a/lib/geom/eli/geom_eli.c
+++ b/lib/geom/eli/geom_eli.c
@@ -941,18 +941,26 @@ eli_attach(struct gctl_req *req)
prov = gctl_get_ascii(req, "arg%d", i);
gctl_ro_param(r, "arg0", -1, prov);
- if (eli_metadata_read(r, prov, &md) == -1)
- return;
+ if (eli_metadata_read(r, prov, &md) == -1) {
+ /*
+ * Error reading metadata - details added to geom
+ * request by eli_metadata_read().
+ */
+ goto out;
+ }
mediasize = g_get_mediasize(prov);
if (md.md_provsize != (uint64_t)mediasize) {
gctl_error(r, "Provider size mismatch.");
- return;
+ goto out;
}
if (eli_genkey(r, &md, key, false) == NULL) {
- explicit_bzero(key, sizeof(key));
- return;
+ /*
+ * Error generating key - details added to geom request
+ * by eli_genkey().
+ */
+ goto out;
}
gctl_ro_param(r, "key", sizeof(key), key);
@@ -962,19 +970,20 @@ eli_attach(struct gctl_req *req)
printf("Attached to %s.\n", prov);
}
+out:
/* Print error for this request, and set parent request error message */
- if (r->error != NULL && r->error[0] != '\0') {
- warnx("%s", r->error);
- gctl_error(req, "At least one provider failed to attach.");
- }
+ if (r->error != NULL && r->error[0] != '\0') {
+ warnx("%s", r->error);
+ gctl_error(req, "There was an error with at least one provider.");
+ }
gctl_free(r);
- /* Clear the derived key */
+ /* Clear sensitive data from memory. */
explicit_bzero(key, sizeof(key));
}
- /* Clear the cached passphrase */
+ /* Clear sensitive data from memory. */
explicit_bzero(cached_passphrase, sizeof(cached_passphrase));
}