Skip to content

Commit

Permalink
VINITUS-351: backport SPARK-38992 (apache#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanvn authored and GitHub Enterprise committed Jul 28, 2022
1 parent 949cb47 commit aaca493
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import org.apache.spark.util.Utils
private[spark] class ShellBasedGroupsMappingProvider extends GroupMappingServiceProvider
with Logging {

private lazy val idPath = Utils.executeAndGetOutput("which" :: "id" :: Nil).stripLineEnd

override def getGroups(username: String): Set[String] = {
val userGroups = getUnixGroups(username)
logDebug("User: " + username + " Groups: " + userGroups.mkString(","))
Expand All @@ -38,8 +40,7 @@ private[spark] class ShellBasedGroupsMappingProvider extends GroupMappingService

// shells out a "bash -c id -Gn username" to get user groups
private def getUnixGroups(username: String): Set[String] = {
val cmdSeq = Seq("bash", "-c", "id -Gn " + username)
// we need to get rid of the trailing "\n" from the result of command execution
Utils.executeAndGetOutput(cmdSeq).stripLineEnd.split(" ").toSet
Utils.executeAndGetOutput(idPath :: "-Gn" :: username :: Nil).stripLineEnd.split(" ").toSet
}
}

0 comments on commit aaca493

Please sign in to comment.