mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Add a helper function for loading geli keys from the loader.
This commit is contained in:
parent
e31a070263
commit
d842ade9a4
2 changed files with 50 additions and 1 deletions
|
|
@ -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 the file to be loaded
|
|||
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
|
||||
|
|
|
|||
|
|
@ -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#] <prov> <file>";
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue