diff --git a/src/modules/machineid/Workers.cpp b/src/modules/machineid/Workers.cpp index e7d5eb03f..6b55f2489 100644 --- a/src/modules/machineid/Workers.cpp +++ b/src/modules/machineid/Workers.cpp @@ -29,16 +29,34 @@ namespace MachineId { +static inline bool +isAbsolutePath( const QString& fileName ) +{ + return fileName.startsWith( '/' ); +} + // might need to use a helper to remove the file void removeFile( const QString& rootMountPoint, const QString& fileName ) { - QFile::remove( rootMountPoint + fileName ); + if ( isAbsolutePath( fileName ) ) + { + QFile::remove( rootMountPoint + fileName ); + } + // Otherwise, do nothing } Calamares::JobResult copyFile( const QString& rootMountPoint, const QString& fileName ) { + if ( !isAbsolutePath( fileName ) ) + { + return Calamares::JobResult::internalError( + QObject::tr( "File not found" ), + QObject::tr( "Path
%1
must be an absolute path." ).arg( fileName ), + 0 ); + } + QFile f( fileName ); if ( !f.exists() ) {