linuxdeployqt icon indicating copy to clipboard operation
linuxdeployqt copied to clipboard

libsoftokn3.so issue

Open probonopd opened this issue 7 years ago • 36 comments

When I try to use -bundle-non-qt-libs on a working Otter AppDir or try to convert it to an AppImage, Otter fails to run with

[1022/144633:ERROR:nss_util.cc(740)] Error initializing NSS with a persistent database (sql:/home/me/.pki/nssdb): libsoftokn3.so: cannot open shared object file: No such file or directory
[1022/144633:ERROR:nss_util.cc(211)] Error initializing NSS without a persistent database: NSS error code: -5925
[1022/144633:FATAL:nss_util.cc(213)] nss_error=-5925, os_error=0

The reason for this is to be investigated.

When I delete libnss3.so from the AppDir, then it starts working again.

probonopd avatar Oct 22 '16 12:10 probonopd

Possibly fixed in 2a19bc3, please confirm

probonopd avatar Oct 22 '16 13:10 probonopd

At last libnssutils3.so, libsmime3.so and libssl3.so depends on it, causing :

/usr/lib64/libnss3.so: version `NSS_3.21' not found (required by ./lib64/libssl3.so)

g-maxime avatar Oct 26 '16 00:10 g-maxime

Now we have an interesting situation here; recently we ran into an application (Firefox) that refused to run without libnss3.so.

So I am not entirely sure what is the best path of action here.

Reopening the issue. Deleting libnss3.so appears to be the wrong course of action.

probonopd avatar Oct 26 '16 03:10 probonopd

We should check which libraries upstream Firefox bundles, and do the same. (Be sure to carry this over to linuxdeployqt too.)

probonopd avatar Mar 19 '17 18:03 probonopd

At least on Ubuntu the following libraries are all part of the same libnss3 binary package:

/usr/lib/x86_64-linux-gnu/libnss3.so
/usr/lib/x86_64-linux-gnu/libnssutil3.so
/usr/lib/x86_64-linux-gnu/libsmime3.so
/usr/lib/x86_64-linux-gnu/libssl3.so
/usr/lib/x86_64-linux-gnu/nss/libfreebl3.so
/usr/lib/x86_64-linux-gnu/nss/libfreeblpriv3.so
/usr/lib/x86_64-linux-gnu/nss/libnssckbi.so
/usr/lib/x86_64-linux-gnu/nss/libnssdbm3.so
/usr/lib/x86_64-linux-gnu/nss/libnsssysinit.so
/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so

I hope that helps to figure out what stuff needs to be bundled or excluded.

darealshinji avatar Apr 14 '17 17:04 darealshinji

Very good observation @darealshinji - this probably suggests that we should treat all of those together; especially either bundle both libnss3 and libssl3 or neither. We should try both approaches with the Otter AppImage.

probonopd avatar Apr 15 '17 07:04 probonopd

Potentially we could even build some logic/database that would always treat libraries that are part of the same package together...

probonopd avatar Apr 15 '17 07:04 probonopd

@probonopd

Hi,

I also have this problem with VNote. After deleting the libnss3.so and libnssutil3.so in the extracted AppImage, it could run successfully. Then I change the script in travis CI like this:

# Get linuxdeployqt tool
wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x linuxdeployqt*.AppImage
unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
./linuxdeployqt*.AppImage ./dist/usr/share/applications/*.desktop -bundle-non-qt-libs

# Copy translations
cp /opt/qt59/translations/*_zh_CN.qm ./dist/usr/translations/

# Package it for the second time.
./linuxdeployqt*.AppImage ./dist/usr/share/applications/*.desktop -appimage

tree dist/

ls -l *.AppImage

wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod a+x appimagetool-x86_64.AppImage

mv VNote-*.AppImage VNote-x86_64.AppImage
chmod a+x VNote-x86_64.AppImage
./VNote-x86_64.AppImage --appimage-extract
rm VNote-x86_64.AppImage
# Delete libnss3.so libnssutil3.so.
rm ./squashfs-root/usr/lib/libnss3.so ./squashfs-root/usr/lib/libnssutil3.so

./appimagetool-x86_64.AppImage squashfs-root

mv VNote-*.AppImage VNote_x86_64_${version}.AppImage

However, the re-packaged AppImage lack the libFcitxQt5DBusAddons.so.1, which seems to exist in the squashfs-root. Append the travis log here.

Any idea to remove the libnss3.so in the AppImage?

Thanks!

tamlok avatar Apr 07 '18 15:04 tamlok

However, the re-packaged AppImage lack the libFcitxQt5DBusAddons.so.1, which seems to exist in the squashfs-root

Are you saying it magically dissapeared when re-packing the AppImage? What did you use to repack? Please use appimagetool to repack an extracted AppImage.

probonopd avatar Apr 08 '18 04:04 probonopd

Yes, the lib disappeared after re-pack. I used appimagetool to pack it. Finally I try the new -exclude-libs option and it works now. Thanks!

tamlok avatar Apr 08 '18 10:04 tamlok

Currently I have the same issue, using Qt 5.9.4 and latest linuxdeploymentqt. But working with -exclude-libs argument seems not to be an option for me, because then my little WebEngine (WebView) component renders also the css in front of the html as plain text, which should not happen.

https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.4.9-xenial is missing the libQt5WebView.so, which gets installed by using Qt 5.9.4 from the qt installer.

BTW: When using Qt 5.10.1 it fails with a different error. Currently trying to get around this problem by using an older qt version. Maybe I will open a new issue according the problem in Qt 5.10.1, because using this version without the lib seems not to be a working solution :/

forelabs avatar Apr 18 '18 07:04 forelabs

I have the same problem and what is weird is that it appeared recently without touching anything else: builds from january were working fine, and now I have this NSS error.

We are building on 14.04 for historical reasons, maybe libnss was recently upgraded?

My app does not want to start if I delete libnss3.so from the lib directory.

Silex avatar Apr 19 '18 14:04 Silex

Check with strace what is actually going on - is it loading /usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so correctly from the system (in case it is a Debian/Ubuntu based system)?

probonopd avatar Apr 20 '18 05:04 probonopd

@probonopd: actually it was not!

Using this works:

LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/nss" mybinary

So basically, it'd just be a matter of packaging that lib in the appimage. I'll play around and report.

Silex avatar Apr 20 '18 06:04 Silex

Ok I just checked based on my latest successful build, and found out that 46a1e7f481317ecfab1804cfe7aa117bcb10e0e6 is able to build & run my Appimage.

I also confirm that using -exclude-libs="libnss3.so,libnssutil3.so" with the latest version fixes the problem.

Silex avatar Apr 20 '18 06:04 Silex

So after verifications, basically in previous versions it did not package libnss* but it was loaded from the system dir, because it was already installed by 3rd party packages (e.g firefox & friends).

In the latest version, it tries to bundle this dependency but is not complete enough so the loading fails?

Here is the difference between the appimages (I sorted it a bit so it's easier to visualize):

root@P080027f4c1bf ~ # diff -rl squashfs-root-46a1e7f/ squashfs-root-latest/
Binary files squashfs-root-46a1e7f/AppRun and squashfs-root-latest/AppRun differ

Only in squashfs-root-46a1e7f/doc: libatk-bridge2.0-0
Only in squashfs-root-46a1e7f/doc: libatk1.0-0
Only in squashfs-root-46a1e7f/doc: libatspi2.0-0
Only in squashfs-root-46a1e7f/doc: libcairo-gobject2
Only in squashfs-root-46a1e7f/doc: libcairo2
Only in squashfs-root-46a1e7f/doc: libdatrie1
Only in squashfs-root-46a1e7f/doc: libfreetype6
Only in squashfs-root-46a1e7f/doc: libgraphite2-3
Only in squashfs-root-46a1e7f/doc: libgtk-3-0
Only in squashfs-root-46a1e7f/doc: libharfbuzz0b
Only in squashfs-root-46a1e7f/doc: libpixman-1-0
Only in squashfs-root-46a1e7f/doc: libselinux1
Only in squashfs-root-46a1e7f/doc: libthai0
Only in squashfs-root-46a1e7f/doc: libwayland-client0
Only in squashfs-root-46a1e7f/doc: libwayland-cursor0
Only in squashfs-root-46a1e7f/doc: libxinerama1
Only in squashfs-root-46a1e7f/doc: libxkbcommon0
Only in squashfs-root-46a1e7f/doc: libxrandr2
Only in squashfs-root-latest/doc: libk5crypto3

Only in squashfs-root-46a1e7f/lib: libXinerama.so.1
Only in squashfs-root-46a1e7f/lib: libXrandr.so.2
Only in squashfs-root-46a1e7f/lib: libatk-1.0.so.0
Only in squashfs-root-46a1e7f/lib: libatk-bridge-2.0.so.0
Only in squashfs-root-46a1e7f/lib: libatspi.so.0
Only in squashfs-root-46a1e7f/lib: libcairo-gobject.so.2
Only in squashfs-root-46a1e7f/lib: libcairo.so.2
Only in squashfs-root-46a1e7f/lib: libdatrie.so.1
Only in squashfs-root-46a1e7f/lib: libfreetype.so.6
Only in squashfs-root-46a1e7f/lib: libgdk-3.so.0
Only in squashfs-root-46a1e7f/lib: libgraphite2.so.3
Only in squashfs-root-46a1e7f/lib: libgtk-3.so.0
Only in squashfs-root-46a1e7f/lib: libharfbuzz.so.0
Only in squashfs-root-46a1e7f/lib: libpixman-1.so.0
Only in squashfs-root-46a1e7f/lib: libselinux.so.1
Only in squashfs-root-46a1e7f/lib: libthai.so.0
Only in squashfs-root-46a1e7f/lib: libwayland-client.so.0
Only in squashfs-root-46a1e7f/lib: libwayland-cursor.so.0
Only in squashfs-root-46a1e7f/lib: libxkbcommon.so.0
Only in squashfs-root-latest/lib: libk5crypto.so.3
Only in squashfs-root-latest/lib: libnss3.so
Only in squashfs-root-latest/lib: libnssutil3.so

Only in squashfs-root-46a1e7f/plugins: platformthemes

Binary files squashfs-root-46a1e7f/provision_browser and squashfs-root-latest/provision_browser differ

Silex avatar Apr 20 '18 06:04 Silex

Ok, another fix is doing cp /usr/lib/x86_64-linux-gnu/nss/* lib before building the appimage.

Also it's opened by the app:

stvs@P080027f4c1bf:~/squashfs-root$ strace -f ./AppRun 2>&1 | grep libsoftokn3
[pid  4720] open("/home/stvs/squashfs-root/lib/nss/libsoftokn3.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  4720] open("/home/stvs/squashfs-root/lib/libsoftokn3.so", O_RDONLY|O_CLOEXEC) = 36

From that I infer that it'd be maybe better to do cp -r /usr/lib/x86_64-linux-gnu/nss lib/ instead.

Silex avatar Apr 20 '18 07:04 Silex

Ok, another fix is doing cp /usr/lib/x86_64-linux-gnu/nss/* lib before building the appimage.

Correct, that is the way to do it. linuxdeployqt will only deploy libraries ldd can find on the system.

Unless upstream Qt fixes the principal issue, since it seems their binary distribution does not work properly on Debian/Ubuntu-based system without the above workaround. Did you open a ticket there?

probonopd avatar Apr 20 '18 15:04 probonopd

Did you open a ticket there?

No, I didn't know this was a Qt issue.

Silex avatar Apr 20 '18 17:04 Silex

-exclude-libs="libnss3.so,libnssutil3.so" worked for me on Centos 7. It also worked on Centos 6, but my app crashed on closing which may be unrelated. The equivalent of cp -r /usr/lib/x86_64-linux-gnu/nss lib/ on Centos 6 isn't obvious (/lib64/nss does not exist), on Centos 7 I have yet to try copying /lib64/nss.

tsteven4 avatar May 15 '18 15:05 tsteven4

On Centos 7 I tried copying /lib64/nss/libnssckbi.so to /lib but it didn't appear to change anything, the error was

[17793:17830:0515/092835.858481:ERROR:nss_util.cc(712)] Error initializing NSS with a persistent database (sql:/home/tsteven4/.pki/nssdb): libsoftokn3.so: cannot open shared object file: No such file or directory [17793:17830:0515/092835.858691:ERROR:nss_util.cc(201)] Error initializing NSS without a persistent database: NSS error code: -5925 [17793:17830:0515/092835.858762:FATAL:nss_util.cc(203)] nss_error=-5925, os_error=0

so I copied /lib64/libsoftokn3.chk & /lib64/libsoftokn3.so to /lib. The error changes to:

[9872:9907:0515/093026.393238:ERROR:nss_util.cc(712)] Error initializing NSS with a persistent database (sql:/home/tsteven4/.pki/nssdb): NSS error code: -8023 [9872:9907:0515/093026.393451:ERROR:nss_util.cc(201)] Error initializing NSS without a persistent database: NSS error code: -8023 [9872:9907:0515/093026.393464:FATAL:nss_util.cc(203)] nss_error=-8023, os_error=0

tsteven4 avatar May 15 '18 15:05 tsteven4

Unless upstream Qt fixes the principal issue, since it seems their binary distribution does not work properly on Debian/Ubuntu-based system without the above workaround. Did you open a ticket there?

I don't agree, I don't see this as a Qt issue.

The issue seems to arise because of ubuntu libnss3 patch 85_security_load.patch which appeared in the changelogs at various times between 2007 and 2009. Unfortunately for us I think other distributions came up with different patches.

The Qt binary distribution works find on Ubuntu based systems, it just requires package libnnss3, which will carry with it the nss subdiretory:

/usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/x86_64-linux-gnu/libnssutil3.so /usr/lib/x86_64-linux-gnu/libsmime3.so /usr/lib/x86_64-linux-gnu/libssl3.so /usr/lib/x86_64-linux-gnu/nss/libfreebl3.chk /usr/lib/x86_64-linux-gnu/nss/libfreebl3.so /usr/lib/x86_64-linux-gnu/nss/libnssckbi.so /usr/lib/x86_64-linux-gnu/nss/libnssdbm3.chk /usr/lib/x86_64-linux-gnu/nss/libnssdbm3.so /usr/lib/x86_64-linux-gnu/nss/libnsssysinit.so /usr/lib/x86_64-linux-gnu/nss/libsoftokn3.chk /usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so /usr/share/doc/libnss3/changelog.Debian.gz /usr/share/doc/libnss3/copyright /usr/share/lintian/overrides/libnss3

tsteven4 avatar May 18 '18 13:05 tsteven4

The issue seems to arise because of ubuntu libnss3 patch 85_security_load.patch

Interesting find!

probonopd avatar May 19 '18 06:05 probonopd

I ran into the same issue running an AppImage built on Centos 7 on Ubuntu 18.04.

Using -exclude-libs="libnss3.so,libnssutil3.so" didn't work for me, I still couldn't run the AppImage on Ubuntu. However copying the .so and .chk files provided by the nss-softokn on Centos 7 manually into the AppImages /lib directory worked. I executed the following command in the AppImages folder to do so:

repoquery -l nss-softokn | grep '.so\|.chk' | xargs -i cp -R {} ./lib

The resulting AppImage runs on Centos 7, latest Arch Linux and Ubuntu 18.04 without complaining about missing libsoftokn3.so and whatnot.

DoctorJohn avatar Oct 12 '18 17:10 DoctorJohn

Does anyone know what a .chk file is?

probonopd avatar Oct 13 '18 07:10 probonopd

It is explained here: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Tech_Notes/nss_tech_note6

On Sat, Oct 13, 2018, 1:49 AM probonopd [email protected] wrote:

Does anyone know what a .chk file is?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/probonopd/linuxdeployqt/issues/35#issuecomment-429520073, or mute the thread https://github.com/notifications/unsubscribe-auth/AM92MeqkAK6Lj7hqE24CYIAad4xNVtEgks5ukZsTgaJpZM4Kd2cK .

tsteven4 avatar Oct 13 '18 12:10 tsteven4

PRs welcome!

probonopd avatar Oct 13 '18 18:10 probonopd

What kind of patch could that be?

Looks like those .chk files are always called the same as the .so files they belong to. linuxdeployqt determines what .so files the program depends on using ldd right? So we could check whether there are matching .chk files next to them(?)

Any opinions on that?

(Sorry, posted the same thing earlier using a wrong github account)

DoctorJohn avatar Oct 13 '18 19:10 DoctorJohn

Yes, exactly as you describe @DoctorJohn

probonopd avatar Oct 13 '18 19:10 probonopd

libsoftokn3.so is seemingly still a pain:

me@host:~$ Downloads/REDasm_x86_64_20181231.AppImage Downloads/AppImageUpdate-x86_64.AppImage 
QBuffer::setData: Buffer is open
[9708:9734:0102/034434.903619:ERROR:nss_util.cc(712)] Error initializing NSS with a persistent database (sql:/home/me/.pki/nssdb): libsoftokn3.so: cannot open shared object file: No such file or directory
[9708:9734:0102/034434.903712:ERROR:nss_util.cc(201)] Error initializing NSS without a persistent database: NSS error code: -5925
[9708:9734:0102/034434.903732:FATAL:nss_util.cc(203)] nss_error=-5925, os_error=0
#0 0x7f35b3c0f5de <unknown>
#1 0x7f35b3c21d1e <unknown>
....

probonopd avatar Jan 02 '19 02:01 probonopd