Bug 44601 - join script 33univention-portal.inst hangs if "nc" is provided by "netcat-traditional"
join script 33univention-portal.inst hangs if "nc" is provided by "netcat-tra...
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Update - Release updates
UCS 4.2
Other Linux
: P5 normal (vote)
: UCS 4.2-1-errata
Assigned To: Janek Walkenhorst
Felix Botner
:
Depends on:
Blocks: 45129
  Show dependency treegraph
 
Reported: 2017-05-15 15:56 CEST by Moritz Bunkus
Modified: 2017-09-05 08:03 CEST (History)
3 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 5: Blocking further progress on the daily work
User Pain: 0.429
Enterprise Customer affected?: Yes
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Moritz Bunkus 2017-05-15 15:56:09 CEST
This is an upgrade from 4.1 to 4.2. On all our servers the "nc" binary is provided by the "netcat-traditional" package. The package "netcat-openbsd" is not installed.

In such a setup the join script hangs in the following line:

if ! nc -w 10 "$ldap_master" "${ldap_master_port:-7389}"; then

The reason is that both netcat variants handle the "-w 10" parameter slightly differently. For netcat-openbsd, the timer starts to run as soon as the program starts. For netcat-traditional, however, the timer starts to run as soon as nc cannot read any input anymore. As input is read from STDIN, this hangs until the user presses Ctrl+D. Ten seconds later nc from netcat-traditional will exit, too.

Meaning one can use "Ctrl+D" in order to continue a seemingly hanging execution of "33univention-portal.inst".

One possible workaround is to redirect nc's STDIN from /dev/null. Unfortunately nc.traditional still hangs for 10 seconds, even with STDIN being redirected.

Here are two tests with "STDIN < /dev/null", one for each nc variant, once with a reachable port (7389), once with an unreachable one (7388):

------------------------------------------------------------
[0 root@master ~] date ; nc.openbsd -w 10 master.mbu-test.intranet 7388 < /dev/null ; echo $? ; date
Mo 15. Mai 15:46:39 CEST 2017
1
Mo 15. Mai 15:46:39 CEST 2017
[0 root@master ~] date ; nc.openbsd -w 10 master.mbu-test.intranet 7389 < /dev/null ; echo $? ; date
Mo 15. Mai 15:46:43 CEST 2017
0
Mo 15. Mai 15:46:43 CEST 2017
[0 root@master ~] date ; nc.traditional -w 10 master.mbu-test.intranet 7388 < /dev/null ; echo $? ; date
Mo 15. Mai 15:46:50 CEST 2017
master.mbu-test.intranet [10.191.1.1] 7388 (?) : Connection refused
1
Mo 15. Mai 15:46:50 CEST 2017
[0 root@master ~] date ; nc.traditional -w 10 master.mbu-test.intranet 7389 < /dev/null ; echo $? ; date
Mo 15. Mai 15:46:57 CEST 2017
0
Mo 15. Mai 15:47:17 CEST 2017
------------------------------------------------------------

The proper solution would be to make one of Univention's common packages (e.g. "univention-server-common") depend on netcat-openbsd, and to call "nc.openbsd" in the join script. Calling "nc" will still call "/etc/alternatives/nc" which a join script (or any other script) cannot rely on being anything in particular.

Other scripts use "nc", too, and should be checked as well:

------------------------------------------------------------
[0 root@master ~] grep -Pr '\bnc\b' /usr/lib/univention-install
/usr/lib/univention-install/33univention-portal.inst:if ! nc -w 10 "$ldap_master" "${ldap_master_port:-7389}"; then
/usr/lib/univention-install/15univention-directory-notifier-post.inst:          nc -z localhost 6669 && break
[0 root@master ~]
------------------------------------------------------------
Comment 1 Moritz Bunkus 2017-05-15 16:00:09 CEST
I have to add that having "netcat-traditional" installed instead of "netcat-openbsd" wasn't a conscious decision. It just turned out to be the case. The server were originally installed with 3.1 back in the day; they've been upgraded since.
Comment 2 Moritz Bunkus 2017-05-18 17:02:41 CEST
More information.

netcat-traditional is a dependency of netcat which is a dependency of several univention-* packages on UCS 4.1. Therefore it isn't possible to remove it.

Installing netcat-openbsd in parallel to netcat-traditional is possible on UCS 4.1.

Due to the timeout issues mentioned in my original post, I propose you implement the following:

1. change the UCS 4.2 upgrade script to install netcat-openbsd as early as possible
2. All packages whose join scripts use nc must depend on netcat-openbsd.
3. All join scripts should be changed from calling nc to call nc.openbsd instead.
Comment 3 Tobias Birkefeld univentionstaff 2017-07-06 14:57:21 CEST
I can confirm this issue in another customer environment. This issue blocks the update progress. Only by kill the nc process during the update and uncomment the specific lines in "33univention-portal.inst" fix the problem during the update.

I will test on another system if the workaround with installed "netcat-openbsd" fix it for me.
Comment 4 Timo Denissen univentionstaff 2017-07-06 14:59:46 CEST
This also occured during internal updates from UCS 4.1-4 to UCS 4.2 with i386 systems.
Comment 5 Stefan Gohmann univentionstaff 2017-07-18 07:46:15 CEST
We should "fix" it in our 4.2-0 preup.sh script.
Comment 6 Janek Walkenhorst univentionstaff 2017-07-28 15:19:49 CEST
(In reply to Stefan Gohmann from comment #5)
> We should "fix" it in our 4.2-0 preup.sh script.

r81530
Bug #44601: require netcat-openbsd for the update to proceed
Comment 7 Felix Botner univentionstaff 2017-08-07 13:59:18 CEST
OK - test works, preup update on external server via Bug #44924
Comment 8 Stefan Gohmann univentionstaff 2017-09-05 08:03:09 CEST
(In reply to Felix Botner from comment #7)
> OK - test works, preup update on external server via Bug #44924

It can be closed because it has been released.