1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

CVE-2022-37966 python:/tests/krb5: call sys.path.insert(0, "bin/python") before any other imports

This allows the tests to be executed without an explicit
PYTHONPATH="bin/python".

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15237

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Dec 13 14:06:14 UTC 2022 on sn-devel-184

(similar to commit 987cba9057)
[jsutton@samba.org Fixed conflicts; removed changes to non-existent
 tests]

Autobuild-User(v4-16-test): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(v4-16-test): Wed Dec 14 11:34:00 UTC 2022 on sn-devel-184
This commit is contained in:
Stefan Metzmacher 2022-11-29 14:14:32 +01:00
parent 160e566d59
commit d5a8e41313
18 changed files with 64 additions and 56 deletions

View File

@ -20,6 +20,9 @@
import sys import sys
import os import os
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
import ldb import ldb
from samba.tests import delete_force from samba.tests import delete_force
@ -32,9 +35,6 @@ from samba.tests.krb5.rfc4120_constants import (
NT_PRINCIPAL, NT_PRINCIPAL,
) )
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -19,12 +19,13 @@
import sys import sys
import os import os
from enum import Enum, unique
import pyasn1
sys.path.insert(0, "bin/python") sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1" os.environ["PYTHONUNBUFFERED"] = "1"
from enum import Enum, unique
import pyasn1
from samba.tests.krb5.kdc_base_test import KDCBaseTest from samba.tests.krb5.kdc_base_test import KDCBaseTest
import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1 import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1
from samba.credentials import DONT_USE_KERBEROS from samba.credentials import DONT_USE_KERBEROS

View File

@ -17,10 +17,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import itertools
import sys import sys
import os import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
import itertools
from samba.dcerpc import security from samba.dcerpc import security
from samba.tests import DynamicTestCase from samba.tests import DynamicTestCase
@ -34,8 +38,6 @@ from samba.tests.krb5.rfc4120_constants import (
) )
import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1 import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -17,9 +17,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import functools
import os
import sys import sys
import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
import functools
import collections import collections
import ldb import ldb
@ -58,9 +62,6 @@ from samba.tests.krb5.rfc4120_constants import (
import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1 import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1
import samba.tests.krb5.kcrypto as kcrypto import samba.tests.krb5.kcrypto as kcrypto
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -18,6 +18,10 @@
import sys import sys
import os import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
from datetime import datetime, timezone from datetime import datetime, timezone
import tempfile import tempfile
import binascii import binascii
@ -91,9 +95,6 @@ from samba.tests.krb5.rfc4120_constants import (
PADATA_ETYPE_INFO2, PADATA_ETYPE_INFO2,
) )
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -17,8 +17,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import os
import sys import sys
import os
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
from functools import partial from functools import partial
@ -41,9 +44,6 @@ from samba.tests.krb5.rfc4120_constants import (
NT_SRV_INST, NT_SRV_INST,
) )
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -17,10 +17,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import sys
import os
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
from enum import Enum from enum import Enum
from functools import partial from functools import partial
import os
import sys
import time import time
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.backends import default_backend
@ -61,9 +65,6 @@ from samba.tests.krb5.rfc4120_constants import (
NT_SRV_INST, NT_SRV_INST,
) )
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -19,14 +19,14 @@
import sys import sys
import os import os
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
from samba.dcerpc import krb5pac from samba.dcerpc import krb5pac
from samba.ndr import ndr_unpack from samba.ndr import ndr_unpack
from samba.tests import DynamicTestCase from samba.tests import DynamicTestCase
from samba.tests.krb5.kdc_base_test import KDCBaseTest from samba.tests.krb5.kdc_base_test import KDCBaseTest
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -19,11 +19,11 @@
import sys import sys
import os import os
from samba.tests.krb5.kdc_base_test import KDCBaseTest
sys.path.insert(0, "bin/python") sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1" os.environ["PYTHONUNBUFFERED"] = "1"
from samba.tests.krb5.kdc_base_test import KDCBaseTest
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -18,11 +18,12 @@
import sys import sys
import os import os
import functools
sys.path.insert(0, "bin/python") sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1" os.environ["PYTHONUNBUFFERED"] = "1"
import functools
from samba import dsdb, ntstatus from samba import dsdb, ntstatus
from samba.dcerpc import krb5pac, lsa from samba.dcerpc import krb5pac, lsa

