Skip to content

Commit aaca493

Browse files
tanvnGitHub Enterprise
authored andcommitted
VINITUS-351: backport SPARK-38992 (apache#16)
1 parent 949cb47 commit aaca493

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/src/main/scala/org/apache/spark/security/ShellBasedGroupsMappingProvider.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import org.apache.spark.util.Utils
3030
private[spark] class ShellBasedGroupsMappingProvider extends GroupMappingServiceProvider
3131
with Logging {
3232

33+
private lazy val idPath = Utils.executeAndGetOutput("which" :: "id" :: Nil).stripLineEnd
34+
3335
override def getGroups(username: String): Set[String] = {
3436
val userGroups = getUnixGroups(username)
3537
logDebug("User: " + username + " Groups: " + userGroups.mkString(","))
@@ -38,8 +40,7 @@ private[spark] class ShellBasedGroupsMappingProvider extends GroupMappingService
3840

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

0 commit comments

Comments
 (0)