mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-28 11:39:07 +00:00
- Added Sufficient Permission check
This commit is contained in:
@@ -19,6 +19,7 @@ public class ServerBootSFG {
|
||||
public static final Map<String, Boolean> incompatibilities = new HashMap<>();
|
||||
public static boolean isJDK17 = true;
|
||||
public static boolean isJRE = false;
|
||||
public static boolean hasPrivileges = false;
|
||||
public static boolean unsuportedversion = false;
|
||||
protected static boolean safeguardPassed;
|
||||
public static boolean passedserversoftware = true;
|
||||
@@ -82,6 +83,11 @@ public class ServerBootSFG {
|
||||
joiner.add("Unsupported JDK");
|
||||
severityMedium++;
|
||||
}
|
||||
if (!hasPrivileges()){
|
||||
hasPrivileges = true;
|
||||
joiner.add("Has insufficient Privileges");
|
||||
severityHigh++;
|
||||
}
|
||||
|
||||
allIncompatibilities = joiner.toString();
|
||||
|
||||
@@ -122,6 +128,24 @@ public class ServerBootSFG {
|
||||
return path != null && checkJavac(path + File.separator + "bin");
|
||||
}
|
||||
|
||||
public static boolean hasPrivileges() {
|
||||
File pv = new File(Bukkit.getWorldContainer() + "iristest.json");
|
||||
if (pv.exists()){
|
||||
pv.delete();
|
||||
}
|
||||
try {
|
||||
if (pv.createNewFile()){
|
||||
if (pv.canWrite() && pv.canRead()){
|
||||
pv.delete();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkJavac(String path) {
|
||||
return !path.isEmpty() && (new File(path, "javac").exists() || new File(path, "javac.exe").exists());
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ public class UtilsSFG {
|
||||
Iris.safeguard(C.RED + "Unsupported Server Software");
|
||||
Iris.safeguard(C.RED + "- Please consider using Paper or Purpur instead.");
|
||||
}
|
||||
if (!ServerBootSFG.hasPrivileges) {
|
||||
Iris.safeguard(C.RED + "Insufficient Privileges");
|
||||
Iris.safeguard(C.RED + "- The server has insufficient Privileges to run iris. Please contact support.");
|
||||
}
|
||||
if (!ServerBootSFG.isJDK17) {
|
||||
Iris.safeguard(C.YELLOW + "Unsupported java version");
|
||||
Iris.safeguard(C.YELLOW + "- Please consider using JDK 17 Instead of JDK " + Iris.getJavaVersion());
|
||||
|
||||
@@ -83,7 +83,7 @@ public class TectonicPlate {
|
||||
public static TectonicPlate read(int worldHeight, File file) throws IOException, ClassNotFoundException {
|
||||
FileInputStream fin = new FileInputStream(file);
|
||||
DataInputStream din;
|
||||
if (file.getName().endsWith("ttp")) {
|
||||
if (file.getName().endsWith("ttp.lz4")) {
|
||||
GZIPInputStream gzi = new GZIPInputStream(fin);
|
||||
din = new DataInputStream(gzi);
|
||||
} else {
|
||||
@@ -174,7 +174,7 @@ public class TectonicPlate {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
DataOutputStream dos;
|
||||
if (file.getName().endsWith("ttp")) {
|
||||
if (file.getName().endsWith("ttp.lz4")) {
|
||||
GZIPOutputStream gzo = new GZIPOutputStream(fos);
|
||||
dos = new DataOutputStream(gzo);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user