Bug 14154 - samba-tool user syncpasswords sync_command_p.communicate python3 bytes- like object is required
Summary: samba-tool user syncpasswords sync_command_p.communicate python3 bytes- like ...
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Python (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: 4.12
Assignee: Douglas Bagnall
QA Contact: Samba QA Contact
URL:
Keywords:
: 14231 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-10-08 15:42 UTC by heinz hoelzl
Modified: 2020-01-08 20:07 UTC (History)
5 users (show)

See Also:


Attachments
logfile (1.53 KB, text/plain)
2019-10-08 15:42 UTC, heinz hoelzl
no flags Details
patch for master (1.02 KB, patch)
2019-10-09 21:38 UTC, Douglas Bagnall
no flags Details
patch for master (1.16 KB, patch)
2019-10-16 00:05 UTC, Douglas Bagnall
bbaumbach: review+
dbagnall: review? (abartlet)
bbaumbach: ci-passed+
Details
patch for 4.10 (1.50 KB, patch)
2019-10-16 00:07 UTC, Douglas Bagnall
no flags Details
patch for 4.11 (1.15 KB, patch)
2019-10-16 00:08 UTC, Douglas Bagnall
no flags Details
4.10 patch with (backported from...) (1.56 KB, patch)
2019-10-16 00:26 UTC, Douglas Bagnall
no flags Details
4.11 patch with cherry-pick -x message (1.22 KB, patch)
2019-10-16 00:27 UTC, Douglas Bagnall
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description heinz hoelzl 2019-10-08 15:42:09 UTC
Created attachment 15519 [details]
logfile

in /usr/local/samba/lib/python3.6/site-packages/samba/netcmd/user.py on line 2001 is called:

reply = sync_command_p.communicate(input)[0]

The type of input is 'str', but in python3.6 the type of input must by bytes.

see:
https://docs.python.org/3.6/library/asyncio-subprocess.html


As a result of this /usr/local/samba/bin/samba-tool user syncpasswords --daemon crashes.


converting the stream to bytes solves the problem:
reply = sync_command_p.communicate(input.encode())[0].decode()

As attachment you get the logfile
Comment 1 Douglas Bagnall 2019-10-09 21:38:04 UTC
Created attachment 15523 [details]
patch for master

Thanks Heinz.

I have formatted your fix as a patch for master. The patch will apply on 4.11, but we may need to do some more fiddling for 4.10 (because it also needs to run with Python 2.7).

There are two things you need to do:

* agree to have a 'Signed-off-by: <you>' line above the Reviewed-by.

* consider whether you need to do a DCO as per the Samba copyright page:
   https://www.samba.org/samba/devel/copyright-policy.html
Comment 2 heinz hoelzl 2019-10-15 05:40:58 UTC
i agree to have a 'Signed-off-by: Heinz Hölzl <heinz.hoelzl@gvcc.net>' line above the Reviewed-by.

i do not need to do a DCO.
Comment 3 Douglas Bagnall 2019-10-16 00:05:24 UTC
Created attachment 15546 [details]
patch for master
Comment 4 Douglas Bagnall 2019-10-16 00:07:51 UTC
Created attachment 15547 [details]
patch for 4.10

the 4.10 patch is slightly inelegant because it has to deal with python 2.
Comment 5 Douglas Bagnall 2019-10-16 00:08:17 UTC
Created attachment 15548 [details]
patch for 4.11
Comment 6 Douglas Bagnall 2019-10-16 00:26:11 UTC
Created attachment 15549 [details]
4.10 patch with (backported from...)
Comment 7 Douglas Bagnall 2019-10-16 00:27:31 UTC
Created attachment 15550 [details]
4.11 patch with cherry-pick -x message
Comment 8 Douglas Bagnall 2019-10-16 00:39:24 UTC
Comment on attachment 15549 [details]
4.10 patch with (backported from...)

oops, not in master yet
Comment 9 Björn Baumbach 2019-10-23 14:34:43 UTC
Comment on attachment 15546 [details]
patch for master

I tried the patch and it's working.

Selftest is also ok:
https://gitlab.com/samba-team/devel/samba/pipelines/90240653

I've added my RB, pushed it to master and the autobuild is currently running.
Comment 10 Björn Jacke 2020-01-08 20:07:39 UTC
*** Bug 14231 has been marked as a duplicate of this bug. ***