Author: cws Date: Tue Sep 25 21:28:46 2012 New Revision: 1390155 URL: http://svn.apache.org/viewvc?rev=1390155&view=rev Log: HIVE-3277. Enable Metastore audit logging for non-secure connections (Sean Mackrory via cws)
Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java Modified: hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java URL: http://svn.apache.org/viewvc/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java?rev=1390155&r1=1390154&r2=1390155&view=diff ============================================================================== --- hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java (original) +++ hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java Tue Sep 25 21:28:46 2012 @@ -207,7 +207,7 @@ public class HiveMetaStore extends Thrif }; private final void logAuditEvent(String cmd) { - if (!useSasl || cmd == null) { + if (cmd == null) { return; } @@ -219,8 +219,19 @@ public class HiveMetaStore extends Thrif } final Formatter fmt = auditFormatter.get(); ((StringBuilder) fmt.out()).setLength(0); + + String address; + if (useSasl) { + address = saslServer.getRemoteAddress().toString(); + } else { + address = getIpAddress(); + } + if (address == null) { + address = "unknown-ip-addr"; + } + auditLog.info(fmt.format(AUDIT_FORMAT, ugi.getUserName(), - saslServer.getRemoteAddress().toString(), cmd).toString()); + address, cmd).toString()); } // The next serial number to be assigned