From owner-svn-src-head@FreeBSD.ORG Mon Feb 16 02:42:18 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 540B8106566B; Mon, 16 Feb 2009 02:42:18 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 27F3D8FC15; Mon, 16 Feb 2009 02:42:18 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1G2gId1035887; Mon, 16 Feb 2009 02:42:18 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1G2gIGx035885; Mon, 16 Feb 2009 02:42:18 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <200902160242.n1G2gIGx035885@svn.freebsd.org> From: Andrew Thompson Date: Mon, 16 Feb 2009 02:42:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188666 - head/sys/boot/common X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 16 Feb 2009 02:42:18 -0000 Author: thompsa Date: Mon Feb 16 02:42:17 2009 New Revision: 188666 URL: http://svn.freebsd.org/changeset/base/188666 Log: Add a helper function for loading geli keys from the loader. Modified: head/sys/boot/common/loader.8 head/sys/boot/common/module.c Modified: head/sys/boot/common/loader.8 ============================================================================== --- head/sys/boot/common/loader.8 Sun Feb 15 23:40:29 2009 (r188665) +++ head/sys/boot/common/loader.8 Mon Feb 16 02:42:17 2009 (r188666) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 8, 2007 +.Dd February 15, 2009 .Dt LOADER 8 .Os .Sh NAME @@ -215,6 +215,17 @@ Any arguments passed after the name of t will be passed as arguments to that file. Currently, argument passing does not work for the kernel. .Pp +.It Ic load_geli Xo +.Op Fl n Ar keyno +.Ar prov Ar file +.Xc +Loads a +.Xr geli 8 +encryption keyfile for the given provider name. +The key index can be specified via +.Ar keyno +or will default to zero. +.Pp .It Ic ls Xo .Op Fl l .Op Ar path Modified: head/sys/boot/common/module.c ============================================================================== --- head/sys/boot/common/module.c Sun Feb 15 23:40:29 2009 (r188665) +++ head/sys/boot/common/module.c Mon Feb 16 02:42:17 2009 (r188666) @@ -154,6 +154,44 @@ command_load(int argc, char *argv[]) return (error == 0 ? CMD_OK : CMD_ERROR); } +COMMAND_SET(load_geli, "load_geli", "load a geli key", command_load_geli); + +static int +command_load_geli(int argc, char *argv[]) +{ + char typestr[80]; + char *cp; + int ch, num; + + if (argc < 3) { + command_errmsg = "usage is [-n key#] "; + return(CMD_ERROR); + } + + num = 0; + optind = 1; + optreset = 1; + while ((ch = getopt(argc, argv, "n:")) != -1) { + switch(ch) { + case 'n': + num = strtol(optarg, &cp, 0); + if (cp == optarg) { + sprintf(command_errbuf, "bad key index '%s'", optarg); + return(CMD_ERROR); + } + break; + case '?': + default: + /* getopt has already reported an error */ + return(CMD_OK); + } + } + argv += (optind - 1); + argc -= (optind - 1); + sprintf(typestr, "%s:geli_keyfile%d", argv[1], num); + return(file_loadraw(typestr, argv[2])); +} + COMMAND_SET(unload, "unload", "unload all modules", command_unload); static int