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

@ -130,5 +130,12 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
Calamares::JobQueue::instance()->globalStorage()->insert( "autologinGroup",
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
- wheel
- audio
autologinGroup: autologin
autologinGroup: autologin
sudoersGroup: wheel

Loading…
Cancel
Save