diff --git common/src/java/org/apache/hadoop/hive/conf/HiveConf.java common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index da45f1a..e0e1339 100644 --- common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -350,7 +350,7 @@ METASTORE_AUTHORIZATION_STORAGE_AUTH_CHECKS("hive.metastore.authorization.storage.checks", false), METASTORE_EVENT_CLEAN_FREQ("hive.metastore.event.clean.freq",0L), METASTORE_EVENT_EXPIRY_DURATION("hive.metastore.event.expiry.duration",0L), - METASTORE_EXECUTE_SET_UGI("hive.metastore.execute.setugi", false), + METASTORE_EXECUTE_SET_UGI("hive.metastore.execute.setugi", true), METASTORE_PARTITION_NAME_WHITELIST_PATTERN( "hive.metastore.partition.name.whitelist.pattern", ""), // Whether to enable integral JDO pushdown. For partition columns storing integers diff --git metastore/src/java/org/apache/hadoop/hive/metastore/TUGIBasedProcessor.java metastore/src/java/org/apache/hadoop/hive/metastore/TUGIBasedProcessor.java index 423ee2c..ef1eee2 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/TUGIBasedProcessor.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/TUGIBasedProcessor.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.Socket; import java.security.PrivilegedExceptionAction; import java.util.List; @@ -59,7 +58,6 @@ functions; private final HadoopShims shim; - @SuppressWarnings("unchecked") public TUGIBasedProcessor(I iface) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { @@ -69,6 +67,7 @@ public TUGIBasedProcessor(I iface) throws SecurityException, NoSuchFieldExceptio shim = ShimLoader.getHadoopShims(); } + @SuppressWarnings("unchecked") @Override public boolean process(final TProtocol in, final TProtocol out) throws TException { setIpAddress(in); @@ -90,7 +89,7 @@ public boolean process(final TProtocol in, final TProtocol out) throws TExceptio // Store ugi in transport if the rpc is set_ugi if (msg.name.equalsIgnoreCase("set_ugi")){ try { - handleSetUGI(ugiTrans, fn, msg, in, out); + handleSetUGI(ugiTrans, (set_ugi)fn, msg, in, out); } catch (TException e) { throw e; } catch (Exception e) { @@ -105,6 +104,7 @@ public boolean process(final TProtocol in, final TProtocol out) throws TExceptio return true; } else { // Found ugi, perform doAs(). PrivilegedExceptionAction pvea = new PrivilegedExceptionAction() { + @Override public Void run() { try { fn.process(msg.seqid,in, out, iface); @@ -133,7 +133,7 @@ public Void run() { } private void handleSetUGI(TUGIContainingTransport ugiTrans, - ProcessFunction fn, TMessage msg, TProtocol iprot, TProtocol oprot) + set_ugi fn, TMessage msg, TProtocol iprot, TProtocol oprot) throws TException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException{ @@ -143,10 +143,7 @@ private void handleSetUGI(TUGIContainingTransport ugiTrans, "allowed. Current ugi is: " + clientUgi.getUserName())); } - // TODO get rid of following reflection after THRIFT-1465 is fixed. - Method method = fn.getClass().getDeclaredMethod("getEmptyArgsInstance", new Class[0]); - method.setAccessible(true); - set_ugi_args args = (set_ugi_args)method.invoke(fn, new Object[0]); + set_ugi_args args = fn.getEmptyArgsInstance(); try { args.read(iprot); } catch (TProtocolException e) { @@ -160,10 +157,7 @@ private void handleSetUGI(TUGIContainingTransport ugiTrans, return; } iprot.readMessageEnd(); - // TODO get rid of following reflection after THRIFT-1465 is fixed. - method = fn.getClass().getDeclaredMethod("getResult", Iface.class, set_ugi_args.class); - method.setAccessible(true); - set_ugi_result result = (set_ugi_result)method.invoke(fn, iface,args); + set_ugi_result result = fn.getResult(iface, args); List principals = result.getSuccess(); // Store the ugi in transport and then continue as usual. ugiTrans.setClientUGI(shim.createRemoteUser(principals.remove(principals.size()-1),