Repository: kudu Updated Branches: refs/heads/master bd4361254 -> de1b95929
fix MiniKdc lsof usage on Ubuntu 16.04 Another instance of the bug fixed by commit 57ccc9a (though it was actually version 4.88 of lsof that made the change, not 4.89; see the changelog [1] for more details). 1. ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ChangeLog Change-Id: I0e49dd8d6b6c0ac05edeff327602b971ea8516db Reviewed-on: http://gerrit.cloudera.org:8080/4919 Reviewed-by: Dan Burkert <[email protected]> Reviewed-by: Alexey Serbin <[email protected]> Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/de1b9592 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/de1b9592 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/de1b9592 Branch: refs/heads/master Commit: de1b959296d982dd4ecee9d6c5d7fe8a177a63d2 Parents: bd43612 Author: Adar Dembo <[email protected]> Authored: Wed Nov 2 12:44:29 2016 -0700 Committer: Adar Dembo <[email protected]> Committed: Wed Nov 2 21:41:28 2016 +0000 ---------------------------------------------------------------------- src/kudu/security/mini_kdc.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/de1b9592/src/kudu/security/mini_kdc.cc ---------------------------------------------------------------------- diff --git a/src/kudu/security/mini_kdc.cc b/src/kudu/security/mini_kdc.cc index 3da68ba..8cb73eb 100644 --- a/src/kudu/security/mini_kdc.cc +++ b/src/kudu/security/mini_kdc.cc @@ -257,7 +257,7 @@ Status MiniKdc::WaitForKdcPorts() { RETURN_NOT_OK(GetBinaryPath("lsof", {"/sbin", "/usr/sbin"}, &lsof)); vector<string> cmd = { - lsof, "-wbn", "-Fn", + lsof, "-wbn", "-Ffn", "-p", std::to_string(kdc_process_->pid()), "-a", "-i", "4TCP"}; @@ -276,16 +276,18 @@ Status MiniKdc::WaitForKdcPorts() { SleepFor(MonoDelta::FromMilliseconds(i * i)); } - // The '-Fn' flag gets lsof to output something like: + // The '-Ffn' flag gets lsof to output something like: // p19730 + // f123 // n*:41254 - // The first line is the pid, which we already know. The second has the - // bind address and port. + // The first line is the pid. We ignore it. + // The second line is the file descriptor number. We ignore it. + // The third line has the bind address and port. vector<string> lines = strings::Split(lsof_out, "\n"); int32_t port = -1; - if (lines.size() != 2 || - lines[1].substr(0, 3) != "n*:" || - !safe_strto32(lines[1].substr(3), &port) || + if (lines.size() != 3 || + lines[2].substr(0, 3) != "n*:" || + !safe_strto32(lines[2].substr(3), &port) || port <= 0) { return Status::RuntimeError("unexpected lsof output", lsof_out); }
