hadoop-hdfs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From canan chen <ccn...@gmail.com>
Subject Can I run a process under impersonation ?
Date Mon, 22 Aug 2016 06:22:08 GMT
I'd like to use UGI.doAs to implement impersonation. But it seems I can not
run a process in doAs.

The following is my code,  the impersonation works if I call the FileSystem
api directly, but it doesn't work if I run it in a process.  Could anyone
help me on that ? Thanks

val ugi = UserGroupInformation.createProxyUser("userA",
UserGroupInformation.getLoginUser)

ugi.doAs(new PrivilegedExceptionAction[Void] {
  def run(): Void = {
    val fs = FileSystem.get(new Configuration())
    fs.globStatus(new Path(".")).foreach(println(_))  // it works in
impersonation
    println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
    val processBuilder = new ProcessBuilder()
    processBuilder.environment()
    processBuilder.command("/Users/cc/hadoop-2.7.2/bin/hadoop", "fs",
"-ls", ".")   // it doesn't work in impersonation
    processBuilder.inheritIO()
    val proc = processBuilder.start()
    proc.waitFor()
    return null
  }
})

Mime
View raw message