[users] Use Calamares command-running API
This commit is contained in:
parent
dfe07a51a3
commit
51e05241fe
@ -66,27 +66,20 @@ ActiveDirectoryJob::exec()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QString installPath = Calamares::System::instance()->targetPath( QStringLiteral( "/" ) );
|
const QString installPath = Calamares::System::instance()->targetPath( QStringLiteral( "/" ) );
|
||||||
QStringList args = { "join", m_domain, "-U", m_adminLogin, "--install=" + installPath, "--verbose" };
|
auto r = Calamares::System::instance()->runCommand(
|
||||||
|
Calamares::System::RunLocation::RunInHost,
|
||||||
|
{ "realm", "join", m_domain, "-U", m_adminLogin, "--install=" + installPath, "--verbose" },
|
||||||
|
QString(),
|
||||||
|
m_adminPassword,
|
||||||
|
std::chrono::seconds( 30 ) );
|
||||||
|
|
||||||
QProcess process;
|
|
||||||
process.start( "realm", args );
|
|
||||||
process.waitForStarted();
|
|
||||||
|
|
||||||
if ( !m_adminPassword.isEmpty() )
|
if ( r.getExitCode() == 0 )
|
||||||
{
|
|
||||||
process.write( ( m_adminPassword + "\n" ).toUtf8() );
|
|
||||||
process.closeWriteChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
process.waitForFinished( -1 );
|
|
||||||
|
|
||||||
if ( process.exitCode() == 0 )
|
|
||||||
{
|
{
|
||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString errorOutput = process.readAllStandardError();
|
return Calamares::JobResult::error( QString( "Failed to join realm: %1" ).arg( r.getOutput() ) );
|
||||||
return Calamares::JobResult::error( QString( "Failed to join realm: %1" ).arg( errorOutput ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user