mediathekview / MediathekView

Das Programm MediathekView durchsucht die Online-Mediatheken verschiedener Sender
https://mediathekview.de
GNU General Public License v3.0
855 stars 95 forks source link

Problem loading SQLite driver if /tmp is mounted noexec #589

Closed tinxx closed 3 years ago

tinxx commented 3 years ago

I was having trouble starting MediathekView since latest version 13.7.0.

As a general security precaution /tmp is mounted with the flag noexec on my system.

Now, when I try and start MediathekView it seems to create its JBDC driver in /tmp and then tries executing it.
That fails with the following log:

. Portable Mode: false
. Programmstart: 2021-01-26T12:33:08.476389297
. Version: 13.7.0
. === JavaVM Parameter ===
--enable-preview
. ========================
. Verzeichnis Einstellungen: /home/someone/.mediathek3
. Konfig existiert nicht!
. Es gibt kein Backup
. Weder Konfig noch Backup konnte geladen werden!
. MVHttpClient: Proxy not configured
. Could not read bookmarks from file /home/someone/.mediathek3/bookmarks.json, error /home/someone/.mediathek3/bookmarks.json (No such file or directory) => file ignored
. No custom font size found.
Failed to load native library:sqlite-3.32.3.2-7a4810e0-158b-46ec-bace-993ebb1d035c-libsqlitejdbc.so. osinfo: Linux/x86_64
java.lang.UnsatisfiedLinkError: /tmp/sqlite-3.32.3.2-7a4810e0-158b-46ec-bace-993ebb1d035c-libsqlitejdbc.so: /tmp/sqlite-3.32.3.2-7a4810e0-158b-46ec-bace-993ebb1d035c-libsqlitejdbc.so: failed to map segment from shared object
. ctor
java.sql.SQLException: Error opening connection
    at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:239) ~[MediathekView.jar:?]
    at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:61) ~[MediathekView.jar:?]
    at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:28) ~[MediathekView.jar:?]
    at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:21) ~[MediathekView.jar:?]
    at org.sqlite.JDBC.createConnection(JDBC.java:115) ~[MediathekView.jar:?]
    at org.sqlite.JDBC.connect(JDBC.java:90) ~[MediathekView.jar:?]
    at java.sql.DriverManager.getConnection(DriverManager.java:677) ~[java.sql:?]
    at java.sql.DriverManager.getConnection(DriverManager.java:189) ~[java.sql:?]
    at mediathek.controller.history.SeenHistoryController.createEmptyDatabase(SeenHistoryController.kt:197) ~[MediathekView.jar:?]
    at mediathek.controller.history.SeenHistoryController.<init>(SeenHistoryController.kt:287) ~[MediathekView.jar:?]
    at mediathek.gui.tabs.tab_film.GuiFilme.<init>(GuiFilme.java:90) ~[MediathekView.jar:?]
    at mediathek.mainwindow.MediathekGui.createTabFilme(MediathekGui.java:652) ~[MediathekView.jar:?]
    at mediathek.mainwindow.MediathekGui.initTabs(MediathekGui.java:667) ~[MediathekView.jar:?]
    at mediathek.mainwindow.MediathekGui.<init>(MediathekGui.java:181) ~[MediathekView.jar:?]
    at mediathek.x11.MediathekGuiX11.<init>(MediathekGuiX11.java:20) ~[MediathekView.jar:?]
    at mediathek.Main.getPlatformWindow(Main.java:639) ~[MediathekView.jar:?]
    at mediathek.Main.lambda$startGuiMode$5(Main.java:616) ~[MediathekView.jar:?]
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316) ~[?:?]
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) ~[?:?]
    at java.awt.EventQueue$4.run(EventQueue.java:721) ~[?:?]
    at java.awt.EventQueue$4.run(EventQueue.java:715) ~[?:?]
    at java.security.AccessController.doPrivileged(AccessController.java:391) [?:?]
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) [?:?]
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:740) [?:?]
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) [?:?]
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) [?:?]
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) [?:?]
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) [?:?]
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:?]
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) [?:?]
Caused by: java.lang.Exception: No native library found for os.name=Linux, os.arch=x86_64, paths=[/org/sqlite/native/Linux/x86_64:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]
    at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:367) ~[MediathekView.jar:?]
    at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:67) ~[MediathekView.jar:?]
    at org.sqlite.core.NativeDB.load(NativeDB.java:63) ~[MediathekView.jar:?]
    at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:235) ~[MediathekView.jar:?]
    ... 29 more

This is from a fresh start. I moved my config dir away to make sure it won't cause any problems.

I wonder why it would even be necessary to dump the database driver into /tmp? It could just be packaged alongside the jar files, etc.

I am running this on Arch Linux, in case that makes any difference.

Cheers, Tinx

derreisende77 commented 3 years ago

Duplicate of #573

derreisende77 commented 3 years ago

Native libraries need to be unpacked from jar files before being executable. Standard java behaviour unpacks to java tmpdir environment variable. If your tmp is not executable the app will fail. You need to modify the startup of the MV app in the launch script by using a custom directory via -Djava.io.tmpdir=

tinxx commented 3 years ago

Thanks for the info.

So I presume you just pack the JDBC driver as an external library – the jar file you mentioned?

Edit:
I can see a ton of native libraries are packaged within MediathekView.jar – for FreeBSD, Windows, etc.
That is mostly platform-specific Java code and the libsqlitejdbc.

derreisende77 commented 3 years ago

yes because the libs are part of the official xerial jdbc driver we use. but only the used lib should get unpacked which is necessary.