diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/SecureCmdDoAs.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/SecureCmdDoAs.java index 619aa1f..15716fc 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/SecureCmdDoAs.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/SecureCmdDoAs.java @@ -38,6 +38,7 @@ */ public class SecureCmdDoAs { private final Path tokenPath; + private final File tokenFile; public SecureCmdDoAs(HiveConf conf) throws HiveException, IOException{ // Get delegation token for user from filesystem and write the token along with @@ -46,8 +47,8 @@ public SecureCmdDoAs(HiveConf conf) throws HiveException, IOException{ FileSystem fs = FileSystem.get(conf); Token fsToken = fs.getDelegationToken(uname); - File t = File.createTempFile("hive_hadoop_delegation_token", null); - tokenPath = new Path(t.toURI()); + tokenFile = File.createTempFile("hive_hadoop_delegation_token", null); + tokenPath = new Path(tokenFile.toURI()); //write credential with token to file Credentials cred = new Credentials(); @@ -60,4 +61,7 @@ public void addEnv(Map env){ tokenPath.toUri().getPath()); } + public void close() { + tokenFile.delete(); + } } diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/MapredLocalTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/MapredLocalTask.java index 9f3df99..d36d003 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/MapredLocalTask.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/mr/MapredLocalTask.java @@ -97,6 +97,7 @@ private ExecMapperContext execContext = null; private Process executor; + private SecureCmdDoAs secureDoAs; public MapredLocalTask() { super(); @@ -271,7 +272,7 @@ public int executeInChildVM(DriverContext driverContext) { //If kerberos security is enabled, and HS2 doAs is enabled, // then additional params need to be set so that the command is run as // intended user - SecureCmdDoAs secureDoAs = new SecureCmdDoAs(conf); + secureDoAs = new SecureCmdDoAs(conf); secureDoAs.addEnv(variables); } @@ -314,9 +315,12 @@ public int executeInChildVM(DriverContext driverContext) { return exitVal; } catch (Exception e) { - e.printStackTrace(); - LOG.error("Exception: " + e.getMessage()); + LOG.error("Exception: " + e, e); return (1); + } finally { + if (secureDoAs != null) { + secureDoAs.close(); + } } }