diff --git a/src/Makefile.test.include b/src/Makefile.test.include index eb24f522c2..52dff5e1e3 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -113,7 +113,7 @@ if ENABLE_WALLET test_test_beta_LDADD += $(LIBBITCOIN_WALLET) endif -test_test_beta_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_LIBS) +test_test_beta_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) test_test_beta_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static if ENABLE_ZMQ diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 04d3386e9a..c335fb016c 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -172,6 +172,14 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &) return false; } + //Set thread-local storage variable to RPC user name for logging + std::string strUserPass64 = authHeader.second.substr(6); + boost::trim(strUserPass64); + std::string strUserPass = DecodeBase64(strUserPass64); + if (!userInstance.get()) { + userInstance.reset(new std::string(strUserPass.substr(0, strUserPass.find(":")))); + } + JSONRequest jreq; try { // Parse request diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 5925ba389a..3abf44be88 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -25,6 +25,11 @@ #include #include // for to_upper() +//For thread local rpc username +#include +//Thread local rpc user name for logging purposes +boost::thread_specific_ptr userInstance; + using namespace RPCServer; using namespace std; diff --git a/src/rpc/server.h b/src/rpc/server.h index b5ccc153d0..da6ca01791 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -17,8 +17,13 @@ #include +#include + #include +//Thread-local rpc user name for logging purposes +extern boost::thread_specific_ptr userInstance; + class CRPCCommand; namespace RPCServer