Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jul 2018 13:40:52 +0000 (UTC)
From:      Ben Woods <woodsb02@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336602 - head/lib/geom/eli
Message-ID:  <201807221340.w6MDeqMs053634@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: woodsb02 (ports committer)
Date: Sun Jul 22 13:40:52 2018
New Revision: 336602
URL: https://svnweb.freebsd.org/changeset/base/336602

Log:
  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

Modified:
  head/lib/geom/eli/geom_eli.c

Modified: head/lib/geom/eli/geom_eli.c
==============================================================================
--- head/lib/geom/eli/geom_eli.c	Sun Jul 22 12:45:02 2018	(r336601)
+++ head/lib/geom/eli/geom_eli.c	Sun Jul 22 13:40:52 2018	(r336602)
@@ -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));
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807221340.w6MDeqMs053634>