summaryrefslogtreecommitdiff
path: root/python/samba
AgeCommit message (Collapse)AuthorFilesLines
2023-06-25netcmd: move get_policy method from base class to the modelRob van der Linde3-23/+71
There isn't much left of the base class, the next thing is to remove it. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: move method print_json to command base classRob van der Linde3-24/+11
This is used in quite a few commands, move to base class. This ensures the correct encoder class and settings are always used, and they are only defined in one place. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: fix import sort/grouping as per python standardRob van der Linde1-4/+5
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: move ldb_connect method to base classRob van der Linde3-18/+9
This method is needed by just about every command and moving it here is another step towards elinimanting the base classes in domain/auth and domain/claim. The base classes are almost empty now, since introducing the model layer. The next step is to get rid of these base classes completely. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: PEP257 fix incorrect docstring quotesRob van der Linde1-1/+1
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: domain: claims: use consistent naming for optionsRob van der Linde2-32/+29
The name of the option should be the same as the attribute name. You can still tell where it's being used (display_name), especially now with the model layer: ClaimType.get(ldb, display_name=name) The silo commands tend to use the `cn` field, while the claims commands use the `displayName` field, but the option is always called `name` for consistency. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: domain: claim commands use the model layerRob van der Linde4-240/+94
This makes it consistent with the auth silo code, both should now make use of the models. Claims commands are now using the model layer with one exception and that is the get_attribute_from_schema and get_class_from_schema methods in the base class. These will be made into models in another commit. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: domain: fix claims constant name was wrong should be claim type CNRob van der Linde1-3/+3
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: domain: fix attributes created by test setUp methodRob van der Linde1-6/+14
Discovered this while converting the claims cli commands to use the models, some tests failed. The reason for this was that they relied on the attributes in the list ATTRIBUTES to exist. However, then we have to also prefix the attributes we create in the test_claim_type_create test. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: domain: claim: show err if assertIsNone failsRob van der Linde1-28/+28
Other tests do this too, this is very useful if things fail Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: domain: rename claim tests for consistencyRob van der Linde1-0/+0
The domain_auth tests are also prefixed with domain, it matches the cli command "samba-tool domain claim". Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: domain: tests for auth silo command line toolsRob van der Linde3-0/+1226
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: domain: add authentication silo commandsRob van der Linde6-0/+1077
Authentication policies: * samba-tool domain auth policy list * samba-tool domain auth policy view * samba-tool domain auth policy create * samba-tool domain auth policy modify * samba-tool domain auth policy delete Authentication silos: * samba-tool domain auth silo list * samba-tool domain auth silo view * samba-tool domain auth silo create * samba-tool domain auth silo modify * samba-tool domain auth silo delete Authentication silo members: * samba-tool domain auth silo member list * samba-tool domain auth silo member add * samba-tool domain auth silo member remove Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: add domain models and basic model layerRob van der Linde9-0/+1167
The ORM is somewhat inspired by Django, but it has some key differences that make it work better with the Ldb database. A field can be a singular value or a list, so a BooleanField can either be True, or [True, False, True], or None. The only thing that many=True does is say that the field "prefers" to be a list, but really any field can be a list. For example when creating a new object, it initialises the field as an empty list rather than None if many=True. When saving an object, if it is an update operation, only write the fields that have actually changed. When updating an object, any fields that are unset (set to None, or an empty list) will be treated as a REMOVE operation. Note that silo members should not be saved this way, writing the whole list can lead to data loss if multiple admins are saving the silo at the same time. Silo members will need to be handled differently, just removing one member but not writing the whole list. Unlike Django, there is no .objects class, instead there are a bunch of static methods for querying: * Model.get * Model.query * Model.create * Model.get_or_create Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: add custom json encoder for object type fieldsRob van der Linde1-0/+49
The custom JSONEncoder class is also capable of encoding Dn objects to str, and any object that has a __json__ method. The __json__ method is not an official dunder method, but this has been used by other frameworks too (like Pyramid). Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-25netcmd: add optparse validators and Range validatorRob van der Linde2-0/+105
Add the ability to the add validators to optparse Option fields. The Option class was already subclassed in `netcmd/__init__.py` so adding some functionality to this was relatively easy. Added the ability to add Validator classes to a field so that this can be used for anything else in the future, but for now there is a Range validator required by upcoming auto silo commands. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-23python:samba: Fix code spellingAndreas Schneider13-24/+24
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-06-23python:samba:tests: Fix code spellingAndreas Schneider33-56/+58
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:subunit: Fix code spellingAndreas Schneider2-2/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:samba3: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:provision: Fix code spellingAndreas Schneider3-10/+10
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:netcmd: Fix code spellingAndreas Schneider14-30/+31
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:kcc: Fix code spellingAndreas Schneider4-21/+21
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:gp_parse: Fix code spellingAndreas Schneider2-2/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:gp: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:emulate: Fix code spellingAndreas Schneider1-5/+5
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool/ntacl: implement set --recursiveStefan Metzmacher1-1/+16
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool/ntacl: add set --verbose and print out the file/directory nameStefan Metzmacher1-13/+27
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool/ntacl: don't announce -q,--quiet in --help as it's not used at allStefan Metzmacher1-1/+2
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool/ntacl: let changedomsid ignore symlinksStefan Metzmacher1-13/+24
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool: print default (domain) for --dns-directory-partition option in ↵Björn Baumbach1-1/+1
help message Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21tests/krb5/s4u_tests.py: add test_constrained_delegation_authtimeStefan Metzmacher1-2/+32
This demonstrates that we use the correct authtime when doing constrained delegation. The actual fix for the problem is already in place via commit 75ec66c729faad60fa18b9504ba4053b3e2f47bc third_party/heimdal: Import lorikeet-heimdal-202306091507 (commit 7d8afc9d7e3d309ddccc2aea6405a8ca6280f6de) The related patch is: 006a365a6aa3047a4e685e1607973746a28cc1f1 kdc: use the correct authtime from addtitional ticket for S4U2Proxy tickets BUG: https://bugzilla.samba.org/show_bug.cgi?id=13137 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21tests/krb5/s4u_tests.py: add ↵Stefan Metzmacher1-3/+89
test_constrained_delegation_with_enc_auth_data_[no_]subkey() This demonstrates that we use the correct key for EncAuthorizationData together with constrained delegation. The actual fix for the problem is already in place via commit 75ec66c729faad60fa18b9504ba4053b3e2f47bc third_party/heimdal: Import lorikeet-heimdal-202306091507 (commit 7d8afc9d7e3d309ddccc2aea6405a8ca6280f6de) The related patches are: 38c47c54f0c78fed5afc1aea9c5f6683e06ec842 kdc: fix memory leak when decryption AuthorizationData 61c0089ea3f5387953818a3ac99fb529244196e6 kdc: decrypt b->enc_authorization_data in tgs_build_reply() fed5579814108ee90f701ca6bfb5500f7d839bc4 kdc: if we don't have an authenticator subkey for S4U2Proxy we need to use the keys from evidence_tkt BUG: https://bugzilla.samba.org/show_bug.cgi?id=13131 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool: let 'domain level raise' call check_and_update_fl() in a transactionStefan Metzmacher1-2/+22
This makes it possible to raise the levels without starting 'samba' first, which is very useful for blackbox tests. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool: move some parts of 'domain level [show|raise]' in to subfunctionsStefan Metzmacher1-4/+17
This will make it easier to use transactions in the following changes... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool: move some parts of 'domain level [show|raise]' in to try/exceptStefan Metzmacher1-47/+50
This just adds indentation for now, the following changes will add transactions... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool: let 'domain level raise --domain-level' use the correct crossRef dnStefan Metzmacher1-3/+8
We should not rely on lp.get('workgroup')... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool: check for invalid 'domain level' subcommands firstStefan Metzmacher1-2/+3
This will simplify further changes... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-21samba-tool: Fix missing import for "domain level raise --forest-level=2016"Andrew Bartlett1-1/+1
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-06-21tests/krb5: Test that FX-COOKIE matches cookie returned by WindowsJoseph Sutton1-0/+87
The cookie produced by Windows differs depending on whether FAST was used. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-06-16samba-tool: add new --dns-directory-partition option to dns zonecreate commandBjörn Baumbach2-5/+113
The new --dns-directory-partition chooses the directory partition for the new zone - "domain" or "forest". Defaults to the current default "domain". Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Jun 16 21:23:28 UTC 2023 on atb-devel-224
2023-06-16libsmb: Test smb1 mknodVolker Lendecke1-0/+20
Requires O_PATH to work correctly Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2023-06-15tests/auth_log: Ensure tests continue to pass when new log types are addedJoseph Sutton1-2/+24
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-15tests/auth_log: Add support for new ‘KDC Authorization’ log typeJoseph Sutton1-0/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-14tests/auth_log: Refactor waitForMessages() to use nextMessage()Joseph Sutton1-15/+8
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Jun 14 23:55:42 UTC 2023 on atb-devel-224
2023-06-14tests/auth_log: Add method to fetch the next relevant message from the ↵Joseph Sutton1-0/+38
messaging bus Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-14tests/krb5: Test authentication with policy restrictions and a wrong passwordJoseph Sutton1-0/+145
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-14tests/krb5: Test S4U2Self followed by constrained delegation with ↵Joseph Sutton2-0/+118
authentication policies Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-14tests/krb5: Remove unneeded ‘dn’ parameterJoseph Sutton1-9/+9
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-14tests/krb5: Make use of KerberosCredentials.get_sid()Joseph Sutton10-270/+106
KerberosCredentials objects now keep track of their account’s SID, which removes the need to look it up with KDCBaseTest.get_objectSid(). Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>