[preservefiles] [users] Use the Permissions methods
- don't call out to tools (executables) when we have an API for it (which might call out to those tools, but that's abstracted)
This commit is contained in:
parent
59dff815fc
commit
90a0605f38
@ -157,26 +157,9 @@ PreserveFiles::exec()
|
|||||||
{
|
{
|
||||||
if ( it.perm.isValid() )
|
if ( it.perm.isValid() )
|
||||||
{
|
{
|
||||||
auto s_p = CalamaresUtils::System::instance();
|
if ( !it.perm.apply( CalamaresUtils::System::instance()->targetPath( bare_dest ) ) )
|
||||||
|
|
||||||
int r;
|
|
||||||
|
|
||||||
r = s_p->targetEnvCall( QStringList { "chown", it.perm.username(), bare_dest } );
|
|
||||||
if ( r )
|
|
||||||
{
|
{
|
||||||
cWarning() << "Could not chown target" << bare_dest;
|
cWarning() << "Could not set attributes of" << bare_dest;
|
||||||
}
|
|
||||||
|
|
||||||
r = s_p->targetEnvCall( QStringList { "chgrp", it.perm.group(), bare_dest } );
|
|
||||||
if ( r )
|
|
||||||
{
|
|
||||||
cWarning() << "Could not chgrp target" << bare_dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = s_p->targetEnvCall( QStringList { "chmod", it.perm.octal(), bare_dest } );
|
|
||||||
if ( r )
|
|
||||||
{
|
|
||||||
cWarning() << "Could not chmod target" << bare_dest;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Permissions.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@ -103,7 +104,7 @@ CreateUserJob::exec()
|
|||||||
|
|
||||||
if ( fileResult )
|
if ( fileResult )
|
||||||
{
|
{
|
||||||
if ( QProcess::execute( "chmod", { "440", fileResult.path() } ) )
|
if ( CalamaresUtils::Permissions::apply( fileResult.path(), 0440 ) )
|
||||||
{
|
{
|
||||||
return Calamares::JobResult::error( tr( "Cannot chmod sudoers file." ) );
|
return Calamares::JobResult::error( tr( "Cannot chmod sudoers file." ) );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user