summaryrefslogtreecommitdiff
path: root/python/samba/netcmd/gpo.py
AgeCommit message (Collapse)AuthorFilesLines
2025-03-29samba-tool gpo: use a real XML parser to check entity validityDouglas Bagnall1-20/+25
The expat parser comes with the Python standard library, so we can use it to check the entities work, rather than relying on a fragile regular expression. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Ralph Boehme <slow@samba.org>
2025-03-29samba-tool gpo: separate function for dtd header generationDouglas Bagnall1-6/+12
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Ralph Boehme <slow@samba.org>
2025-03-25samba-tool gpo: better entities check copes with new linesDouglas Bagnall1-2/+2
Per https://www.w3.org/TR/xml/#sec-entity-decl (and MS references) there is always some whitespace between '<!ENTITY' and the name, and between the name and whatever is next. Also, it is valid XML to have newlines inside entity declarations, like this: <!ENTITY bubble "*S-1-5-113" > We used to create such files, so we should allow them. There is a kind of entity that has '%' before the name, and there are non-ascii names, which we continue not to support. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15829 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
2025-03-25samba-tool gpo backup fix --generalizeDouglas Bagnall1-3/+5
This was broken with commit ce56d336f234febfd4cb3da11dd584842c24ce1d but we didn't notice because the test was already broken. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15829 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
2025-03-25python:netcmd:gpo: fix crash when updating an MOTD GPOAndreas Hasenack1-2/+6
When the policy exists already, there is no exception and the code tries to use the "data" variable, but it doesn't exist because it was only defined in the exception handling. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15774 Signed-off-by: Andreas Hasenack <andreas.hasenack@canonical.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
2025-03-25samba-tool gpo: close opened filesDouglas Bagnall1-6/+10
It is almost certain that we are not going to run out of files, as they get garbage collected anyway, but in some circumstances these can fill your screen with "ResourceWarning: unclosed file" messages, which hides the real messages. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
2025-03-19python/gpo.py: avoid SDDL conversion for dsacl2fsaclRalph Boehme1-2/+1
This is not needed and has the potential to loose information if the sddl code wouldn't have all features implemented. No intended change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14927 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-09-24samba-tool: Fix for inability to delete GPOs containing GPWL policiesKacper Boström1-2/+2
GPOs containing GPWL (Wireless/Wired Protocol Extension) policies could not be deleted with samba-tool as those policies were stored as subentries of the GPO and only the main root was deleted. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15387 RN: Fix for inability to delete GPOs containing GPWL policies using samba-tool Signed-off-by: Kacper Boström <kacper@kacper.se> Reviewed-by: David Mulder <dmulder@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Sep 24 17:11:53 UTC 2024 on atb-devel-224
2023-12-15python: use python3 style super statementsRob van der Linde1-2/+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-12-15python: pep257: docstring should use double quotesRob van der Linde1-11/+11
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-09-29samba-tool: Fix for gpo restore not working without --tmpdirKacper1-0/+9
cmd_restore depends on cmd_create but the later cleans up required temp files for cmd_restore to function. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15462 RN: Fix for gpo restore not working without --tmpdir Signed-off-by: Kacper Boström <kacper@kacper.se> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: David Mulder <dmulder@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Sep 29 03:15:18 UTC 2023 on atb-devel-224
2023-08-30gp: Use read_file() instead of readfp()Joseph Sutton1-4/+4
readfp() is deprecated and could be removed in a future version of Python. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:netcmd: Fix code spellingAndreas Schneider1-1/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-03-09samba-tool: Ensure modifying GPO increments GPT.INI versDavid Mulder1-0/+63
When we modify a GPO, we must increment the version number in the GPT.INI, otherwise client machines won't process the update. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15327 Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2023-03-09samba-tool: Subclass GPOCommand for calling samdb_connectDavid Mulder1-15/+15
These sub commands will need to call samdb_connect in an upcoming commit. Subclass from GPOCommand to make this possible. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15327 Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2023-03-03samba-tool: Clarify cse register command file destDavid Mulder1-2/+6
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-03-03samba-tool: Don't use invalid escape sequencesJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-02-23python: fix mutable default argumentsRob van der Linde1-3/+11
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> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Feb 23 23:33:46 UTC 2023 on atb-devel-224
2023-02-03gp: samba-tool gpo cse register/unregister/listDavid Mulder1-0/+110
Add samba-tool commands for managing registration of Client Side Extensions. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-01-30samba-tool: Use ntstatus constants in gpo commandsDavid Mulder1-127/+134
Replace all the hard coded instances of ntstatus codes in the samba-tool gpo commands with constants from samba.ntstatus. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-01-30samba-tool: gpo show/load handle utf-16-le stringsDavid Mulder1-1/+6
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Tested-by: Kees van Vloten <keesvanvloten@gmail.com>
2023-01-30samba-tool: gpo load provide option for replace vs mergeDavid Mulder1-3/+8
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Tested-by: Kees van Vloten <keesvanvloten@gmail.com>
2023-01-30samba-tool: gpo load add Registry ext by defaultDavid Mulder1-3/+9
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Tested-by: Kees van Vloten <keesvanvloten@gmail.com>
2023-01-30samba-tool: gpo load extension namesDavid Mulder1-6/+37
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Tested-by: Kees van Vloten <keesvanvloten@gmail.com>
2023-01-30samba-tool: gpo load/remove increment GPT.INIDavid Mulder1-12/+11
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Tested-by: Kees van Vloten <keesvanvloten@gmail.com>
2023-01-30samba-tool: gpo load/remove bytesDavid Mulder1-0/+32
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Tested-by: Kees van Vloten <keesvanvloten@gmail.com>
2023-01-30samba-tool: gpo load/remove commandsDavid Mulder1-0/+126
These commands allow the setting of various group policies on the sysvol. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Tested-by: Kees van Vloten <keesvanvloten@gmail.com>
2023-01-30samba-tool: Move smb_connection to a common fileDavid Mulder1-20/+1
This is in preparation for needing it here later. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-01-30samba-tool: Move create_directory_hier to a common fileDavid Mulder1-8/+1
This is in preparation for needing it here later. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-01-30samba-tool: gpo show command list policiesDavid Mulder1-1/+52
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Tested-by: Kees van Vloten <keesvanvloten@gmail.com>
2022-11-21gp: PAM Access should implicitly deny ALL w/ allowDavid Mulder1-1/+2
If an allow entry is specified, the PAM Access CSE should implicitly deny ALL (everyone other than the explicit allow entries). Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-11-21gp: samba-tool manage gpo access add don't fail w/out upnDavid Mulder1-5/+3
The search response for the user could possibly not include a upn (this happens with Administrator for example). Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-11-21gp: Make samba-tool gpo manage sudoers remove backward compatibleDavid Mulder1-18/+46
Ensure `samba-tool gpo manage sudoers remove` is backward compatible with the GPME sudo rules. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-11-21gp: Make samba-tool gpo manage sudoers list backward compatibleDavid Mulder1-18/+42
Ensure `samba-tool gpo manage sudoers list` is backward compatible with the GPME sudo rules. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-11-15gp: Fix startup scripts add not always set runonceDavid Mulder1-1/+1
The runonce is always being set because neither True nor False is ever None. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Nov 15 02:09:45 UTC 2022 on sn-devel-184
2022-11-15gp: Fix startup scripts list not fail with empty argsDavid Mulder1-1/+5
This fixes the startup scripts list command to not fail when the parameters variable is empty. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-11-15gp: startup scripts list enclude newline in outputDavid Mulder1-1/+1
The output for listing startup scripts wasn't clear because there was no newline between entries. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-11-15gp: startup scripts add clarify 'args' optionDavid Mulder1-1/+1
Make sure it is clear how to specify args for the command, and that multiple args can be passed wrapped in quotes. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-11-15gp: Fix startup scripts add argsDavid Mulder1-1/+1
The args for the command could not be parsed because samba-tool detects the '-' and thinks its part of the samba-tool command. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-08-06samba-tool gpo: clean up tmpdir after createDouglas Bagnall1-0/+4
'fetch' and 'backup' might also leave files in /tmp, but in those cases we want the files. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15006 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: David Mulder <dmulder@suse.com> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Sat Aug 6 01:42:09 UTC 2022 on sn-devel-184
2022-05-31gpo: Move Group Policy code below gp directoryDavid Mulder1-1/+1
Moves the Group Policy extensions and supporting code within the existing python/samba/gp directory. Meant to clean up the clutter that's accumulating in python/samba. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue May 31 20:15:45 UTC 2022 on sn-devel-184
2022-05-10python: Use 'is' for identity when comparing against NoneJoseph Sutton1-2/+2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue May 10 06:12:10 UTC 2022 on sn-devel-184
2022-05-10python: Remove redundant assignmentsJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2022-05-10samba-tool gpo: Fix unintended string concatenationsJoseph Sutton1-6/+6
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-06-09samba-tool: gpo admxload mkdir -pDavid Mulder1-1/+1
Ensure all directories in the path are created, otherwise admx upload fails here. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Wed Jun 9 22:26:42 UTC 2021 on sn-devel-184
2021-04-28python: remove all 'from __future__ import print_function'Douglas Bagnall1-1/+0
This made Python 2's print behave like Python 3's print(). In some cases, where we had: from __future__ import print_function """Intended module documentation...""" this will have the side effect of making the intended module documentation work as the actual module documentation (i.e. becoming __doc__), because it is once again the first statement in the module. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-03-18samba-tool: Add a gpo command for removing VGP Host Access Group PolicyDavid Mulder1-1/+69
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Mar 18 20:02:50 UTC 2021 on sn-devel-184
2021-03-18samba-tool: Test gpo manage access remove commandDavid Mulder1-0/+30
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-18samba-tool: Add a gpo command for adding VGP Host Access Group PolicyDavid Mulder1-1/+104
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-03-18samba-tool: Test gpo manage access add commandDavid Mulder1-0/+30
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org>