Strategies to debug cpython modules during provision

Andrew Bartlett abartlet at
Tue Apr 10 01:30:12 UTC 2018

On Tue, 2018-04-10 at 11:05 +1000, William Brown via samba-technical
> Hi,
> I'm trying to start on some samba4 development. During the provision
> process I have encountered an error:
> Setting up sam.ldb users and groups
> ERROR(ldb): uncaught exception - operations error at
> ../source4/dsdb/samdb/ldb_modules/password_hash.c:3144
>   File "/usr/local/samba/lib64/python2.7/site-
> packages/samba/netcmd/", line 176, in _run
>     return*args, **kwargs)
>   File "/usr/local/samba/lib64/python2.7/site-
> packages/samba/netcmd/", line 501, in run
>     plaintext_secrets=plaintext_secrets)
>   File "/usr/local/samba/lib64/python2.7/site-
> packages/samba/provision/", line 2267, in provision
>     skip_sysvolacl=skip_sysvolacl)
>   File "/usr/local/samba/lib64/python2.7/site-
> packages/samba/provision/", line 1866, in provision_fill
>     next_rid=next_rid, dc_rid=dc_rid)
>   File "/usr/local/samba/lib64/python2.7/site-
> packages/samba/provision/", line 1527, in fill_samdb
>     }, controls=["relax:0", "provision:0"])
>   File "/usr/local/samba/lib64/python2.7/site-
> packages/samba/provision/", line 55, in setup_add_ldif
>     ldb.add_ldif(data, controls)
>   File "/usr/local/samba/lib64/python2.7/site-
> packages/samba/", line 229, in add_ldif
>     self.add(msg, controls)
> Inspecting the code, I see this is from password_hash.c's call to
> smb_krb5_init_context, and reading that code in
> source4/auth/kerberos/krb5_init_context.c between smb_krb5_init_context
> and smb_krb5_init_context_basic I can see some areas that *could* be
> the cause of the issue with regard to the system krb5.conf from MIT vs
> embedded heimdal.

Yep, the includedir statement.  A better error message would be good,
as would be backporting the patch for includedir from modern Heimdal.

> However to be 100% sure, I would like to attach a debugger into this
> process so that I can observe the error.
> As I haven't debugging the samba-tool domain provision process before,
> I would like to know if there is any advice on how to go about doing
> this that could make my life a bit easier. Additionally, it would be
> great to know how to "clean up" after a failed installation like this.

gdb --args python ....

No need to clean up, it wipes every time.  (Somehow nobody has said
they have lost data re-running provision, I don't know why). 

Andrew Bartlett

Andrew Bartlett
Authentication Developer, Samba Team
Samba Development and Support, Catalyst IT

More information about the samba-technical mailing list