Only add wheel to sudoers if a wheel group is defined in conf.

main
Teo Mrnjavac 10 years ago
parent ad68ce0187
commit 9e84581354

@ -57,20 +57,27 @@ CreateUserJob::exec()
{ {
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
QDir destDir( gs->value( "rootMountPoint" ).toString() ); QDir destDir( gs->value( "rootMountPoint" ).toString() );
QFileInfo sudoersFi( destDir.absoluteFilePath( "etc/sudoers.d/10-installer" ) );
if ( !sudoersFi.absoluteDir().exists() ) if ( gs->contains( "sudoersGroup" ) &&
return Calamares::JobResult::error( tr( "Sudoers dir is not writable." ) ); !gs->value( "sudoersGroup" ).toString().isEmpty() )
{
QFileInfo sudoersFi( destDir.absoluteFilePath( "etc/sudoers.d/10-installer" ) );
if ( !sudoersFi.absoluteDir().exists() )
return Calamares::JobResult::error( tr( "Sudoers dir is not writable." ) );
QFile sudoersFile( sudoersFi.absoluteFilePath() ); QFile sudoersFile( sudoersFi.absoluteFilePath() );
if (!sudoersFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) if (!sudoersFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
return Calamares::JobResult::error( tr( "Cannot create sudoers file for writing." ) ); return Calamares::JobResult::error( tr( "Cannot create sudoers file for writing." ) );
QTextStream sudoersOut( &sudoersFile ); QString sudoersGroup = gs->value( "sudoersGroup" ).toString();
sudoersOut << QString( "%1 ALL=(ALL) ALL\n" ).arg( m_userName );
if ( QProcess::execute( "chmod", { "440", sudoersFi.absoluteFilePath() } ) ) QTextStream sudoersOut( &sudoersFile );
return Calamares::JobResult::error( tr( "Cannot chmod sudoers file." ) ); sudoersOut << QString( "%%1 ALL=(ALL) ALL\n" ).arg( sudoersGroup );
if ( QProcess::execute( "chmod", { "440", sudoersFi.absoluteFilePath() } ) )
return Calamares::JobResult::error( tr( "Cannot chmod sudoers file." ) );
}
QFileInfo groupsFi( destDir.absoluteFilePath( "etc/group" ) ); QFileInfo groupsFi( destDir.absoluteFilePath( "etc/group" ) );
QFile groupsFile( groupsFi.absoluteFilePath() ); QFile groupsFile( groupsFi.absoluteFilePath() );

@ -130,5 +130,12 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
Calamares::JobQueue::instance()->globalStorage()->insert( "autologinGroup", Calamares::JobQueue::instance()->globalStorage()->insert( "autologinGroup",
configurationMap.value( "autologinGroup" ).toString() ); configurationMap.value( "autologinGroup" ).toString() );
} }
if ( configurationMap.contains( "sudoersGroup" ) &&
configurationMap.value( "sudoersGroup" ).type() == QVariant::String )
{
Calamares::JobQueue::instance()->globalStorage()->insert( "sudoersGroup",
configurationMap.value( "sudoersGroup" ).toString() );
}
} }

@ -7,4 +7,5 @@ defaultGroups:
- storage - storage
- wheel - wheel
- audio - audio
autologinGroup: autologin autologinGroup: autologin
sudoersGroup: wheel

Loading…
Cancel
Save