[users] Expand tests and repair newly-acceptable cases

This commit is contained in:
Adriaan de Groot 2024-10-22 15:07:24 +02:00
parent 4ac0529d1c
commit c68c3632cc
8 changed files with 67 additions and 7 deletions

View File

@ -523,6 +523,10 @@ UserTests::testUserUmask_data()
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;
}
void
@ -531,7 +535,12 @@ UserTests::testUserUmask()
static constexpr int no_permissions = -1;
const QString old_shell = QStringLiteral( "/bin/ls" );
const QString new_shell = QStringLiteral( "/usr/bin/new" );
const QStringList forbidden { QStringLiteral( "me" ), QStringLiteral( "myself" ), QStringLiteral( "moi" ) };
// nobody and root are always forbidden, even if not mentioned in the config, entries are alphabetical
const QStringList forbidden { QStringLiteral( "me" ),
QStringLiteral( "moi" ),
QStringLiteral( "myself" ),
QStringLiteral( "nobody" ),
QStringLiteral( "root" ) };
Config c;
c.setUserShell( old_shell );
QCOMPARE( c.homePermissions(), no_permissions );
@ -541,8 +550,12 @@ UserTests::testUserUmask()
QFETCH( int, permission );
QFETCH( int, umask );
QCOMPARE( permission & umask, 0 );
QCOMPARE( permission | umask, 0777 );
// Checks that the test-data is valid
if ( permission != -1 )
{
QCOMPARE( permission & umask, 0 );
QCOMPARE( permission | umask, 0777 );
}
QFileInfo fi( QString( "%1/%2" ).arg( BUILD_AS_TEST, filename ) );
QVERIFY( fi.exists() );

View File

@ -8,4 +8,4 @@ user:
- me
- myself
- moi
home_permissions: "700"
home_permissions: "o700"

View File

@ -4,8 +4,10 @@
---
user:
shell: /usr/bin/new
# Order of names here doesn't matter (and "nobody" and "root" are always added)
forbidden_names:
- me
- myself
- moi
home_permissions: "755"
- me
- root
home_permissions: "o755"

View File

@ -8,4 +8,4 @@ user:
- me
- myself
- moi
home_permissions: "126"
home_permissions: "o126"

View File

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
user:
shell: /usr/bin/new
forbidden_names:
- me
- myself
- moi
home_permissions: rwx--x---

View File

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
user:
shell: /usr/bin/new
forbidden_names:
- me
- myself
- moi
home_permissions: -w---xr--

View File

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
user:
shell: /usr/bin/new
forbidden_names:
- me
- myself
- moi
home_permissions: Bogus

View File

@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
#
---
user:
shell: /usr/bin/new
forbidden_names:
- me
- myself
- moi
# This is a number, not a string, due to vagaries of YAML
home_permissions: "0750"