[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)
main
Adriaan de Groot 5 years ago
parent 59dff815fc
commit 90a0605f38

@ -157,26 +157,9 @@ PreserveFiles::exec()
{
if ( it.perm.isValid() )
{
auto s_p = CalamaresUtils::System::instance();
int r;
r = s_p->targetEnvCall( QStringList { "chown", it.perm.username(), bare_dest } );
if ( r )
{
cWarning() << "Could not chown target" << 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 )
if ( !it.perm.apply( CalamaresUtils::System::instance()->targetPath( bare_dest ) ) )
{
cWarning() << "Could not chmod target" << bare_dest;
cWarning() << "Could not set attributes of" << bare_dest;
}
}

@ -12,6 +12,7 @@
#include "JobQueue.h"
#include "utils/CalamaresUtilsSystem.h"
#include "utils/Logger.h"
#include "utils/Permissions.h"
#include <QDateTime>
#include <QDir>
@ -103,7 +104,7 @@ CreateUserJob::exec()
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." ) );
}

Loading…
Cancel
Save