wahern / luaossl

Most comprehensive OpenSSL module in the Lua universe.
http://25thandclement.com/~william/projects/luaossl.html
Other
144 stars 50 forks source link

Fails to load on 5.1 on Oracle Linux 7 #156

Closed chris-jansson closed 5 years ago

chris-jansson commented 5 years ago

I'm having an issue on Oracle Linux 7.4, running Lua 5.1.4, OpenSSL 1.0.2k-fips, and luaossl 20181102-0.

I installed luaossl with LuaRocks. Output of luarocks list:

luaossl
   20181102-0 (installed) - /usr/lib64/luarocks/rocks

The source code is located at /usr/share/lua/5.1.

Specifically, I am trying to require openssl.digest. When I run the code, I see this error:

*3 lua entry thread aborted: runtime error: /usr/share/lua/5.1/openssl/digest.lua:1: module '_openssl.digest' not found:
    no field package.preload['_openssl.digest']
    no file './_openssl/digest.lua'
    no file '/usr/share/nginx-luajit-2.0.5/_openssl/digest.lua'
    no file '/usr/local/share/lua/5.1/_openssl/digest.lua'
    no file '/usr/local/share/lua/5.1/_openssl/digest/init.lua'
    no file '/usr/share/lua/5.1/_openssl/digest.lua'
    no file '/usr/share/lua/5.1/_openssl/digest/init.lua'
    no file './_openssl/digest.so'
    no file '/usr/local/lib/lua/5.1/_openssl/digest.so'
    no file '/usr/lib/lua/5.1/_openssl/digest.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
    no file './_openssl.so'
    no file '/usr/local/lib/lua/5.1/_openssl.so'
    no file '/usr/lib/lua/5.1/_openssl.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'

I confirmed that both openssl-devel and openssl-libs are also installed on my system.

Current package.path:

./?.lua;/usr/share/nginx-luajit-2.0.5/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;

Current package.cpath:

./?.so;/usr/local/lib/lua/5.1/?.so;/usr/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so

Any ideas? Thanks

daurnimator commented 5 years ago

From your output, you installed it to /usr/lib64 but don't have that in your package.cpath. either your luarocks is configured incorrectly, or your lua cpath is.

chris-jansson commented 5 years ago

Ok, I can add that to my cpath. What exactly do I need to point to in /usr/lib64?

I see the file /usr/lib64/lua/5.1/_openssl.so, is that it? I added /usr/lib64/lua/5.1/?.so to my cpath, but since I'm using require 'openssl.digest', the loader tries to find _openssl/digest.so

daurnimator commented 5 years ago

the loader tries to find _openssl/digest.so

I should then try and find _openssl.so after. (which I can see in your earlier error messages)

chris-jansson commented 5 years ago

So is my lua.cpath correct then?

daurnimator commented 5 years ago

So is my lua.cpath correct then?

You haven't shown it to me since you made the above changes.

chris-jansson commented 5 years ago

Sure. I added /usr/lib64/lua/5.1/?.so to my cpath, so this is its new value:

/usr/lib64/lua/5.1/?.so;/usr/lib64/lua/5.1/loadall.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so

Inside the /usr/lib64/lua/5.1 directory, the only OpenSSL related file is _openssl.so. So, when I try to require openssl.digest (based on the examples in the docs), I get this error:

lua entry thread aborted: runtime error: /usr/share/lua/5.1/openssl/digest.lua:1: module '_openssl.digest' not found:
    no field package.preload['_openssl.digest']
    no file './_openssl/digest.lua'
    no file '/usr/share/nginx-luajit-2.0.5/_openssl/digest.lua'
    no file '/usr/local/share/lua/5.1/_openssl/digest.lua'
    no file '/usr/local/share/lua/5.1/_openssl/digest/init.lua'
    no file '/usr/share/lua/5.1/_openssl/digest.lua'
    no file '/usr/share/lua/5.1/_openssl/digest/init.lua'
    no file ' /usr/lib64/lua/5.1/_openssl/digest.so'
    no file '/usr/lib64/lua/5.1/loadall.so'
    no file './_openssl/digest.so'
    no file '/usr/local/lib/lua/5.1/_openssl/digest.so'
    no file '/usr/lib/lua/5.1/_openssl/digest.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
    no file ' /usr/lib64/lua/5.1/_openssl.so'
    no file '/usr/lib64/lua/5.1/loadall.so'
    no file './_openssl.so'
    no file '/usr/local/lib/lua/5.1/_openssl.so'
    no file '/usr/lib/lua/5.1/_openssl.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'

I can see in the trace that it is checking the updated cpath.

daurnimator commented 5 years ago

I notice a space at the start of the /usr/lib64/lua/5.1/_openssl.so path.

chris-jansson commented 5 years ago

Aha. Working now. So it was just a cpath issue after all. Thanks