summaryrefslogtreecommitdiff
path: root/python/samba/__init__.py
AgeCommit message (Collapse)AuthorFilesLines
2025-03-29python: make source_tree_topdir() test-onlyDouglas Bagnall1-10/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Ralph Boehme <slow@samba.org>
2025-03-29python: remove unused in_source_tree() functionDouglas Bagnall1-9/+0
We don't use it and don't want non-tests changing their behaviour based on this kind of thing anyway. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Ralph Boehme <slow@samba.org>
2024-10-23Add pyglue for Rust for disabling testsDavid Mulder1-0/+1
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2024-06-12python: remove string_to_byte_array()Douglas Bagnall1-4/+0
This was a useful function during the Python 2 -> 3 migration, but it is not used any more. In all the cases it was used, we knew we already had a bytes object, and this was just an inefficient way of confirming that. In cases where we actually want to cast a string into a mutable list of byte-sized ints, the builtin bytearray() function will do a better job than this, because it will encode high unicode characters as utf-8 bytes, rather than adding them as out-of-range values in the list. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Jun 12 09:16:39 UTC 2024 on atb-devel-224
2024-04-09python: Add aead_aes_256_cbc_hmac_sha512()Andreas Schneider1-0/+11
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-03-14python: Explain strange enable_net_export_keytab() behaviour is no longer ↵Andrew Bartlett1-2/+2
due Heimdal This code is now common between Heimdal and MIT Kerberos, but can still be missing for builds of "samba-tool" that do not include the whole AD DC. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
2024-02-29pylibs: add string_is_guid() helper.Douglas Bagnall1-0/+32
In various places we use regular expressions to check for GUID-ness, though typically we don't match GUIDs with uppercase hex digits when we really should. If we centralise the check, we have more chance of getting it right. Pair-programmed-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Feb 29 02:38:07 UTC 2024 on atb-devel-224
2024-01-15python: Generate HRESULT definitions automaticallyJoseph Sutton1-6/+0
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Joseph Sutton <jsutton@samba.org> Autobuild-Date(master): Mon Jan 15 01:56:53 UTC 2024 on atb-devel-224
2023-12-21pyglue: Export some more HRESULT constantsJoseph Sutton1-0/+3
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-11-30python: Use constants from hresult.h for python constantsAndrew Bartlett1-2/+2
This encourages us to keep a single source for constants. In the future this should be a generated python file like for ntstatus. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2023-11-30python: move HRES_SEC_* constants to samba moduleRob van der Linde1-0/+3
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-11-30python: fix missing colon around param in docstringRob van der Linde1-1/+1
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-30python: Remove unused importsJoseph Sutton1-1/+0
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba: Fix code spellingAndreas Schneider1-3/+3
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Fri Jun 23 14:51:14 UTC 2023 on atb-devel-224
2023-03-22python/samba: add support for LDB_CHANGETYPE_MODRDN to modify_ldif()Stefan Metzmacher1-0/+7
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-03-22python/samba: add support for LDB_CHANGETYPE_DELETE to modify_ldif()Stefan Metzmacher1-0/+3
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-03-22python/samba: let modify_ldif() verify the changetype valueStefan Metzmacher1-1/+6
DELETE and MODRDN are not really supported yet. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-10-21python: Use list comprehension in string_to_byte_array()Joseph Sutton1-6/+1
Samba is now a mature user of Python and can cope with a list comprehension from time to time. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2022-05-10python: Remove redundant assignmentsJoseph Sutton1-1/+0
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-09-21python: Don't leak file handlesJoseph Sutton1-5/+7
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-21python: glue function for detecting if selftest is enabledDavid Mulder1-0/+1
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-03-01pyglue: add float2nttime() and nttime2float()Stefan Metzmacher1-0/+2
The float value is what the native python time.time() returns, it's basically a struct timespec converted to double/float. Pair-Programmed-With: Björn Baumbach <bb@sernet.de> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-10-23py3: Add is_ad_dc_built option to python glueDavid Mulder1-0/+1
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-08-21python: Remove remaining references to third_party python libsAndrew Bartlett1-40/+0
For now at least we do not have any in third_party. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: David Mulder <dmulder@suse.com> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Aug 21 00:12:52 UTC 2020 on sn-devel-184
2020-08-11python compat: remove string_typesDouglas Bagnall1-3/+2
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2020-07-17python: wrap 'import dckeytab' in an explanatory functionDouglas Bagnall1-0/+17
The samba.dckeytab module has magic effects on samba.net, but never appears to be used. That can be confusing, both to people and to linters. Here we wrap that confusion up into a well-commented function, so we never again have to wonder why the unused import is there. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: David Mulder <dmulder@samba.org>
2019-04-03python/samba: ignore encoding errors while reading filesPhilipp Gesang1-1/+1
Provisioning fails on C locale due to the Unicode quotes in ldif data. Patch read_and_sub_file() to read the files as UTF-8. Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Wed Apr 3 11:33:38 UTC 2019 on sn-devel-144
2018-12-10python/samba: PY3 ord needs 'str' type not intNoel Power1-1/+1
string_to_byte_array returns not a bytearray (as the name suggests) but a list of byte values (int). Some code expects the list so even using a 'real' bytearray wont work. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E713: test for membership should be 'not in'Joe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E305: expected 2 blank lines after class or function definition, ↵Joe Guo1-0/+2
found 1 Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E302: expected 2 blank lines, found 1Joe Guo1-0/+5
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E265: block comment should start with '# 'Joe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E226: missing whitespace around arithmetic operatorJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E128: continuation line under-indented for visual indentJoe Guo1-9/+9
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E713: test for membership should be 'not in'Joe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-06-12python: export fault_setup() to python bindingsStefan Metzmacher1-0/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13469 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-06-04pyldb-samba: Use the same smb.conf variable name as the C wrapper users for ↵Andrew Bartlett1-1/+1
LDB_FLG_NOSYNC This was never noticed as most wrappers on make test run with TDB_NO_FSYNC However ldb_mdb has not been told to use this (naturally) and so we rely on the smb.conf setting to not force an fsync(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13461 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-04-30python/samba: port some isinstance str checks (to cater for unicode)Noel Power1-2/+3
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2017-12-18pyglue: Add function to generate a random byte stringGary Lockyer1-0/+1
Adds a function to generate a random byte string using the samba random routines. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-12-10samba-tool: validate password early in `domain provision`Jamie McClymont1-0/+1
Checks password against default quality and length standards when it is entered, allowing a second chance to enter one (if interactive), rather than running through the provisioning process and bailing on an exception Includes unit tests for the newly-added python wrapper of check_password_quality plus black-box tests for the checks in samba-tool. Breaks an openldap test which uses an invalid password. BUG: https://bugzilla.samba.org/show_bug.cgi?id=9710 BUG: https://bugzilla.samba.org/show_bug.cgi?id=12235 Signed-off-by: Jamie McClymont <jamiemcclymont@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2017-04-29python: Add provisioning support for MIT KDC in samba-toolAndreas Schneider1-0/+1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Andrew Bartlet <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2017-03-15lib/crypto: implement samba.crypto Python module for RC4Alexander Bokovoy1-14/+2
Implement a small Python module that exposes arcfour_crypt_blob() function widely used in Samba C code. When Samba Python bindings are used to call LSA CreateTrustedDomainEx2, there is a need to encrypt trusted credentials with RC4 cipher. Current Samba Python code relies on Python runtime to provide RC4 cipher. However, in FIPS 140-2 mode system crypto libraries do not provide access RC4 cipher at all. According to Microsoft dochelp team, Windows is treating AuthenticationInformation blob encryption as 'plain text' in terms of FIPS 140-2, thus doing application-level encryption. Replace samba.arcfour_encrypt() implementation with a call to samba.crypto.arcfour_crypt_blob(). Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Simo Sorce <idra@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org> Autobuild-User(master): Günther Deschner <gd@samba.org> Autobuild-Date(master): Wed Mar 15 01:30:24 CET 2017 on sn-devel-144
2017-03-10python: Remove unused import PY3Andrew Bartlett1-1/+0
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-03-10python: samba._ldb: Port of samba._ldb to Python 3 compatible formLumir Balhar1-5/+1
Port of samba._ldb Python module to Python 3 compatible form. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-03-10python: Make top-level samba modules Python 3 compatibleLumir Balhar1-12/+20
New file compat.py will help with porting to Python 3. For now, it contains only PY3 variable based on six.PY3 which simplifies condition mentioned below. The added `if not PY3` conditions enable us to bootstrap running tests with Python 3 even if most modules are not ported yet. The plan is to move modules outside this condition as they are ported. The `PY3` condition is currently used only in tests and for the samba._ldb module which is not ported yet and has a lot of dependencies. The other changes are related to differences between Python 2 and 3. Python 2.6 introduced the `0o` prefix for octal literals as an alternative to plain `0`. In Python 3, support for plain `0` is dropped and octal literals have to start with `0o` prefix. Python 2.6 introduced a clearer `except` syntax: `except ExceptionType as target:` instead of `except ExceptionType, target:`. In Python 3, the old syntax is no longer allowed. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-02-21pyglue: add generate_random_machine_password() wrapperStefan Metzmacher1-0/+1
We use PyUnicode_FromString() (which is available from 2.6) because we really have non-ascii strings. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12262 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2016-11-04python: Add DsExtendedError ExceptionAndrew Bartlett1-0/+1
This will be used for checking errors during a GetNCChanges EXOP like RID Set allocation. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12398
2016-11-04python: create NTSTATUSError, HRESULTError and WERRORErrorAndrew Bartlett1-0/+4
The advantage of these over the previous use of just RuntimeError is that we can catch just the errors we want, without having to catch all possible RuntimeError cases and assume they decode to a tuple Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12398
2016-02-03python:samba: add a generic arcfour_encrypt() helper functionStefan Metzmacher1-0/+16
This works with Crypto.Cipher.ARC4 (from python*-crypto) and fallback to M2Crypto.RC4.RC4 (from [python*-]m2crypto). BUG: https://bugzilla.samba.org/show_bug.cgi?id=11699 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2016-02-03python:samba: add a generic string_to_byte_array() helper functionStefan Metzmacher1-0/+8
We should avoid implementing this again and again. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11699 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>