[calamares] Allow disabling the Python pre-script
The test-application injects a script into Python code to render harmless functions in the subprocess module (eg to avoid Python code from running the package manager for real). There are cases, though, where that injection should be skipped (eg because the whole point of test- loading some Python is to check commands that are run). Add a -P option to the test-application to do that.
This commit is contained in:
parent
a86ffd105a
commit
5d54a08581
@ -62,6 +62,7 @@ struct ModuleConfig
|
|||||||
QString m_language;
|
QString m_language;
|
||||||
QString m_branding;
|
QString m_branding;
|
||||||
bool m_ui;
|
bool m_ui;
|
||||||
|
bool m_pythonInjection;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ModuleConfig
|
static ModuleConfig
|
||||||
@ -86,7 +87,6 @@ handle_args( QCoreApplication& a )
|
|||||||
QStringLiteral( "Enable UI" ) );
|
QStringLiteral( "Enable UI" ) );
|
||||||
QCommandLineOption slideshowOption( QStringList() << QStringLiteral( "s" ) << QStringLiteral( "slideshow" ),
|
QCommandLineOption slideshowOption( QStringList() << QStringLiteral( "s" ) << QStringLiteral( "slideshow" ),
|
||||||
QStringLiteral( "Run slideshow module" ) );
|
QStringLiteral( "Run slideshow module" ) );
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription( "Calamares module tester" );
|
parser.setApplicationDescription( "Calamares module tester" );
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
@ -99,6 +99,12 @@ handle_args( QCoreApplication& a )
|
|||||||
parser.addOption( brandOption );
|
parser.addOption( brandOption );
|
||||||
parser.addOption( uiOption );
|
parser.addOption( uiOption );
|
||||||
parser.addOption( slideshowOption );
|
parser.addOption( slideshowOption );
|
||||||
|
#ifdef WITH_PYTHON
|
||||||
|
QCommandLineOption pythonOption( QStringList() << QStringLiteral( "P" ) << QStringLiteral( "no-injected-python" ),
|
||||||
|
QStringLiteral( "Do not disable potentially-harmful Python commands" ) );
|
||||||
|
parser.addOption( pythonOption );
|
||||||
|
#endif
|
||||||
|
|
||||||
parser.addPositionalArgument( "module", "Path or name of module to run." );
|
parser.addPositionalArgument( "module", "Path or name of module to run." );
|
||||||
parser.addPositionalArgument( "job.yaml", "Path of job settings document to use.", "[job.yaml]" );
|
parser.addPositionalArgument( "job.yaml", "Path of job settings document to use.", "[job.yaml]" );
|
||||||
|
|
||||||
@ -123,12 +129,21 @@ handle_args( QCoreApplication& a )
|
|||||||
jobSettings = args.at( 1 );
|
jobSettings = args.at( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pythonInjection = true;
|
||||||
|
#ifdef WITH_PYTHON
|
||||||
|
if ( parser.isSet( pythonOption ) )
|
||||||
|
{
|
||||||
|
pythonInjection = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return ModuleConfig { parser.isSet( slideshowOption ) ? QStringLiteral( "-" ) : args.first(),
|
return ModuleConfig { parser.isSet( slideshowOption ) ? QStringLiteral( "-" ) : args.first(),
|
||||||
jobSettings,
|
jobSettings,
|
||||||
parser.value( globalOption ),
|
parser.value( globalOption ),
|
||||||
parser.value( langOption ),
|
parser.value( langOption ),
|
||||||
parser.value( brandOption ),
|
parser.value( brandOption ),
|
||||||
parser.isSet( slideshowOption ) || parser.isSet( uiOption ) };
|
parser.isSet( slideshowOption ) || parser.isSet( uiOption ),
|
||||||
|
pythonInjection
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +445,10 @@ main( int argc, char* argv[] )
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
|
if ( module.m_pythonInjection )
|
||||||
|
{
|
||||||
Calamares::PythonJob::setInjectedPreScript(pythonPreScript);
|
Calamares::PythonJob::setInjectedPreScript(pythonPreScript);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_QML
|
#ifdef WITH_QML
|
||||||
CalamaresUtils::initQmlModulesDir(); // don't care if failed
|
CalamaresUtils::initQmlModulesDir(); // don't care if failed
|
||||||
|
Loading…
Reference in New Issue
Block a user