Permalink
Browse files

Fix to allow mounting DVD iso images as non-root

  • Loading branch information...
1 parent b854896 commit d875d8c427ebe6e3a0d4ae01af2a904b02a0a648 @stuckless stuckless committed Dec 1, 2016
Showing with 26 additions and 6 deletions.
  1. +1 −1 build.gradle
  2. +23 −4 java/sage/FSManager.java
  3. +2 −1 java/sage/Sage.java
View
@@ -1,7 +1,7 @@
import org.gradle.internal.os.OperatingSystem
plugins {
- id "com.jfrog.bintray" version "1.3.1"
+ id "com.jfrog.bintray" version "1.7.3"
}
apply plugin: "java"
@@ -411,10 +411,24 @@ public String requestLargeTempStorageDir(long minFreeSpace)
}
else
{
- if (IOUtils.exec2(new String[] { Sage.get("linux/dvdmounter", "mount"), isoFile.getAbsolutePath(), mountDir.getAbsolutePath(), "-o", "loop" }, true) != 0)
+ if (!Sage.LINUX_IS_ROOT)
{
- if (Sage.DBG) System.out.println("FAILED mounting ISO image " + isoFile + " to " + mountDir);
- return null;
+ // mount requires root permissions
+ // the sagetv user needs to be in the sudoers list
+ // NOTE mount command is NOT resolved in properties because sudo is being used
+ if (IOUtils.exec2(new String[]{"sudo","mount", isoFile.getAbsolutePath(), mountDir.getAbsolutePath(), "-o", "loop,ro"}, true) != 0)
+ {
+ if (Sage.DBG) System.out.println("FAILED mounting ISO image " + isoFile + " to " + mountDir);
+ return null;
+ }
+ }
+ else
+ {
+ if (IOUtils.exec2(new String[]{Sage.get("linux/dvdmounter", "mount"), isoFile.getAbsolutePath(), mountDir.getAbsolutePath(), "-o", "loop"}, true) != 0)
+ {
+ if (Sage.DBG) System.out.println("FAILED mounting ISO image " + isoFile + " to " + mountDir);
+ return null;
+ }
}
}
return mountDir;
@@ -478,7 +492,12 @@ public void releaseISOMount(java.io.File mountDir)
}
}
else
- IOUtils.exec2(new String[] { "umount", mountDir.getAbsolutePath() }, false);
+ {
+ if (Sage.LINUX_IS_ROOT)
+ IOUtils.exec2(new String[]{"umount", mountDir.getAbsolutePath()}, false);
+ else
+ IOUtils.exec2(new String[]{"sudo","umount", mountDir.getAbsolutePath()}, false);
+ }
mountDir.delete();
}
}
View
@@ -86,6 +86,7 @@
static final boolean DISABLE_MSG_LOOP_FOR_JPROFILER = false;
public static boolean WINDOWS_OS = false;
public static boolean LINUX_OS = false;
+ public static boolean LINUX_IS_ROOT = false; // will be true if SageTV Linux is running as 'root'
public static boolean MAC_OS_X = false;
public static boolean VISTA_OS = false; // if this is true, then WINDOWS_OS is also true
public static boolean EMBEDDED = false;
@@ -117,7 +118,7 @@
MAC_OS_X = System.getProperty("os.name").toLowerCase().indexOf("mac os x") != -1;
LINUX_OS = !WINDOWS_OS && !MAC_OS_X;
VISTA_OS = WINDOWS_OS && (System.getProperty("os.version").startsWith("6.") || System.getProperty("os.version").startsWith("7."));
-
+ LINUX_IS_ROOT = "root".equals(System.getProperty("user.name"));
if (WINDOWS_OS)
sage.Native.loadLibrary("SageTVWin32");
else

0 comments on commit d875d8c

Please sign in to comment.