[users] Ensure UMASK= gets a leading 0 if needed
This commit is contained in:
parent
a93dc7740c
commit
3614fd003d
@ -70,7 +70,8 @@ createUser( const QString& loginName, const QString& fullName, const QString& sh
|
||||
useraddCommand << "-c" << fullName;
|
||||
if ( umask >= 0 )
|
||||
{
|
||||
useraddCommand << "-K" << ( QStringLiteral( "UMASK=" ) + QString::number( umask, 8 ) );
|
||||
// The QChar() is needed to disambiguate from the overload that takes a double
|
||||
useraddCommand << "-K" << ( QStringLiteral( "UMASK=%1" ).arg( umask, 3, 8, QChar( '0' ) ) );
|
||||
}
|
||||
useraddCommand << loginName;
|
||||
#endif
|
||||
|
@ -519,15 +519,17 @@ UserTests::testUserUmask_data()
|
||||
QTest::addColumn< QString >( "filename" );
|
||||
QTest::addColumn< int >( "permission" );
|
||||
QTest::addColumn< int >( "umask" );
|
||||
QTest::addColumn< QString >( "umask_string" );
|
||||
|
||||
QTest::newRow( "good " ) << "tests/8a-issue-2362.conf" << 0700 << 0077;
|
||||
QTest::newRow( "open " ) << "tests/8b-issue-2362.conf" << 0755 << 0022;
|
||||
QTest::newRow( "weird" ) << "tests/8c-issue-2362.conf" << 0126 << 0651;
|
||||
QTest::newRow( "rwxx " ) << "tests/8d-issue-2362.conf" << 0710 << 0067;
|
||||
QTest::newRow( "-wrd " ) << "tests/8e-issue-2362.conf" << 0214 << 0563;
|
||||
QTest::newRow( "bogus" ) << "tests/8f-issue-2362.conf" << -1 << -1;
|
||||
QTest::newRow( "good2" ) << "tests/8g-issue-2362.conf" << 0750 << 0027;
|
||||
QTest::newRow( "numrc" ) << "tests/8h-issue-2362.conf" << 0751 << 0026;
|
||||
QTest::newRow( "good " ) << "tests/8a-issue-2362.conf" << 0700 << 0077 << QStringLiteral( "077" );
|
||||
QTest::newRow( "open " ) << "tests/8b-issue-2362.conf" << 0755 << 0022 << QStringLiteral( "022" );
|
||||
QTest::newRow( "weird" ) << "tests/8c-issue-2362.conf" << 0126 << 0651 << QStringLiteral( "651" );
|
||||
QTest::newRow( "rwxx " ) << "tests/8d-issue-2362.conf" << 0710 << 0067 << QStringLiteral( "067" );
|
||||
QTest::newRow( "-wrd " ) << "tests/8e-issue-2362.conf" << 0214 << 0563 << QStringLiteral( "563" );
|
||||
QTest::newRow( "bogus" ) << "tests/8f-issue-2362.conf" << -1 << -1
|
||||
<< QStringLiteral( "-01" ); // Bogus 3-character representation
|
||||
QTest::newRow( "good2" ) << "tests/8g-issue-2362.conf" << 0750 << 0027 << QStringLiteral( "027" );
|
||||
QTest::newRow( "numrc" ) << "tests/8h-issue-2362.conf" << 0751 << 0026 << QStringLiteral( "026" );
|
||||
}
|
||||
|
||||
void
|
||||
@ -550,6 +552,7 @@ UserTests::testUserUmask()
|
||||
QFETCH( QString, filename );
|
||||
QFETCH( int, permission );
|
||||
QFETCH( int, umask );
|
||||
QFETCH( QString, umask_string );
|
||||
|
||||
// Checks that the test-data is valid
|
||||
if ( permission != -1 )
|
||||
@ -572,6 +575,8 @@ UserTests::testUserUmask()
|
||||
|
||||
QCOMPARE( c.homePermissions(), permission );
|
||||
QCOMPARE( c.homeUMask(), umask );
|
||||
// The QChar() is needed to disambiguate from the overload that takes a double
|
||||
QCOMPARE( QStringLiteral( "%1" ).arg( umask, 3, 8, QChar( '0' ) ), umask_string );
|
||||
|
||||
QCOMPARE( c.forbiddenLoginNames(), forbidden );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user