From owner-svn-src-head@freebsd.org Sun Jul 22 13:40:53 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2025D104BEAB; Sun, 22 Jul 2018 13:40:53 +0000 (UTC) (envelope-from woodsb02@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C213475520; Sun, 22 Jul 2018 13:40:52 +0000 (UTC) (envelope-from woodsb02@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8935E6AC4; Sun, 22 Jul 2018 13:40:52 +0000 (UTC) (envelope-from woodsb02@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6MDeq1R053635; Sun, 22 Jul 2018 13:40:52 GMT (envelope-from woodsb02@FreeBSD.org) Received: (from woodsb02@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6MDeqMs053634; Sun, 22 Jul 2018 13:40:52 GMT (envelope-from woodsb02@FreeBSD.org) Message-Id: <201807221340.w6MDeqMs053634@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: woodsb02 set sender to woodsb02@FreeBSD.org using -f From: Ben Woods Date: Sun, 22 Jul 2018 13:40:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336602 - head/lib/geom/eli X-SVN-Group: head X-SVN-Commit-Author: woodsb02 X-SVN-Commit-Paths: head/lib/geom/eli X-SVN-Commit-Revision: 336602 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jul 2018 13:40:53 -0000 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)); }