summaryrefslogtreecommitdiff
path: root/python/samba/getopt.py
AgeCommit message (Collapse)AuthorFilesLines
2025-03-12python:getopt: hack to generate docbook stubs from --helpDouglas Bagnall1-0/+52
We have many many samba-tool subcommands that are not documented in the manpage. Often the --help text is a good place to start, but doing it entirely manually is VERY tedious. This automates some of the process. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Rowland Penny <rpenny@samba.org>
2025-02-08py:get_opts:VersionOptions prints version in --helpDouglas Bagnall1-2/+2
Because it might as well. Like this: Version Options: -V, --version Display version number (4.22.2) BUG: https://bugzilla.samba.org/show_bug.cgi?id=15770 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
2024-04-23python/samba/getopt: don't prompt for a password for --use-krb5-ccache=...Stefan Metzmacher1-0/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15018 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2023-10-25python: getopt: HostOptions and other option groups inherit from samba ↵Rob van der Linde1-9/+5
OptionGroup class 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> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Oct 25 00:31:37 UTC 2023 on atb-devel-224
2023-10-24netcmd: auth policy: add OptionGroup classes for user, service and computer ↵Rob van der Linde1-0/+23
options 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-10-24python: getopt: Add HostOptions to avoid need to manually add -HRob van der Linde1-0/+16
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-10-24python: getopt: implement required flag on options and OptionParserRob van der Linde1-1/+35
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-10-24python: getopt: subclass OptionParser to populate option_classRob van der Linde1-0/+22
The option_class needs to be set correctly for OptionGroups that use self.add_option Override OptionParser `__init__` to change the default Option class to the samba one. 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-10-24python: netcmd: remove OptionError alias to OptionValueErrorRob van der Linde1-4/+4
The other methods in this file already raise optparse.OptionValueError directly, except for two older ones. They are using an alias which changes the name to OptionError, the confusing part about this is that optparse.OptionError actually does exist, so the incorrect alias needs to be removed. 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-10-24python: getopt: rename SambaOption to OptionRob van der Linde1-1/+1
* Nothing uses SambaOption directly, everything imports it through samba.netcmd.Option * Avoid an unnecessary rename on import 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-10-24python: add docstrings to Validator and ValidationErrorRob van der Linde1-0/+8
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-10-24python: move Validator base class and ValidationError to getoptRob van der Linde1-0/+12
It makes more sense for these to exist in the top package, because they are used by SambaOption. validators.py can still exist in netcmd, just not the base class and exception. 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-10-24python: getopt: move validators logic to parent classRob van der Linde1-0/+17
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-10-24python: getopt: move SambaOption to the top of the fileRob van der Linde1-45/+45
This is needed for the next commit 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-10-24python: getopt: correctly group and sort importsRob van der Linde1-2/+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-10-24python: getopt: update super calls to python3 styleRob van der Linde1-5/+5
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-10-24python: move comment for check_bytes to docstringRob van der Linde1-4/+5
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-10-24python: PEP8 fixup whitespace in getopt.py firstRob van der Linde1-6/+6
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-07-21samba-tool: Use samba.glue.get_burnt_cmdline rather than regexAndrew Bartlett1-49/+20
This use avoids having two different methods to match on command-line passwords. We already have a dependency on the setproctitle python module, and this does not change as the (C) libbsd setproctitle() can't be run from within a python module. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15289 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2022-10-04samba-tool: Use authentication file to pass credentialsNikola Radovanovic1-0/+10
In order not to pass credentials in clear-text directly over command line, this is a patch to store username/password/domain in a file and use it during domain join for example. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15031 Signed-off-by: Nikola Radovanovic <radovanovic.extern@univention.de> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-09-06py/getopt: allow --option arguments to contain '='Douglas Bagnall1-1/+1
smb.conf lines can have = on the right hand side. For example, in st/ad_dc/etc/smb.conf we have 3 examples, including: gpo update command = python3 source4/scripting/bin/samba-gpupdate [...] --target=Computer If we tried to provide the same line via --option, it would split on both '=', and the set value would end at '--target'. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-06py/getopt: improve messages for bad --realmDouglas Bagnall1-1/+4
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-06py/getopt: improve messages for bad --debug argDouglas Bagnall1-1/+4
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-06samba-tool: avoid traceback for options errorsDouglas Bagnall1-0/+3
What option? None yet, but see the next two commits. We use a local reference to optparse.OptionValueError, to save typing and make the eventual switch to argparse easier. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-07-22gpo: samba-gpupdate use s3 param for registry confDavid Mulder1-0/+9
Cause samba-gpupdate to use an s3 param so that it can load settings from registry configuration. 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): Fri Jul 22 20:40:51 UTC 2022 on sn-devel-184
2021-06-20python: Streamline option parser of python toolsAndreas Schneider1-6/+36
The python tools, especially samba-tool should have the same option set as the rest of the client utils. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-26Remove password from samba-tool proctitleHeiko Baumann1-0/+48
This fix makes sure the password is removed from the proctitle of samba-tool so it cannot be exposed by e.g. ps(1). - Moved code to python/samba/getopt.py as suggested by David Mulder - Except ModuleNotFoundError when trying to load setproctitle module - Improved code to keep option separator (space or equal sign) while removing password from proctitle. Signed-off-by: Heiko Baumann <heibau@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: David Mulder <dmulder@suse.com>
2019-07-02python getopt: Add bytes option typeGary Lockyer1-0/+45
Add a new option type to the python command line options. Option("--size", type="bytes", metavar="SIZE") To allow the input of file and memory sizes using unit suffixes i.e. 2Gb, 4KiB ... Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-14python/samba: PY3 fix can't compare string with intNoel Power1-3/+0
Testing a string against an int value is illegal and is not necessary in this case, this patch removes the problematic test. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E128: continuation line under-indented for visual indentJoe Guo1-19/+19
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 E123: closing bracket does not match indentation of opening ↵Joe Guo1-1/+1
bracket's line 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: call fault_setup() if samba.getopt is usedStefan Metzmacher1-0/+2
This means we have a samba command line tool written in python, e.g. samba-tool We should get the samba typicall backtraces instead of just "Segmentation fault (core dumped)". 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> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Jun 12 11:04:55 CEST 2018 on sn-devel-144
2017-09-07python: Allow debug classes to be specified on the command line for python toolsAndrew Bartlett1-3/+3
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Sep 7 10:43:33 CEST 2017 on sn-devel-144
2017-07-28python/getopt: Add --krb5-ccache (for samba-tool etc) to match the C binariesAndrew Bartlett1-0/+7
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2017-06-23python/getopt: -d/--debuglevel saves value in options for scriptsDouglas Bagnall1-0/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-03-10python: samba.getopt: Port module to Python 3 compatible formLumir Balhar1-6/+2
Port samba.getopt module to Python 3 compatible form. Remove unused and untested `get_hostconfig()` function. Andrew Bartlett suggested this removal because it is the simpliest way how to break a long dependency line of Python modules which have to be ported at once. More info: https://lists.samba.org/archive/samba-technical/2017-January/118150.html Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2015-07-08python/samba: add on optional 'special_name' argument to CredentialsOptions()Stefan Metzmacher1-10/+27
This way we have have two sets or credentials on the command line, while at least one uses some prefix (special_name) for the arguments. The default options without special_name are: Credentials Options: --simple-bind-dn=DN DN to use for a simple bind --password=PASSWORD Password -U USERNAME, --username=USERNAME Username -W WORKGROUP, --workgroup=WORKGROUP Workgroup -N, --no-pass Don't ask for a password -k KERBEROS, --kerberos=KERBEROS Use Kerberos --ipaddress=IPADDRESS IP address of server -P, --machine-pass Use stored machine account password With special_name='local-dc' it's: Credentials Options (local-dc): --local-dc-simple-bind-dn=DN DN to use for a simple bind --local-dc-password=PASSWORD Password --local-dc-username=USERNAME Username --local-dc-workgroup=WORKGROUP Workgroup --local-dc-no-pass Don't ask for a password --local-dc-kerberos=KERBEROS Use Kerberos --local-dc-ipaddress=IPADDRESS IP address of server --local-dc-machine-pass Use stored machine account password Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-03-06samba-tool: Add -P to options.CredentialsOptionsAndrew Bartlett1-5/+21
This matches our other binaries, and allows samba-tool commands to run with the machine account. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-03-02Move python modules from source4/scripting/python/ to python/.Jelmer Vernooij1-0/+251
Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sat Mar 2 03:57:34 CET 2013 on sn-devel-104