View File

@ -19,14 +19,14 @@
import sys import sys
import os import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
import ldb import ldb
from samba.tests.krb5.as_req_tests import AsReqBaseTest from samba.tests.krb5.as_req_tests import AsReqBaseTest
import samba.tests.krb5.kcrypto as kcrypto import samba.tests.krb5.kcrypto as kcrypto
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -17,8 +17,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
import os
import sys import sys
import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
from samba.tests import DynamicTestCase from samba.tests import DynamicTestCase
@ -33,9 +36,6 @@ from samba.tests.krb5.rfc4120_constants import (
NT_PRINCIPAL, NT_PRINCIPAL,
) )
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -20,6 +20,9 @@
import sys import sys
import os import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
import ldb import ldb
from ldb import SCOPE_SUBTREE from ldb import SCOPE_SUBTREE
@ -31,9 +34,6 @@ from samba.ntstatus import NT_STATUS_NO_IMPERSONATION_TOKEN
from samba.tests.krb5.kdc_base_test import KDCBaseTest from samba.tests.krb5.kdc_base_test import KDCBaseTest
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -20,6 +20,9 @@
import sys import sys
import os import os
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
from ldb import SCOPE_SUBTREE from ldb import SCOPE_SUBTREE
from samba import NTSTATUSError from samba import NTSTATUSError
from samba.credentials import DONT_USE_KERBEROS from samba.credentials import DONT_USE_KERBEROS
@ -34,9 +37,6 @@ from samba.samba3 import param as s3param
from samba.tests.krb5.kdc_base_test import KDCBaseTest from samba.tests.krb5.kdc_base_test import KDCBaseTest
sys.path.insert(0, 'bin/python')
os.environ['PYTHONUNBUFFERED'] = '1'
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -20,6 +20,9 @@
import sys import sys
import os import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
import ldb import ldb
from ldb import LdbError, ERR_OPERATIONS_ERROR, SCOPE_BASE, SCOPE_SUBTREE from ldb import LdbError, ERR_OPERATIONS_ERROR, SCOPE_BASE, SCOPE_SUBTREE
@ -30,9 +33,6 @@ from samba import credentials
from samba.tests.krb5.kdc_base_test import KDCBaseTest from samba.tests.krb5.kdc_base_test import KDCBaseTest
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -18,6 +18,10 @@
import sys import sys
import os import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
import pwd import pwd
import ctypes import ctypes
@ -29,9 +33,6 @@ from samba import NTSTATUSError, ntstatus
from samba.tests.krb5.kdc_base_test import KDCBaseTest from samba.tests.krb5.kdc_base_test import KDCBaseTest
from samba.credentials import MUST_USE_KERBEROS, DONT_USE_KERBEROS from samba.credentials import MUST_USE_KERBEROS, DONT_USE_KERBEROS
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
class SmbMinDomainUid(KDCBaseTest): class SmbMinDomainUid(KDCBaseTest):
"""Test for SMB authorization without NSS winbind. In such setup domain """Test for SMB authorization without NSS winbind. In such setup domain
accounts are mapped to local accounts using the 'username map' option. accounts are mapped to local accounts using the 'username map' option.

View File

@ -20,6 +20,9 @@
import sys import sys
import os import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
import ldb import ldb
from samba import NTSTATUSError, credentials from samba import NTSTATUSError, credentials
@ -31,9 +34,6 @@ from samba.ntstatus import (
from samba.tests.krb5.kdc_base_test import KDCBaseTest from samba.tests.krb5.kdc_base_test import KDCBaseTest
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False

View File

@ -20,6 +20,9 @@
import sys import sys
import os import os
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
import ldb import ldb
from ldb import SCOPE_SUBTREE from ldb import SCOPE_SUBTREE
@ -32,9 +35,6 @@ from samba.samba3 import param as s3param
from samba.tests.krb5.kdc_base_test import KDCBaseTest from samba.tests.krb5.kdc_base_test import KDCBaseTest
sys.path.insert(0, "bin/python")
os.environ["PYTHONUNBUFFERED"] = "1"
global_asn1_print = False global_asn1_print = False
global_hexdump = False global_hexdump = False