chroot calls are now generic "target env" calls.

main
Teo Mrnjavac 9 years ago
parent da79082b13
commit bf885d65db

@ -69,7 +69,7 @@ ProcessJob::exec()
int ec = 0;
QString output;
if ( m_runInChroot )
ec = CalamaresUtils::chrootOutput( m_command,
ec = CalamaresUtils::targetEnvOutput( m_command,
output,
m_workingPath,
QString(),

@ -37,23 +37,23 @@ namespace bp = boost::python;
BOOST_PYTHON_FUNCTION_OVERLOADS( mount_overloads,
CalamaresPython::mount,
2, 4 );
BOOST_PYTHON_FUNCTION_OVERLOADS( chroot_call_str_overloads,
CalamaresPython::chroot_call,
BOOST_PYTHON_FUNCTION_OVERLOADS( target_env_call_str_overloads,
CalamaresPython::target_env_call,
1, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( chroot_call_list_overloads,
CalamaresPython::chroot_call,
BOOST_PYTHON_FUNCTION_OVERLOADS( target_env_call_list_overloads,
CalamaresPython::target_env_call,
1, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( check_chroot_call_str_overloads,
CalamaresPython::check_chroot_call,
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_call_str_overloads,
CalamaresPython::check_target_env_call,
1, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( check_chroot_call_list_overloads,
CalamaresPython::check_chroot_call,
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_call_list_overloads,
CalamaresPython::check_target_env_call,
1, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( check_chroot_output_str_overloads,
CalamaresPython::check_chroot_output,
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_output_str_overloads,
CalamaresPython::check_target_env_output,
1, 3 );
BOOST_PYTHON_FUNCTION_OVERLOADS( check_chroot_output_list_overloads,
CalamaresPython::check_chroot_output,
BOOST_PYTHON_FUNCTION_OVERLOADS( check_target_env_output_list_overloads,
CalamaresPython::check_target_env_output,
1, 3 );
BOOST_PYTHON_MODULE( libcalamares )
{
@ -115,11 +115,11 @@ BOOST_PYTHON_MODULE( libcalamares )
)
);
bp::def(
"chroot_call",
"target_env_call",
static_cast< int (*)( const std::string&,
const std::string&,
int ) >( &CalamaresPython::chroot_call ),
chroot_call_str_overloads(
int ) >( &CalamaresPython::target_env_call ),
target_env_call_str_overloads(
bp::args( "command",
"stdin",
"timeout" ),
@ -132,11 +132,11 @@ BOOST_PYTHON_MODULE( libcalamares )
)
);
bp::def(
"chroot_call",
"target_env_call",
static_cast< int (*)( const bp::list&,
const std::string&,
int ) >( &CalamaresPython::chroot_call ),
chroot_call_list_overloads(
int ) >( &CalamaresPython::target_env_call ),
target_env_call_list_overloads(
bp::args( "args",
"stdin",
"timeout" ),
@ -150,11 +150,11 @@ BOOST_PYTHON_MODULE( libcalamares )
);
bp::def(
"check_chroot_call",
"check_target_env_call",
static_cast< int (*)( const std::string&,
const std::string&,
int ) >( &CalamaresPython::check_chroot_call ),
check_chroot_call_str_overloads(
int ) >( &CalamaresPython::check_target_env_call ),
check_target_env_call_str_overloads(
bp::args( "command",
"stdin",
"timeout" ),
@ -164,11 +164,11 @@ BOOST_PYTHON_MODULE( libcalamares )
)
);
bp::def(
"check_chroot_call",
"check_target_env_call",
static_cast< int (*)( const bp::list&,
const std::string&,
int ) >( &CalamaresPython::check_chroot_call ),
check_chroot_call_list_overloads(
int ) >( &CalamaresPython::check_target_env_call ),
check_target_env_call_list_overloads(
bp::args( "args",
"stdin",
"timeout" ),
@ -179,11 +179,11 @@ BOOST_PYTHON_MODULE( libcalamares )
);
bp::def(
"check_chroot_output",
"check_target_env_output",
static_cast< std::string (*)( const std::string&,
const std::string&,
int ) >( &CalamaresPython::check_chroot_output ),
check_chroot_output_str_overloads(
int ) >( &CalamaresPython::check_target_env_output ),
check_target_env_output_str_overloads(
bp::args( "command",
"stdin",
"timeout" ),
@ -193,11 +193,11 @@ BOOST_PYTHON_MODULE( libcalamares )
)
);
bp::def(
"check_chroot_output",
"check_target_env_output",
static_cast< std::string (*)( const bp::list&,
const std::string&,
int ) >( &CalamaresPython::check_chroot_output ),
check_chroot_output_list_overloads(
int ) >( &CalamaresPython::check_target_env_output ),
check_target_env_output_list_overloads(
bp::args( "args",
"stdin",
"timeout" ),

@ -46,11 +46,11 @@ mount( const std::string& device_path,
int
chroot_call( const std::string& command,
target_env_call( const std::string& command,
const std::string& stdin,
int timeout )
{
return CalamaresUtils::chrootCall( QString::fromStdString( command ),
return CalamaresUtils::targetEnvCall( QString::fromStdString( command ),
QString(),
QString::fromStdString( stdin ),
timeout );
@ -58,7 +58,7 @@ chroot_call( const std::string& command,
int
chroot_call( const bp::list& args,
target_env_call( const bp::list& args,
const std::string& stdin,
int timeout )
{
@ -69,7 +69,7 @@ chroot_call( const bp::list& args,
bp::extract< std::string >( args[ i ] ) ) );
}
return CalamaresUtils::chrootCall( list,
return CalamaresUtils::targetEnvCall( list,
QString(),
QString::fromStdString( stdin ),
timeout );
@ -77,21 +77,21 @@ chroot_call( const bp::list& args,
int
check_chroot_call( const std::string& command,
check_target_env_call( const std::string& command,
const std::string& stdin,
int timeout )
{
int ec = chroot_call( command, stdin, timeout );
return _handle_check_chroot_call_error( ec, QString::fromStdString( command ) );
int ec = target_env_call( command, stdin, timeout );
return _handle_check_target_env_call_error( ec, QString::fromStdString( command ) );
}
int
check_chroot_call( const bp::list& args,
check_target_env_call( const bp::list& args,
const std::string& stdin,
int timeout )
{
int ec = chroot_call( args, stdin, timeout );
int ec = target_env_call( args, stdin, timeout );
if ( !ec )
return ec;
@ -102,28 +102,28 @@ check_chroot_call( const bp::list& args,
bp::extract< std::string >( args[ i ] ) ) );
}
return _handle_check_chroot_call_error( ec, failedCmdList.join( ' ' ) );
return _handle_check_target_env_call_error( ec, failedCmdList.join( ' ' ) );
}
std::string
check_chroot_output( const std::string& command,
check_target_env_output( const std::string& command,
const std::string& stdin,
int timeout )
{
QString output;
int ec = CalamaresUtils::chrootOutput( QString::fromStdString( command ),
int ec = CalamaresUtils::targetEnvOutput( QString::fromStdString( command ),
output,
QString(),
QString::fromStdString( stdin ),
timeout );
_handle_check_chroot_call_error( ec, QString::fromStdString( command ) );
_handle_check_target_env_call_error( ec, QString::fromStdString( command ) );
return output.toStdString();
}
std::string
check_chroot_output( const bp::list& args,
check_target_env_output( const bp::list& args,
const std::string& stdin,
int timeout )
{
@ -135,18 +135,18 @@ check_chroot_output( const bp::list& args,
bp::extract< std::string >( args[ i ] ) ) );
}
int ec = CalamaresUtils::chrootOutput( list,
int ec = CalamaresUtils::targetEnvOutput( list,
output,
QString(),
QString::fromStdString( stdin ),
timeout );
_handle_check_chroot_call_error( ec, list.join( ' ' ) );
_handle_check_target_env_call_error( ec, list.join( ' ' ) );
return output.toStdString();
}
int
_handle_check_chroot_call_error( int ec, const QString& cmd )
_handle_check_target_env_call_error( int ec, const QString& cmd )
{
if ( !ec )
return ec;

@ -34,32 +34,32 @@ int mount( const std::string& device_path,
const std::string& filesystem_name = std::string(),
const std::string& options = std::string() );
int chroot_call( const std::string& command,
int target_env_call( const std::string& command,
const std::string& stdin = std::string(),
int timeout = 0 );
int chroot_call( const boost::python::list& args,
int target_env_call( const boost::python::list& args,
const std::string& stdin = std::string(),
int timeout = 0 );
int check_chroot_call( const std::string& command,
int check_target_env_call( const std::string& command,
const std::string& stdin = std::string(),
int timeout = 0 );
int check_chroot_call( const boost::python::list& args,
int check_target_env_call( const boost::python::list& args,
const std::string& stdin = std::string(),
int timeout = 0 );
std::string check_chroot_output( const std::string& command,
std::string check_target_env_output( const std::string& command,
const std::string& stdin = std::string(),
int timeout = 0 );
std::string check_chroot_output( const boost::python::list& args,
std::string check_target_env_output( const boost::python::list& args,
const std::string& stdin = std::string(),
int timeout = 0 );
inline int _handle_check_chroot_call_error( int ec, const QString& cmd );
inline int _handle_check_target_env_call_error( int ec, const QString& cmd );
void debug( const std::string& s );

@ -59,13 +59,13 @@ mount( const QString& devicePath,
}
int
chrootCall( const QStringList& args,
targetEnvCall( const QStringList& args,
const QString& workingPath,
const QString& stdInput,
int timeoutSec )
{
QString discard;
return chrootOutput( args,
return targetEnvOutput( args,
discard,
workingPath,
stdInput,
@ -74,12 +74,12 @@ chrootCall( const QStringList& args,
int
chrootCall( const QString& command,
targetEnvCall( const QString& command,
const QString& workingPath,
const QString& stdInput,
int timeoutSec )
{
return chrootCall( QStringList{ command },
return targetEnvCall( QStringList{ command },
workingPath,
stdInput,
timeoutSec );
@ -87,7 +87,7 @@ chrootCall( const QString& command,
int
chrootOutput( const QStringList& args,
targetEnvOutput( const QStringList& args,
QString& output,
const QString& workingPath,
const QString& stdInput,
@ -165,13 +165,13 @@ chrootOutput( const QStringList& args,
int
chrootOutput( const QString& command,
targetEnvOutput( const QString& command,
QString& output,
const QString& workingPath,
const QString& stdInput,
int timeoutSec )
{
return chrootOutput( QStringList{ command },
return targetEnvOutput( QStringList{ command },
output,
workingPath,
stdInput,

@ -44,23 +44,23 @@ DLLEXPORT int mount( const QString& devicePath,
* -3 = bad arguments
* -4 = QProcess timeout
*/
DLLEXPORT int chrootCall( const QStringList& args,
DLLEXPORT int targetEnvCall( const QStringList& args,
const QString& workingPath = QString(),
const QString& stdInput = QString(),
int timeoutSec = 0 );
DLLEXPORT int chrootCall( const QString& command,
DLLEXPORT int targetEnvCall( const QString& command,
const QString& workingPath = QString(),
const QString& stdInput = QString(),
int timeoutSec = 0 );
DLLEXPORT int chrootOutput( const QStringList& args,
DLLEXPORT int targetEnvOutput( const QStringList& args,
QString& output,
const QString& workingPath = QString(),
const QString& stdInput = QString(),
int timeoutSec = 0 );
DLLEXPORT int chrootOutput( const QString& command,
DLLEXPORT int targetEnvOutput( const QString& command,
QString& output,
const QString& workingPath = QString(),
const QString& stdInput = QString(),

@ -57,11 +57,11 @@ SetTimezoneJob::exec()
tr( "Bad path: %1" ).arg( zoneFile.absolutePath() ) );
// Make sure /etc/localtime doesn't exist, otherwise symlinking will fail
CalamaresUtils::chrootCall( { "rm",
CalamaresUtils::targetEnvCall( { "rm",
"-f",
localtimeSlink } );
int ec = CalamaresUtils::chrootCall( { "ln",
int ec = CalamaresUtils::targetEnvCall( { "ln",
"-s",
zoneinfoPath,
localtimeSlink } );

@ -108,7 +108,7 @@ CreateUserJob::exec()
foreach ( const QString& group, m_defaultGroups )
if ( !groupsLines.contains( group ) )
CalamaresUtils::chrootCall( { "groupadd", group } );
CalamaresUtils::targetEnvCall( { "groupadd", group } );
QString defaultGroups = m_defaultGroups.join( ',' );
if ( m_autologin )
@ -120,11 +120,11 @@ CreateUserJob::exec()
else
autologinGroup = QStringLiteral( "autologin" );
CalamaresUtils::chrootCall( { "groupadd", autologinGroup } );
CalamaresUtils::targetEnvCall( { "groupadd", autologinGroup } );
defaultGroups.append( QString( ",%1" ).arg( autologinGroup ) );
}
int ec = CalamaresUtils::chrootCall( { "useradd",
int ec = CalamaresUtils::targetEnvCall( { "useradd",
"-m",
"-s",
"/bin/bash",
@ -139,14 +139,14 @@ CreateUserJob::exec()
tr( "useradd terminated with error code %1." )
.arg( ec ) );
ec = CalamaresUtils::chrootCall( { "chfn", "-f", m_fullName, m_userName } );
ec = CalamaresUtils::targetEnvCall( { "chfn", "-f", m_fullName, m_userName } );
if ( ec )
return Calamares::JobResult::error( tr( "Cannot set full name for user %1." )
.arg( m_userName ),
tr( "chfn terminated with error code %1." )
.arg( ec ) );
ec = CalamaresUtils::chrootCall( { "chown",
ec = CalamaresUtils::targetEnvCall( { "chown",
"-R",
QString( "%1:%2" ).arg( m_userName )
.arg( m_userGroup ),

@ -61,7 +61,7 @@ SetPasswordJob::exec()
QByteArray data = crypt( m_newPassword.toLatin1(), QString( "$6$%1$" ).arg( m_userName ).toLatin1() );
int ec = CalamaresUtils::chrootCall( { "usermod",
int ec = CalamaresUtils::targetEnvCall( { "usermod",
"-p",
QString::fromLatin1( data ),
m_userName } );

Loading…
Cancel
Save