From owner-svn-src-head@freebsd.org Tue Apr 10 13:22:49 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 0D637F9C754; Tue, 10 Apr 2018 13:22:49 +0000 (UTC) (envelope-from oshogbo@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 AE6BD6AE4F; Tue, 10 Apr 2018 13:22:48 +0000 (UTC) (envelope-from oshogbo@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 A96886265; Tue, 10 Apr 2018 13:22:48 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3ADMm8I057916; Tue, 10 Apr 2018 13:22:48 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3ADMmhg057913; Tue, 10 Apr 2018 13:22:48 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201804101322.w3ADMmhg057913@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Tue, 10 Apr 2018 13:22:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332361 - in head: sbin/geom/class/eli sys/geom/eli X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: in head: sbin/geom/class/eli sys/geom/eli X-SVN-Commit-Revision: 332361 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.25 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: Tue, 10 Apr 2018 13:22:49 -0000 Author: oshogbo Date: Tue Apr 10 13:22:48 2018 New Revision: 332361 URL: https://svnweb.freebsd.org/changeset/base/332361 Log: Introduce dry run option for attaching the device. This will allow us to verify if passphrase and key is valid without decrypting whole device. Reviewed by: cem@, allanjude@ Differential Revision: https://reviews.freebsd.org/D15000 Modified: head/sbin/geom/class/eli/geli.8 head/sbin/geom/class/eli/geom_eli.c head/sys/geom/eli/g_eli_ctl.c Modified: head/sbin/geom/class/eli/geli.8 ============================================================================== --- head/sbin/geom/class/eli/geli.8 Tue Apr 10 13:16:50 2018 (r332360) +++ head/sbin/geom/class/eli/geli.8 Tue Apr 10 13:22:48 2018 (r332361) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 17, 2017 +.Dd April 10, 2018 .Dt GELI 8 .Os .Sh NAME @@ -67,7 +67,7 @@ utility: .Cm init .Nm .Cm attach -.Op Fl dprv +.Op Fl dnprv .Op Fl j Ar passfile .Op Fl k Ar keyfile .Ar prov @@ -420,6 +420,9 @@ For more information see the description of the option for the .Cm init subcommand. +.It Fl n +Do a dry-run decryption. +This is useful to verify passphrase and keyfile without decrypting the device. .It Fl p Do not use a passphrase as a component of the User Key. Cannot be combined with the Modified: head/sbin/geom/class/eli/geom_eli.c ============================================================================== --- head/sbin/geom/class/eli/geom_eli.c Tue Apr 10 13:16:50 2018 (r332360) +++ head/sbin/geom/class/eli/geom_eli.c Tue Apr 10 13:22:48 2018 (r332361) @@ -148,11 +148,12 @@ struct g_command class_commands[] = { { 'd', "detach", NULL, G_TYPE_BOOL }, { 'j', "passfile", G_VAL_OPTIONAL, G_TYPE_STRING | G_TYPE_MULTI }, { 'k', "keyfile", G_VAL_OPTIONAL, G_TYPE_STRING | G_TYPE_MULTI }, + { 'n', "dryrun", NULL, G_TYPE_BOOL }, { 'p', "nopassphrase", NULL, G_TYPE_BOOL }, { 'r', "readonly", NULL, G_TYPE_BOOL }, G_OPT_SENTINEL }, - "[-dprv] [-j passfile] [-k keyfile] prov" + "[-dnprv] [-j passfile] [-k keyfile] prov" }, { "detach", 0, NULL, { Modified: head/sys/geom/eli/g_eli_ctl.c ============================================================================== --- head/sys/geom/eli/g_eli_ctl.c Tue Apr 10 13:16:50 2018 (r332360) +++ head/sys/geom/eli/g_eli_ctl.c Tue Apr 10 13:22:48 2018 (r332361) @@ -59,7 +59,7 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_class struct g_provider *pp; const char *name; u_char *key, mkey[G_ELI_DATAIVKEYLEN]; - int *nargs, *detach, *readonly; + int *nargs, *detach, *readonly, *dryrun; int keysize, error; u_int nkey; @@ -87,6 +87,12 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_class return; } + dryrun = gctl_get_paraml(req, "dryrun", sizeof(*dryrun)); + if (dryrun == NULL) { + gctl_error(req, "No '%s' argument.", "dryrun"); + return; + } + if (*detach && *readonly) { gctl_error(req, "Options -d and -r are mutually exclusive."); return; @@ -141,7 +147,8 @@ g_eli_ctl_attach(struct gctl_req *req, struct g_class md.md_flags |= G_ELI_FLAG_WO_DETACH; if (*readonly) md.md_flags |= G_ELI_FLAG_RO; - g_eli_create(req, mp, pp, &md, mkey, nkey); + if (!*dryrun) + g_eli_create(req, mp, pp, &md, mkey, nkey); explicit_bzero(mkey, sizeof(mkey)); explicit_bzero(&md, sizeof(md)); }