[PATCH] samba-tool: Fix traceback in samba-tool ntacl subcommands
Alexander Bokovoy
ab at samba.org
Thu Jul 18 07:47:41 UTC 2019
On to, 18 heinä 2019, Amit Kumar via samba-technical wrote:
> # samba-tool ntacl sysvolcheck
> ERROR(runtime): uncaught exception - samdb_domain_sid failed
> File "/usr/lib64/python2.7/site-packages/samba/netcmd/__init__.py",
> line 177, in _run
> return self.run(*args, **kwargs)
> File "/usr/lib64/python2.7/site-packages/samba/netcmd/ntacl.py", line
> 265, in run
> domain_sid = security.dom_sid(samdb.domain_sid)
> File "/usr/lib64/python2.7/site-packages/samba/samdb.py", line 583, in
> get_domain_sid
> return dsdb._samdb_get_domain_sid(self)
>
> # samba-tool ntacl sysvolreset
> ERROR(runtime): uncaught exception - samdb_domain_sid failed
> File "/usr/lib64/python2.7/site-packages/samba/netcmd/__init__.py",
> line 177, in _run
> return self.run(*args, **kwargs)
> File "/usr/lib64/python2.7/site-packages/samba/netcmd/ntacl.py", line
> 210, in run
> domain_sid = security.dom_sid(samdb.domain_sid)
> File "/usr/lib64/python2.7/site-packages/samba/samdb.py", line 583, in
> get_domain_sid
> return dsdb._samdb_get_domain_sid(self)
>
> Signed-off-by: Amit Kumar <amitkuma at redhat.com>
> ---
> python/samba/netcmd/ntacl.py | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/python/samba/netcmd/ntacl.py b/python/samba/netcmd/ntacl.py
> index 4cc7737ae77..dfcc8bd4d8f 100644
> --- a/python/samba/netcmd/ntacl.py
> +++ b/python/samba/netcmd/ntacl.py
> @@ -393,7 +393,11 @@ class cmd_ntacl_sysvolreset(Command):
> elif use_s3fs:
> use_ntvfs = False
>
> - domain_sid = security.dom_sid(samdb.domain_sid)
> + try:
> + domain_sid = security.dom_sid(samdb.domain_sid)
> + except Exception as e:
> + print("domain_sid not returned,",e)
> + return
I think it is better to raise CommandError() exception here instead.
Pretty much like below with 'Unable to open samdb':
>
> s3conf = s3param.get_context()
> s3conf.load(lp.configfile)
> @@ -448,7 +452,11 @@ class cmd_ntacl_sysvolcheck(Command):
> except Exception as e:
> raise CommandError("Unable to open samdb:", e)
^^ Here.
Also, please use 'Cannot retrieve domain SID' as a friendly message
instead of 'domain_sid not returned'.
Same applies to the second patch.
>
> - domain_sid = security.dom_sid(samdb.domain_sid)
> + try:
> + domain_sid = security.dom_sid(samdb.domain_sid)
> + except Exception as e:
> + print("domain_sid not returned,",e)
> + return
>
> provision.checksysvolacl(samdb, netlogon, sysvol,
> domain_sid,
> --
> 2.17.1
>
>
> Opened MR: https://gitlab.com/samba-team/samba/merge_requests/650
>
> From 646c9d78413d59399636d1ca14cad65341b912c6 Mon Sep 17 00:00:00 2001
> From: Amit Kumar <amitkuma at redhat.com>
> Date: Fri, 19 Jul 2019 00:43:58 +0530
> Subject: [PATCH] samba-tool: Fix traceback in samba-tool ntacl subcommands
>
> # samba-tool ntacl sysvolcheck
> ERROR(runtime): uncaught exception - samdb_domain_sid failed
> File "/usr/lib64/python2.7/site-packages/samba/netcmd/__init__.py", line 177, in _run
> return self.run(*args, **kwargs)
> File "/usr/lib64/python2.7/site-packages/samba/netcmd/ntacl.py", line 265, in run
> domain_sid = security.dom_sid(samdb.domain_sid)
> File "/usr/lib64/python2.7/site-packages/samba/samdb.py", line 583, in get_domain_sid
> return dsdb._samdb_get_domain_sid(self)
>
> # samba-tool ntacl sysvolreset
> ERROR(runtime): uncaught exception - samdb_domain_sid failed
> File "/usr/lib64/python2.7/site-packages/samba/netcmd/__init__.py", line 177, in _run
> return self.run(*args, **kwargs)
> File "/usr/lib64/python2.7/site-packages/samba/netcmd/ntacl.py", line 210, in run
> domain_sid = security.dom_sid(samdb.domain_sid)
> File "/usr/lib64/python2.7/site-packages/samba/samdb.py", line 583, in get_domain_sid
> return dsdb._samdb_get_domain_sid(self)
>
> Signed-off-by: Amit Kumar <amitkuma at redhat.com>
> ---
> python/samba/netcmd/ntacl.py | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/python/samba/netcmd/ntacl.py b/python/samba/netcmd/ntacl.py
> index 4cc7737ae77..dfcc8bd4d8f 100644
> --- a/python/samba/netcmd/ntacl.py
> +++ b/python/samba/netcmd/ntacl.py
> @@ -393,7 +393,11 @@ class cmd_ntacl_sysvolreset(Command):
> elif use_s3fs:
> use_ntvfs = False
>
> - domain_sid = security.dom_sid(samdb.domain_sid)
> + try:
> + domain_sid = security.dom_sid(samdb.domain_sid)
> + except Exception as e:
> + print("domain_sid not returned,",e)
> + return
>
> s3conf = s3param.get_context()
> s3conf.load(lp.configfile)
> @@ -448,7 +452,11 @@ class cmd_ntacl_sysvolcheck(Command):
> except Exception as e:
> raise CommandError("Unable to open samdb:", e)
>
> - domain_sid = security.dom_sid(samdb.domain_sid)
> + try:
> + domain_sid = security.dom_sid(samdb.domain_sid)
> + except Exception as e:
> + print("domain_sid not returned,",e)
> + return
>
> provision.checksysvolacl(samdb, netlogon, sysvol,
> domain_sid,
> --
> 2.17.1
>
--
/ Alexander Bokovoy
More information about the samba-technical
mailing list