Make sure chrootCall with args list actually passes the args as list.

This commit is contained in:
Teo Mrnjavac 2014-07-30 12:43:15 +02:00
parent 122a6036d5
commit e7e57689d8
3 changed files with 21 additions and 4 deletions

View File

@ -66,7 +66,8 @@ chroot_call( const boost::python::list& args,
list.append( QString::fromStdString( list.append( QString::fromStdString(
boost::python::extract< std::string >( args[ i ] ) ) ); boost::python::extract< std::string >( args[ i ] ) ) );
} }
return CalamaresUtils::chrootCall( list.join( ' ' ),
return CalamaresUtils::chrootCall( list,
QString::fromStdString( stdin ), QString::fromStdString( stdin ),
timeout ); timeout );
} }

View File

@ -55,7 +55,7 @@ int mount( const QString& devicePath,
return QProcess::execute( program, args ); return QProcess::execute( program, args );
} }
int chrootCall( const QString& command, int chrootCall( const QStringList& args,
const QString& stdInput, const QString& stdInput,
int timeoutSec ) int timeoutSec )
{ {
@ -68,11 +68,12 @@ int chrootCall( const QString& command,
return -3; return -3;
QString program( "chroot" ); QString program( "chroot" );
QStringList args = { destDir, command }; QStringList arguments = { destDir };
arguments << args;
QProcess process; QProcess process;
process.setProgram( program ); process.setProgram( program );
process.setArguments( args ); process.setArguments( arguments );
if ( !process.waitForStarted() ) if ( !process.waitForStarted() )
return -2; return -2;
@ -92,4 +93,15 @@ int chrootCall( const QString& command,
return process.exitCode(); return process.exitCode();
} }
int chrootCall( const QString& command,
const QString& stdInput,
int timeoutSec )
{
return chrootCall( QStringList() = { command },
stdInput,
timeoutSec );
}
} }

View File

@ -44,6 +44,10 @@ DLLEXPORT int mount( const QString& devicePath,
* -3 = bad arguments * -3 = bad arguments
* -4 = QProcess timeout * -4 = QProcess timeout
*/ */
DLLEXPORT int chrootCall( const QStringList& args,
const QString& stdInput = QString(),
int timeoutSec = 0 );
DLLEXPORT int chrootCall( const QString& command, DLLEXPORT int chrootCall( const QString& command,
const QString& stdInput = QString(), const QString& stdInput = QString(),
int timeoutSec = 0 ); int timeoutSec = 0 );