Commit 94dd2c20 authored by Jérome Perrin's avatar Jérome Perrin

fixup! trun: Spawn user test with sole regular uid/gid in /etc/{passwd,group} database

parent 2bb7dc04
Pipeline #18741 passed with stage
in 0 seconds
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
# verify general functionality # verify general functionality
import grp
import os import os
import pwd
import sys import sys
import re import re
import time import time
...@@ -261,6 +263,26 @@ TestCase('TESTCASE', ['mount', '-t', 'tmpfs', 'none', '/etc']) ...@@ -261,6 +263,26 @@ TestCase('TESTCASE', ['mount', '-t', 'tmpfs', 'none', '/etc'])
assert "# leaked mount: none /etc tmpfs" in captured.out assert "# leaked mount: none /etc tmpfs" in captured.out
# verify user mapping
def test_run_usermap(run_nxdtest, capsys):
tdumpusergroups = "%s/testprog/tdumpusergroups" % (dirname(__file__),)
run_nxdtest(
"""
TestCase('TESTCASE', %r)
""" % [tdumpusergroups])
captured = capsys.readouterr()
assert captured.err == ''
assert repr(pwd.getpwnam('root')) in captured.out.splitlines()
assert repr(pwd.getpwnam('nobody')) in captured.out.splitlines()
assert repr(pwd.getpwuid(os.getuid())) in captured.out.splitlines()
assert repr(grp.getgrnam('root')) in captured.out.splitlines()
assert repr(grp.getgrnam('nogroup')) in captured.out.splitlines()
assert repr(grp.getgrgid(os.getgid())) in captured.out.splitlines()
# verify that inside environment, that nxdtest creates, file permissions are # verify that inside environment, that nxdtest creates, file permissions are
# still respected. # still respected.
def test_run_writero(run_nxdtest, capsys): def test_run_writero(run_nxdtest, capsys):
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2021 Nexedi SA and Contributors.
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""Program tdumpusergroups helps to verify that nxdtest maps users and groups
in namespace."""
from __future__ import absolute_import, print_function
import grp
import pwd
import sys
def main():
for u in sorted(pwd.getpwall()):
print(repr(u))
for g in sorted(grp.getgrall()):
print(repr(g))
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment