YARN-10228. Relax restriction of file path character in yarn.service.am.java.opts.
Contributed by Bilwa S T via eyang
This commit is contained in:
parent
e452163a06
commit
d7cf19d7c0
@ -250,7 +250,7 @@ public static void validateAndResolveService(Service service,
|
||||
|
||||
public static void validateJvmOpts(String jvmOpts)
|
||||
throws IllegalArgumentException {
|
||||
Pattern pattern = Pattern.compile("[!~#?@*&%${}()<>\\[\\]|\"\\/,`;]");
|
||||
Pattern pattern = Pattern.compile("[!~#?@*&%${}()<>\\[\\]|\",`;]");
|
||||
Matcher matcher = pattern.matcher(jvmOpts);
|
||||
if (matcher.find()) {
|
||||
throw new IllegalArgumentException(
|
||||
|
@ -46,10 +46,12 @@
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
|
||||
import static org.apache.hadoop.yarn.service.conf.RestApiConstants.DEFAULT_UNLIMITED_LIFETIME;
|
||||
import static org.apache.hadoop.yarn.service.exceptions.RestApiErrorMessages.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Test for ServiceApiUtil helper methods.
|
||||
@ -766,10 +768,19 @@ public void run() {
|
||||
Assert.assertTrue(thread.isAlive());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testJvmOpts() {
|
||||
String jvmOpts = "`ping -c 3 example.com`";
|
||||
ServiceApiUtil.validateJvmOpts(jvmOpts);
|
||||
@Test
|
||||
public void testJvmOpts() throws Exception {
|
||||
String invalidJvmOpts = "`ping -c 3 example.com`";
|
||||
intercept(IllegalArgumentException.class,
|
||||
"Invalid character in yarn.service.am.java.opts.",
|
||||
() -> ServiceApiUtil.validateJvmOpts(invalidJvmOpts));
|
||||
String validJvmOpts = "-Dyarn.service.am.java.opts=-Xmx768m "
|
||||
+ "-Djava.security.auth.login.config=/opt/hadoop/etc/jaas-zk.conf";
|
||||
try {
|
||||
ServiceApiUtil.validateJvmOpts(validJvmOpts);
|
||||
} catch (Exception ex) {
|
||||
fail("Invalid character in yarn.service.am.java.opts.");
|
||||
}
|
||||
}
|
||||
|
||||
public static Service createExampleApplication() {
|
||||
|
Loading…
Reference in New Issue
Block a user