[luksbootkeyfile] Implement keyfile creation and use
- Just copy the commands from the existing Python code, including nonsensical dd.
This commit is contained in:
parent
8706b579ec
commit
856a2eaa1d
@ -106,16 +106,33 @@ struct LuksDeviceList
|
||||
bool valid;
|
||||
};
|
||||
|
||||
static const char keyfile[] = "/crypto_keyfile.bin";
|
||||
|
||||
static bool
|
||||
generateTargetKeyfile()
|
||||
{
|
||||
auto r = CalamaresUtils::System::instance()->targetEnvCommand(
|
||||
{ "dd", "bs=512", "count=4", "if=/dev/urandom", QString( "of=%1" ).arg( keyfile ) } );
|
||||
if ( r.getExitCode() != 0 )
|
||||
{
|
||||
cWarning() << "Could not create LUKS keyfile:" << r.getOutput() << "(exit code" << r.getExitCode() << ')';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
setupLuks( const LuksDevice& d )
|
||||
{
|
||||
auto r = CalamaresUtils::System::instance()->targetEnvCommand(
|
||||
{ "cryptsetup", "luksAddKey", d.device, keyfile }, QString(), d.passphrase, 15 );
|
||||
if ( r.getExitCode() != 0 )
|
||||
{
|
||||
cWarning() << "Could not configure LUKS keyfile on" << d.device << ':' << r.getOutput() << "(exit code"
|
||||
<< r.getExitCode() << ')';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Calamares::JobResult
|
||||
|
Loading…
Reference in New Issue
Block a user