[m-rev.] diff: replace use of the Java security manager
Julien Fischer
jfischer at opturion.com
Tue Jan 16 11:37:37 AEDT 2024
Replace use of the Java security manager.
The security manager was deprecated in Java 17 and recent versions of Java now
emit warnings about its use; replace its use.
library/io.call_system.m:
Instead of using the security manager methods to check whether
"/bin/sh" is executable, use the methods provided by the java.nio
package.
Julien.
diff --git a/library/io.call_system.m b/library/io.call_system.m
index 161e100..c9d0d45 100644
--- a/library/io.call_system.m
+++ b/library/io.call_system.m
@@ -207,15 +207,8 @@ call_system_return_signal(Command, Result, !IO) :-
"
boolean has_sh;
try {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkExec(""/bin/sh"");
- has_sh = true;
- } else {
- // If there is no security manager installed, we just check
- // if the file exists.
- has_sh = new java.io.File(""/bin/sh"").exists();
- }
+ has_sh = java.nio.file.Files.isExecutable(
+ java.nio.file.Paths.get(""/bin/sh""));
} catch (java.lang.Exception e) {
has_sh = false;
}
@@ -262,7 +255,7 @@ call_system_return_signal(Command, Result, !IO) :-
throw stderr.exception;
}
} catch (java.lang.Exception e) {
- Status = 1;
+ Status = 1;
Error = e;
}
").
More information about the reviews
mailing list