Only add wheel to sudoers if a wheel group is defined in conf.
This commit is contained in:
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" ) );
|
||||
|
||||
QFile sudoersFile( sudoersFi.absoluteFilePath() );
|
||||
if (!sudoersFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||
return Calamares::JobResult::error( tr( "Cannot create sudoers file for writing." ) );
|
||||
if ( !sudoersFi.absoluteDir().exists() )
|
||||
return Calamares::JobResult::error( tr( "Sudoers dir is not writable." ) );
|
||||
|
||||
QTextStream sudoersOut( &sudoersFile );
|
||||
sudoersOut << QString( "%1 ALL=(ALL) ALL\n" ).arg( m_userName );
|
||||
QFile sudoersFile( sudoersFi.absoluteFilePath() );
|
||||
if (!sudoersFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
|
||||
return Calamares::JobResult::error( tr( "Cannot create sudoers file for writing." ) );
|
||||
|
||||
if ( QProcess::execute( "chmod", { "440", sudoersFi.absoluteFilePath() } ) )
|
||||
return Calamares::JobResult::error( tr( "Cannot chmod sudoers file." ) );
|
||||
QString sudoersGroup = gs->value( "sudoersGroup" ).toString();
|
||||
|
||||
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…
Reference in New Issue
Block a user