From owner-freebsd-bugs@freebsd.org Sat Dec 24 19:55:36 2016 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 290ECC8FFD0 for ; Sat, 24 Dec 2016 19:55:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0E1911373 for ; Sat, 24 Dec 2016 19:55:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOJtZRA036945 for ; Sat, 24 Dec 2016 19:55:35 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 215540] ntpd fails to start when ran via ssh with pseudo-terminal and terminals/connection are closed before child opens new fds Date: Sat, 24 Dec 2016 19:55:36 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 11.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: dereks@lifeofadishwasher.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Dec 2016 19:55:36 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D215540 Bug ID: 215540 Summary: ntpd fails to start when ran via ssh with pseudo-terminal and terminals/connection are closed before child opens new fds Product: Base System Version: 11.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: freebsd-bugs@FreeBSD.org Reporter: dereks@lifeofadishwasher.com ntpd fails to start if terminals are closed before ntpd's child process can open new fds. Testing with HAVE_CLOSEFROM in config.h doesn't have this is= sue. Before restrarting ntpd from A: $ ntpq -pn remote refid st t when poll reach delay offset=20 jitter =20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D north-america.p .POOL. 16 p - 64 0 0.000 0.000=20= =20 0.002 *50.22.155.163 209.51.161.238 2 u 1 64 1 87.964 -2.998=20= =20 2.572 ... Using something like the following to restart ntp on an array of machines: for m in A B C; do ssh -t "$m" 'sudo service ntpd restart' ; done Later from host A: ... Dec 23 18:40:57 A ntpd[80966]: ntpd 4.2.8p9-a (1): Starting ... $ ntpq -pn ntpq: read: Connection refused ... ntpd fails to finish starting up and silently fails. The same is true from= B and C. Running the same without ssh's -t or sleeping before the connection closes allows ntpd child to startup. This assumes the user can run sudo without a password: for m in A B C; do ssh "$m" 'sudo service ntpd restart' ; done or for m in A B C; do ssh -t "$m" 'sudo service ntpd restart; sleep 1' ; done Testing ntpd from the relang/11.0 branch with '#define HAVE_CLOSEFROM 1' in config.h appears to solve the problem. This will cause libntp/ntp_worker.c close_all_beyond() to use closefrom(2) = that appears to not suffer the same issue as the two other ifdef's. However, the issue appears to be contrib/ntp/ doesn't have a test to see if= the system has closefrom(2) so it appears we have to add it manually? This was initially found when restarting ntpd on a legion of machines via ansible. I'd suspect other config management tools that use ssh with pseudo-terminals would suffer the same issue. The above is a raw example = of what something like ansible might perform. This is also a problem in 9.3 and 10.x --=20 You are receiving this mail because: You are the assignee for the bug.=