[users] Handle system-group creating specially
This commit is contained in:
parent
fa1d314b13
commit
03541470d5
@ -136,6 +136,24 @@ Config::setAutologinGroup( const QString& group )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
Config::groupsForThisUser() const
|
||||||
|
{
|
||||||
|
QStringList l;
|
||||||
|
l.reserve( defaultGroups().size() + 1 );
|
||||||
|
|
||||||
|
for ( const auto& g : defaultGroups() )
|
||||||
|
{
|
||||||
|
l << g.name();
|
||||||
|
}
|
||||||
|
if ( doAutoLogin() && !autologinGroup().isEmpty() )
|
||||||
|
{
|
||||||
|
l << autologinGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setSudoersGroup( const QString& group )
|
Config::setSudoersGroup( const QString& group )
|
||||||
{
|
{
|
||||||
|
@ -68,6 +68,7 @@ public:
|
|||||||
|
|
||||||
bool isValid() const { return m_isValid; }
|
bool isValid() const { return m_isValid; }
|
||||||
bool isSystemGroup() const { return m_isSystem; }
|
bool isSystemGroup() const { return m_isSystem; }
|
||||||
|
bool mustAlreadyExist() const { return m_mustAlreadyExist; }
|
||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
|
|
||||||
///@brief Equality of groups depends only on name and kind
|
///@brief Equality of groups depends only on name and kind
|
||||||
@ -213,6 +214,11 @@ public:
|
|||||||
bool requireStrongPasswords() const { return m_requireStrongPasswords; }
|
bool requireStrongPasswords() const { return m_requireStrongPasswords; }
|
||||||
|
|
||||||
const QList< GroupDescription >& defaultGroups() const { return m_defaultGroups; }
|
const QList< GroupDescription >& defaultGroups() const { return m_defaultGroups; }
|
||||||
|
/** @brief the names of all the groups for the current user
|
||||||
|
*
|
||||||
|
* Takes into account defaultGroups and autologin behavior.
|
||||||
|
*/
|
||||||
|
QStringList groupsForThisUser() const;
|
||||||
|
|
||||||
// The user enters a password (and again in a separate UI element)
|
// The user enters a password (and again in a separate UI element)
|
||||||
QString userPassword() const { return m_userPassword; }
|
QString userPassword() const { return m_userPassword; }
|
||||||
|
@ -112,7 +112,6 @@ ensureGroupsExistInTarget( const QList< GroupDescription >& wantedGroups,
|
|||||||
|
|
||||||
for ( const auto& group : wantedGroups )
|
for ( const auto& group : wantedGroups )
|
||||||
{
|
{
|
||||||
int groupaddResult = 0;
|
|
||||||
if ( group.isValid() && !availableGroups.contains( group.name() ) )
|
if ( group.isValid() && !availableGroups.contains( group.name() ) )
|
||||||
{
|
{
|
||||||
if ( group.mustAlreadyExist() )
|
if ( group.mustAlreadyExist() )
|
||||||
@ -122,13 +121,22 @@ ensureGroupsExistInTarget( const QList< GroupDescription >& wantedGroups,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList cmd;
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
groupaddResult
|
if ( group.isSystemGroup() )
|
||||||
= CalamaresUtils::System::instance()->targetEnvCall( { "pw", "groupadd", "-n", group.name() } );
|
{
|
||||||
|
cWarning() << "Ignoring must-be-a-system group for" << group.name() << "on FreeBSD";
|
||||||
|
}
|
||||||
|
cmd = QStringList { "pw", "groupadd", "-n", group.name() };
|
||||||
#else
|
#else
|
||||||
groupaddResult = CalamaresUtils::System::instance()->targetEnvCall( { "groupadd", group.name() } );
|
cmd << QStringLiteral( "groupadd" );
|
||||||
|
if ( group.isSystemGroup() )
|
||||||
|
{
|
||||||
|
cmd << "--system";
|
||||||
|
}
|
||||||
|
cmd << group.name();
|
||||||
#endif
|
#endif
|
||||||
if ( groupaddResult )
|
if ( CalamaresUtils::System::instance()->targetEnvCall( cmd ) )
|
||||||
{
|
{
|
||||||
failureCount++;
|
failureCount++;
|
||||||
missingGroups.append( group.name() + QChar( '*' ) );
|
missingGroups.append( group.name() + QChar( '*' ) );
|
||||||
|
Loading…
Reference in New Issue
Block a user