[PATCH] Re: samba-tool fsmo transfer - uncaught exception

Daniele Dario d.dario76 at gmail.com
Mon May 27 09:16:44 UTC 2019


On Mon, 2019-05-27 at 09:50 +0100, Rowland penny via samba-technical wrote:
> On 27/05/2019 09:27, Alexander Bokovoy wrote:
> > On ma, 27 touko 2019, Rowland penny via samba-technical wrote:
> > > On 27/05/2019 02:28, Douglas Bagnall wrote:
> > > > On 26/05/19 11:22 PM, Rowland penny wrote:
> > > > 
> > > > > How do you test for something that works on some computers, but not on
> > > > > others ?
> > > > 
> > > > With Gitlab CI.
> > > > 
> > > > > Which is correct, it working, or it not working ?
> > > > 
> > > > Well, when I go
> > > > 
> > > > PYTHONPATH=bin/python python3 -c 'import samba;
> > > > samba.drs_utils.drsException'
> > > > 
> > > > I get "module 'samba' has no attribute 'drs_utils'".
> > > > 
> > > > Maybe Python 2 was different.
> > > > 
> > > > > If you have a problem with the test, take it up with Andrew, I
> > > > > initially
> > > > > created the script following his advice, he later 'improved' it,
> > > > > obviously
> > > > > not enough ;-)
> > > > 
> > > > Yes. It only tests 'samba-tool fsmo show', not 'seize' and 'transfer'.
> > > 
> > > That is what Andrew wanted at the time, feel free to extend the test.
> > > > > Anyway, NACK to your patch, but only because you haven't remove the
> > > > > 'import samba' line.
> > > > 
> > > > OK, though I don't it would work with the line removed.
> > > > For example, it would break
> > > > 
> > > >           forest_dn = samba.dn_from_dns_name(samdb.forest_dns_name())
> > > > 
> > > > and it *might* break other things too because, as discussed, Python
> > > > imports can be a bit weird with unexpected side-effects.
> > > > 
> > > > cheers,
> > > > Douglas
> > > 
> > > So how do you propose to test for this ? When having just 'import samba'
> > > fails for 'samba.drs_utils' but works for 'samba.dn_from_dns_name' ? To
> > > me,
> > > this looks like a bug in python.
> > 
> > https://docs.python.org/3/reference/import.html is the canonical
> > documentation on how module import works. When you do 'import samba',
> > you are importing samba/__init__.py implicitly. That file defines what
> > is in the 'samba' namespace as imported. It has no references to
> > 'drs_utils' so the only ways to get 'samba.drs_utils' is to do 'from
> > samba import drs_utils' or 'import samba.drs_utils' explicitly -- in the
> > former case we'll get drs_utils directly, in the latter --
> > samba.drs_utils.
> > 
> 
> Thank you very much for explaining that Alexander, much clearer now.
> 
> It still doesn't explain why it seemed to work with python2, but I will 
> put this down to one of the reasons that python3 was written ;-)
> 
> In which case, I remove my 'NACK' and change it to RB+
> 
> Rowland
> 
> 
> 

Hello everyone,
I reported this problem some times.

If you google for "samba 4.7.0 AD DC: FSMO roles transfer error" there's a
thread (started on Oct 11, 2017) where we discussed about it and python version
was 2.7.12.

Daniele





More information about the samba-technical mailing list