From e7e57689d8e27a60cf9f4cf15ea6f34f931b29c0 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 30 Jul 2014 12:43:15 +0200 Subject: [PATCH] Make sure chrootCall with args list actually passes the args as list. --- src/libcalamares/PythonJobApi.cpp | 3 ++- .../utils/CalamaresUtilsSystem.cpp | 18 +++++++++++++++--- src/libcalamares/utils/CalamaresUtilsSystem.h | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/libcalamares/PythonJobApi.cpp b/src/libcalamares/PythonJobApi.cpp index af972082a..4e302e1b4 100644 --- a/src/libcalamares/PythonJobApi.cpp +++ b/src/libcalamares/PythonJobApi.cpp @@ -66,7 +66,8 @@ chroot_call( const boost::python::list& args, list.append( QString::fromStdString( boost::python::extract< std::string >( args[ i ] ) ) ); } - return CalamaresUtils::chrootCall( list.join( ' ' ), + + return CalamaresUtils::chrootCall( list, QString::fromStdString( stdin ), timeout ); } diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index 86115293f..92b795fa7 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -55,7 +55,7 @@ int mount( const QString& devicePath, return QProcess::execute( program, args ); } -int chrootCall( const QString& command, +int chrootCall( const QStringList& args, const QString& stdInput, int timeoutSec ) { @@ -68,11 +68,12 @@ int chrootCall( const QString& command, return -3; QString program( "chroot" ); - QStringList args = { destDir, command }; + QStringList arguments = { destDir }; + arguments << args; QProcess process; process.setProgram( program ); - process.setArguments( args ); + process.setArguments( arguments ); if ( !process.waitForStarted() ) return -2; @@ -92,4 +93,15 @@ int chrootCall( const QString& command, return process.exitCode(); } + +int chrootCall( const QString& command, + const QString& stdInput, + int timeoutSec ) +{ + return chrootCall( QStringList() = { command }, + stdInput, + timeoutSec ); +} + + } diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.h b/src/libcalamares/utils/CalamaresUtilsSystem.h index d268892b0..901329cc6 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.h +++ b/src/libcalamares/utils/CalamaresUtilsSystem.h @@ -44,6 +44,10 @@ DLLEXPORT int mount( const QString& devicePath, * -3 = bad arguments * -4 = QProcess timeout */ +DLLEXPORT int chrootCall( const QStringList& args, + const QString& stdInput = QString(), + int timeoutSec = 0 ); + DLLEXPORT int chrootCall( const QString& command, const QString& stdInput = QString(), int timeoutSec = 0 );