[Samba] samba-tool user syncpasswords crashes with python3
heinz.hoelzl at gvcc.net
Mon Oct 7 09:52:14 UTC 2019
I think, i found the error:
in /usr/local/samba/lib/python3.6/site-packages/samba/netcmd/user.py on
def run_sync_command(dn, ldif):
log_msg("Call Popen[%s] for %s\n" % (self.sync_command,
sync_command_p = Popen(self.sync_command,
res = sync_command_p.poll()
assert res is None
input = "%s" % (ldif)
reply = sync_command_p.communicate(input)
input and ldif are Strings, but the type of input in
Popen.communicate(input) must by bytes.
The python3.6 documentation :
Interact with process: Send data to stdin. Read data from stdout and
stderr, until end-of-file is reached. Wait for process to terminate.
The optional input argument should be data to be sent to the child
process, or None, if no data should be sent to the child. The type of
input must be bytes.
so, converting input to bytes and replay to string solves the problem.
#reply = sync_command_p.communicate(input)
reply = sync_command_p.communicate(input.encode()).decode()
Am Freitag, den 04.10.2019, 21:45 +0100 schrieb Rowland penny via
> On 04/10/2019 15:28, Heinz Hölzl via samba wrote:
> > the script works...
> The script may work when you run it manually, but the error samba-
> throws is this:
> ERROR(<class 'TypeError'>): uncaught exception - memoryview: a
> bytes-like object is required, not 'str'
> If you examine the error, samba-tool runs your script with this:
> line 2001, in run_sync_command
> reply = bytes(sync_command_p.communicate(input), encoding =
> After that 'subprocess.py' is called and the error seems to coming
> there. Samba doesn't import all of 'subprocess', it only does this:
> subprocess import Popen, PIPE, STDOUT, check_call, CalledProcessError
> The error output goes on to do this:
> File "/usr/lib/python3.6/subprocess.py", line 863, in communicate
> stdout, stderr = self._communicate(input, endtime, timeout)
> File "/usr/lib/python3.6/subprocess.py", line 1519, in
> input_view = memoryview(self._input)
> And it is 'memoryview' that throws the error and it looks like it is
> something in subprocess.py that is wrong, or something in your
> Samba, as far as I can see, does not use 'memoryview' directly.
More information about the samba