You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by yu...@apache.org on 2013/08/21 11:43:29 UTC
[2/3] git commit: TS-2141: Inconsistent euid cause bad
mgmtapi/eventapi sockets
TS-2141: Inconsistent euid cause bad mgmtapi/eventapi sockets
In the main function of traffic_manager, webIntr_main thread is created
after euid has been changed to "proxy.config.admin.user_id".
And then, webIntr_main thread will create mgmtapisocket/eventapisocket
socket fd, and listen on them.
But unfortunately, after created webIntr_main thread, the main thread
will call listenForProxy()->bindProxyPort() immediately, which might
change/restore euid concurrently.
For example:
1) bindProxyPort() change the euid to 0(root uid).
2) webIntr_main creates mgmtapisocket with 0 euid.
3) bindProxyPort() restore the euid to 501(admin.user_id)
4) webIntr_main calls chmod(0777) on mgmtapisocket, it'll get
"Operation not permitted" error and other unexpected errors.
As the api sockets can't be created correctly, traffic_cop will failed to
establish heartbeat with traffic_manager, and than traffic_cop will kill
traffic_manager automatically.
But more worse, after killed and restarted manager, traffic_cop forgets to
reconnect to manager, so it will use bad main_socket_fd to detect heartbeat
of manager. Of course, it'll faill to detect and than kill/restart manager
again and again and again.
I'll give another patch to fix reconnect problem of traffic_cop which seems
casued by an old commit:ba95f9c6e8c49f69f018885f255db02f31d7335f.
Signed-off-by: Yunkai Zhang <qi...@taobao.com>
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ce9188b5
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ce9188b5
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ce9188b5
Branch: refs/heads/master
Commit: ce9188b5a68487669470c11d734a58807312201b
Parents: f4f8d99
Author: Yunkai Zhang <qi...@taobao.com>
Authored: Tue Aug 20 16:19:22 2013 +0800
Committer: Yunkai Zhang <qi...@taobao.com>
Committed: Wed Aug 21 17:42:44 2013 +0800
----------------------------------------------------------------------
mgmt/Main.cc | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ce9188b5/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index a5c4483..9eb6904 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -722,9 +722,17 @@ main(int argc, char **argv)
// Now that we know our cluster ip address, add the
// UI record for this machine
overviewGenerator->addSelfRecord();
+
+ lmgmt->listenForProxy();
+
+ //
+ // As listenForProxy() may change/restore euid, we should put
+ // the creation of webIntr_main thread after it. So that we
+ // can keep a consistent euid when create mgmtapi/eventapi unix
+ // sockets in webIntr_main thread.
+ //
webThrId = ink_thread_create(webIntr_main, NULL); /* Spin web agent thread */
Debug("lm", "Created Web Agent thread (%" PRId64 ")", (int64_t)webThrId);
- lmgmt->listenForProxy();
ticker = time(NULL);
mgmt_log("[TrafficManager] Setup complete\n");