Skip to content

Commit 90cb7d2

Browse files
committed
always filter out auth secret
1 parent af4d89d commit 90cb7d2

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

core/src/main/scala/org/apache/spark/deploy/worker/CommandUtils.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,14 @@ object CommandUtils extends Logging {
9191
if (securityMgr.isAuthenticationEnabled) {
9292
newEnvironment += (SecurityManager.ENV_AUTH_SECRET -> securityMgr.getSecretKey)
9393
}
94-
// filter out auth secret from java opts
95-
val javaOpts = if (securityMgr.isAuthenticationEnabled) {
96-
command.javaOpts.filterNot(_.startsWith("-D" + SecurityManager.SPARK_AUTH_SECRET_CONF))
97-
} else {
98-
command.javaOpts
99-
}
10094

10195
Command(
10296
command.mainClass,
10397
command.arguments.map(substituteArguments),
10498
newEnvironment,
10599
command.classPathEntries ++ classPath,
106100
Seq[String](), // library path already captured in environment variable
107-
javaOpts)
101+
command.javaOpts.filterNot(_.startsWith("-D" + SecurityManager.SPARK_AUTH_SECRET_CONF)))
108102
}
109103

110104
/** Spawn a thread that will redirect a given stream to a file */

core/src/test/scala/org/apache/spark/deploy/worker/CommandUtilsSuite.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ class CommandUtilsSuite extends SparkFunSuite with Matchers with PrivateMethodTe
3636
assert(env.get(libraryPath).startsWith("libraryPathToB"))
3737
}
3838

39-
test("Auth secret shouldn't appear in java opts") {
39+
test("auth secret shouldn't appear in java opts") {
4040
val buildLocalCommand = PrivateMethod[Command]('buildLocalCommand)
41-
val command = new Command("mainClass", Seq(), Map(), Seq(), Seq("libraryPathToB"), Seq())
4241
val conf = new SparkConf
43-
// set auth secret
4442
val secret = "This is the secret sauce"
43+
// set auth secret
4544
conf.set(SecurityManager.SPARK_AUTH_SECRET_CONF, secret)
45+
val command = new Command("mainClass", Seq(), Map(), Seq(), Seq("lib"),
46+
Seq("-D" + SecurityManager.SPARK_AUTH_SECRET_CONF + "=" + secret))
4647

4748
// auth is not set
4849
var cmd = CommandUtils invokePrivate buildLocalCommand(

0 commit comments

Comments
 (0)