Coder Social home page Coder Social logo

Comments (34)

leafo avatar leafo commented on August 22, 2024

If you uninstall the sha2 module everything starts up okay?

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

this only occurs when the function is called.
right now its being required at the top of my auth subapp and only being used there, the site works fine (and i can see route logs) until i send a login request. the minute i send a login request my route logs disappear from terminal, that thing appears and I get a "No data received :(" error in chrome.

from lapis.

leafo avatar leafo commented on August 22, 2024

hmm, okay. I would create and issue on the OpenResty mailing list. First try creating a new app with just an Nginx config and a content_by_lua block that runs sha2 and see if it breaks the server.

This is the config, I used, I was unable to reproduce the crash: (You can just put this in a directory and run lapis server if you don't know how to start nginx manually)

worker_processes 1;
error_log stderr notice;
daemon off;

events {
  worker_connections 1024;
}

http {
  server {
    listen 8181;
    location / {
      default_type text/html;
      content_by_lua '
        local sha2 = require("sha2")
        ngx.say(sha2.sha512hex("hello world"))
      ';
    }
  }
}

from lapis.

leafo avatar leafo commented on August 22, 2024

Also if you are hashing passwords I recommend using bcrypt or scrypt. Here's a bcrypt binding I use in my apps:
https://github.com/leafo/luabcrypt

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

I'll use bcrypt for now, I'll test out that sha2 thing an a little bit.

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

I was going to ask on the luabcrypt repo but its got issues disabled, what is your recommended way of installing openssl?

Using that thing you sent me the same thing appears:









b70b1000-b70b2000 r--p 00013000 fc:00 2883622    /lib/i386-linux-gnu/libresolv-2.15.so
b70b2000-b70b3000 rw-p 00014000 fc:00 2883622    /lib/i386-linux-gnu/libresolv-2.15.so
b70b3000-b70b5000 rw-p 00000000 00:00 0 
b70b5000-b70b7000 r-xp 00000000 fc:00 2883899    /lib/i386-linux-gnu/libkeyutils.so.1.4
b70b7000-b70b8000 r--p 00002000 fc:00 2883899    /lib/i386-linux-gnu/libkeyutils.so.1.4
b70b8000-b70b9000 rw-p 00003000 fc:00 2883899    /lib/i386-linux-gnu/libkeyutils.so.1.4
b70b9000-b70c0000 r-xp 00000000 fc:00 1837163    /usr/lib/i386-linux-gnu/libkrb5support.so.0.1
b70c0000-b70c1000 r--p 00006000 fc:00 1837163    /usr/lib/i386-linux-gnu/libkrb5support.so.0.1
b70c1000-b70c2000 rw-p 00007000 fc:00 1837163    /usr/lib/i386-linux-gnu/libkrb5support.so.0.1
b70c2000-b70c3000 rw-p 00000000 00:00 0 
b70c3000-b70e9000 r-xp 00000000 fc:00 1837156    /usr/lib/i386-linux-gnu/libk5crypto.so.3.1
b70e9000-b70ea000 r--p 00025000 fc:00 1837156    /usr/lib/i386-linux-gnu/libk5crypto.so.3.1
b70ea000-b70eb000 rw-p 00026000 fc:00 1837156    /usr/lib/i386-linux-gnu/libk5crypto.so.3.1
b70eb000-b7107000 r-xp 00000000 fc:00 2883628    /lib/i386-linux-gnu/libgcc_s.so.1
b7107000-b7108000 r--p 0001b000 fc:00 2883628    /lib/i386-linux-gnu/libgcc_s.so.1
b7108000-b7109000 rw-p 0001c000 fc:00 2883628    /lib/i386-linux-gnu/libgcc_s.so.1
b7109000-b710c000 r-xp 00000000 fc:00 2883610    /lib/i386-linux-gnu/libdl-2.15.so
b710c000-b710d000 r--p 00002000 fc:00 2883610    /lib/i386-linux-gnu/libdl-2.15.so
b710d000-b710e000 rw-p 00003000 fc:00 2883610    /lib/i386-linux-gnu/libdl-2.15.so
b710e000-b7138000 r-xp 00000000 fc:00 2883611    /lib/i386-linux-gnu/libm-2.15.so
b7138000-b7139000 r--p 00029000 fc:00 2883611    /lib/i386-linux-gnu/libm-2.15.so
b7139000-b713a000 rw-p 0002a000 fc:00 2883611    /lib/i386-linux-gnu/libm-2.15.so
b713a000-b7188000 r-xp 00000000 fc:00 1843398    /usr/lib/i386-linux-gnu/libldap_r-2.4.so.2.8.1
b7188000-b7189000 ---p 0004e000 fc:00 1843398    /usr/lib/i386-linux-gnu/libldap_r-2.4.so.2.8.1
b7189000-b718a000 r--p 0004e000 fc:00 1843398    /usr/lib/i386-linux-gnu/libldap_r-2.4.so.2.8.1
b718a000-b718b000 rw-p 0004f000 fc:00 1843398    /usr/lib/i386-linux-gnu/libldap_r-2.4.so.2.8.1
b718b000-b718d000 rw-p 00000000 00:00 0 
b718d000-b71c8000 r-xp 00000000 fc:00 1837158    /usr/lib/i386-linux-gnu/libgssapi_krb5.so.2.2
b71c8000-b71c9000 ---p 0003b000 fc:00 1837158    /usr/lib/i386-linux-gnu/libgssapi_krb5.so.2.2
b71c9000-b71ca000 r--p 0003b000 fc:00 1837158    /usr/lib/i386-linux-gnu/libgssapi_krb5.so.2.2
b71ca000-b71cb000 rw-p 0003c000 fc:00 1837158    /usr/lib/i386-linux-gnu/libgssapi_krb5.so.2.2
b71cb000-b71ce000 r-xp 00000000 fc:00 2883596    /lib/i386-linux-gnu/libcom_err.so.2.1
b71ce000-b71cf000 r--p 00002000 fc:00 2883596    /lib/i386-linux-gnu/libcom_err.so.2.1
b71cf000-b71d0000 rw-p 00003000 fc:00 2883596    /lib/i386-linux-gnu/libcom_err.so.2.1
b71d0000-b7298000 r-xp 00000000 fc:00 1837161    /usr/lib/i386-linux-gnu/libkrb5.so.3.3
b7298000-b729e000 r--p 000c7000 fc:00 1837161    /usr/lib/i386-linux-gnu/libkrb5.so.3.3
b729e000-b729f000 rw-p 000cd000 fc:00 1837161    /usr/lib/i386-linux-gnu/libkrb5.so.3.3
b729f000-b743e000 r-xp 00000000 fc:00 2883603    /lib/i386-linux-gnu/libc-2.15.so
b743e000-b7440000 r--p 0019f000 fc:00 2883603    /lib/i386-linux-gnu/libc-2.15.so
b7440000-b7441000 rw-p 001a1000 fc:00 2883603    /lib/i386-linux-gnu/libc-2.15.so
b7441000-b7444000 rw-p 00000000 00:00 0 
b7444000-b7458000 r-xp 00000000 fc:00 2883815    /lib/i386-linux-gnu/libz.so.1.2.3.4
b7458000-b7459000 r--p 00013000 fc:00 2883815    /lib/i386-linux-gnu/libz.so.1.2.3.4
b7459000-b745a000 rw-p 00014000 fc:00 2883815    /lib/i386-linux-gnu/libz.so.1.2.3.4
b745a000-b745b000 rw-p 00000000 00:00 0 
b745b000-b75ed000 r-xp 00000000 fc:00 2883764    /lib/i386-linux-gnu/libcrypto.so.1.0.0
b75ed000-b75fc000 r--p 00192000 fc:00 2883764    /lib/i386-linux-gnu/libcrypto.so.1.0.0
b75fc000-b7603000 rw-p 001a1000 fc:00 2883764    /lib/i386-linux-gnu/libcrypto.so.1.0.0
b7603000-b7606000 rw-p 00000000 00:00 0 
b7606000-b7657000 r-xp 00000000 fc:00 2883656    /lib/i386-linux-gnu/libssl.so.1.0.0
b7657000-b7659000 r--p 00050000 fc:00 2883656    /lib/i386-linux-gnu/libssl.so.1.0.0
b7659000-b765d000 rw-p 00052000 fc:00 2883656    /lib/i386-linux-gnu/libssl.so.1.0.0
2013/10/30 18:56:19 [notice] 17799#0: signal 17 (SIGCHLD) received
2013/10/30 18:56:19 [alert] 17799#0: worker process 17800 exited on signal 6
2013/10/30 18:56:19 [notice] 17799#0: start worker process 17801

If you want to explore the error on my system, I'm running Vagrant ( http://vagrantup.com ) so I could send you my current system if you want. I rebuilt my system recently so I can confirm it wasn't that instance of an installation.

from lapis.

leafo avatar leafo commented on August 22, 2024

The bcrypt library I linked to has no dependencies. Are you talking about the sha2 library?

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

You require openssl for bcrypt http://qs.lc/5pww

from lapis.

leafo avatar leafo commented on August 22, 2024

oh, ooops. It's actually just a library I forked. I have no answer for you then. I just install openssl from my distro

from lapis.

seanlai avatar seanlai commented on August 22, 2024

If you are on Debian, try installing libssl-dev first

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

how do i compile luabcrypt, i've tried both the fork and original and i get this:

vagrant@precise32:/vagrant/luabcrypt-master$ make
gcc -o bcrypt.so src/luabcrypt.c src/bcrypt.c src/blowfish.c -O2 -shared -fPIC -lcrypto -Wall -Wextra -Werror
src/luabcrypt.c:4:17: fatal error: lua.h: No such file or directory
compilation terminated.
make: *** [bcrypt] Error 1
vagrant@precise32:/vagrant/luabcrypt-master$ 

Do I need the lua source?

from lapis.

leafo avatar leafo commented on August 22, 2024

try

luarocks install https://raw.github.com/leafo/luabcrypt/master/rockspec/bcrypt-scm-1.rockspec

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

did that already before. https requires luasec, which fails to install because of

sudo luarocks install luasec
Error: Could not find expected file libssl.a, or libssl.so, or libssl.so.* for OPENSSL -- you may have to install OPENSSL in your system and/or pass OPENSSL_DIR or OPENSSL_LIBDIR to the luarocks command. Example: luarocks install luasec OPENSSL_DIR=/usr/local
vagrant@precise32:/vagrant/luabcrypt-master$ sudo apt-get install libssl-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libssl-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 146 not upgraded.

from lapis.

leafo avatar leafo commented on August 22, 2024

What distro are you using? Sounds like you need to install libssl-dev (or the equivalent) as @seanlai suggested

from lapis.

leafo avatar leafo commented on August 22, 2024

Run this in the folder where you checked out the repo to avoid having LuaRocks make an https request:

luarocks install bcrypt-scm-1.rockspec

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

wget https://raw.github.com/leafo/luabcrypt/master/rockspec/bcrypt-scm-1.rockspec success
sudo apt-get install git success
sudo luarocks install bcrypt-scm-1.rockspec success bcrypt scm-1 is now built and installed in /usr/local/ (license: MIT)

> require "bcrypt"
error loading module 'bcrypt' from file '/usr/local/lib/lua/5.1/bcrypt.so':
    /usr/local/lib/lua/5.1/bcrypt.so: undefined symbol: RAND_bytes
stack traceback:
    [C]: ?
    [C]: in function 'require'
    stdin:1: in main chunk
    [C]: ?
> ```

from lapis.

leafo avatar leafo commented on August 22, 2024

Do you have openssl dev installed?

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

openssl-dev doesn't exist, tried doing sudo apt-get install openssl and i installed it. same error. i read somewhere that "openssl-dev" is basically "libssl-dev"

from lapis.

seanlai avatar seanlai commented on August 22, 2024

Hey qaisjp, did you try sudo apt-get install libssl-dev. It works for me.

If it doesn't work, you should really try asking on StackOverflow. You might have better luck getting help there.

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)
 * Documentation:  https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Thu Oct 31 01:46:04 2013 from 10.0.2.2
vagrant@precise32:~$ sudo apt-get install libssl-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libssl-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 145 not upgraded.
vagrant@precise32:~$ 

@seanlai :(

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

http://stackoverflow.com/questions/19712859/issue-installing-libssl-for-use-with-bcrypt
lets just hope i dont get negative repped for not doing this on superuser, im sure this should be on soverflow because its lua related but its superuser related due to it being an issue with openssl.

from lapis.

leafo avatar leafo commented on August 22, 2024

If you're still looking for things to try the bcrypt library I had forked has been updated to use a different library, maybe you can see if that runs: https://github.com/mikejsavage/lua-bcrypt It doesn't appear to use openssl anymore.

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

Why oh why.

vagrant@precise32:/vagrant$ rm bcrypt-scm-1.rockspec 
vagrant@precise32:/vagrant$ wget https://raw.github.com/mikejsavage/lua-bcrypt/master/rockspec/bcrypt-scm-1.rockspec
--2013-10-31 17:20:25--  https://raw.github.com/mikejsavage/lua-bcrypt/master/rockspec/bcrypt-scm-1.rockspec
Resolving raw.github.com (raw.github.com)... 185.31.19.133
Connecting to raw.github.com (raw.github.com)|185.31.19.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 418 [text/plain]
Saving to: `bcrypt-scm-1.rockspec'

100%[=========================================================================================================================================================================>] 418         --.-K/s   in 0s      

2013-10-31 17:20:26 (4.39 MB/s) - `bcrypt-scm-1.rockspec' saved [418/418]

vagrant@precise32:/vagrant$ luarocks install bcrypt-scm-1.rockspec 

Error: Your user does not have write permissions in /usr/local/ 
-- you may want to run as a privileged user or use your local tree with --local.
vagrant@precise32:/vagrant$ sudo luarocks install bcrypt-scm-1.rockspec 
Using bcrypt-scm-1.rockspec... switching to 'build' mode
Cloning into 'lua-bcrypt'...
remote: Counting objects: 24, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 24 (delta 3), reused 21 (delta 3)
Receiving objects: 100% (24/24), 28.35 KiB, done.
Resolving deltas: 100% (3/3), done.
Warning: variable CFLAGS was not passed in build_variables
make -C lib/bcrypt
make[1]: Entering directory `/tmp/luarocks_bcrypt-scm-1-1014/lua-bcrypt/lib/bcrypt'
gcc -c -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wundef -Wpointer-arith -O2 -fomit-frame-pointer -funroll-loops -fPIC crypt_blowfish.c
gcc -c x86.S
gcc -c -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wundef -Wpointer-arith -O2 -fomit-frame-pointer -funroll-loops -fPIC crypt_gensalt.c
gcc -c -W -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wundef -Wpointer-arith -O2 -fomit-frame-pointer -funroll-loops -fPIC wrapper.c
make[1]: Leaving directory `/tmp/luarocks_bcrypt-scm-1-1014/lua-bcrypt/lib/bcrypt'
gcc -o bcrypt.so src/main.c lib/bcrypt/crypt_blowfish.o lib/bcrypt/x86.o lib/bcrypt/crypt_gensalt.o lib/bcrypt/wrapper.o -O2 -shared -fPIC -fomit-frame-pointer -funroll-loops -lcrypto -Ilib/bcrypt -Wall -Wextra -Werror -Wbad-function-cast -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Wundef -Wpointer-arith
src/main.c:7:17: fatal error: lua.h: No such file or directory
compilation terminated.
make: *** [bcrypt] Error 1

Error: Build error: Failed building.
vagrant@precise32:/vagrant$ 

from lapis.

leafo avatar leafo commented on August 22, 2024

This is why I forked the library, the Makefile included doesn't work on all systems. You can edit the top level Makefile to add -I /path/to/lua/headers and that should fix it.

from lapis.

leafo avatar leafo commented on August 22, 2024

Okay, sorry you're having so much trouble :)

I patched the latest version of lua-bcrypt to use LuaRock's build system instead of make so it should install on your system:

Try running this command:

luarocks install http://leafo.net/dump/bcrypt-leafo-1.rockspec

I'll push this patch upstream if it works for you.

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

no problem :) i'll just carry on development without password hashing and fakes passes for now. This is my log, ended up with a different error now:

...
bcrypt leafo-1 is now built and installed in /usr/local/ (license: MIT)
...
vagrant@precise32:/vagrant$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require "bcrypt"
error loading module 'bcrypt' from file '/usr/local/lib/lua/5.1/bcrypt.so':
    /usr/local/lib/lua/5.1/bcrypt.so: undefined symbol: _BF_body_r
stack traceback:
    [C]: ?
    [C]: in function 'require'
    stdin:1: in main chunk
    [C]: ?
> 

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

Okay I re-read the build information before it was finished installing, seems it failed somewhere:

vagrant@precise32:/vagrant$ sudo luarocks install http://leafo.net/dump/bcrypt-leafo-1.rockspec
Using http://leafo.net/dump/bcrypt-leafo-1.rockspec... switching to 'build' mode
Cloning into 'luabcrypt'...
remote: Counting objects: 37, done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 37 (delta 7), reused 27 (delta 5)
Receiving objects: 100% (37/37), 36.81 KiB, done.
Resolving deltas: 100% (7/7), done.
Branch latest set up to track remote branch latest from origin.
gcc -O2 -fPIC -I/usr/include/lua5.1 -c lib/bcrypt/crypt_blowfish.c -o lib/bcrypt/crypt_blowfish.o -Ilib/bcrypt/
gcc -O2 -fPIC -I/usr/include/lua5.1 -c lib/bcrypt/crypt_gensalt.c -o lib/bcrypt/crypt_gensalt.o -Ilib/bcrypt/
gcc -O2 -fPIC -I/usr/include/lua5.1 -c lib/bcrypt/wrapper.c -o lib/bcrypt/wrapper.o -Ilib/bcrypt/
gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/main.c -o src/main.o -Ilib/bcrypt/
src/main.c: In function 'randomBytes':
src/main.c:39:6: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
gcc -shared -o bcrypt.so -L/usr/local/lib lib/bcrypt/crypt_blowfish.o lib/bcrypt/crypt_gensalt.o lib/bcrypt/wrapper.o src/main.o
Updating manifest for /usr/local/lib/luarocks/rocks

bcrypt leafo-1 is now built and installed in /usr/local/ (license: MIT)

from lapis.

leafo avatar leafo commented on August 22, 2024

Cool, so everything is working?

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

Nope :(

vagrant@precise32:/vagrant$ sudo luarocks install http://leafo.net/dump/bcrypt-leafo-1.rockspec
...
Branch latest set up to track remote branch latest from origin.
gcc -O2 -fPIC -I/usr/include/lua5.1 -c lib/bcrypt/crypt_blowfish.c -o lib/bcrypt/crypt_blowfish.o -Ilib/bcrypt/
gcc -O2 -fPIC -I/usr/include/lua5.1 -c lib/bcrypt/crypt_gensalt.c -o lib/bcrypt/crypt_gensalt.o -Ilib/bcrypt/
gcc -O2 -fPIC -I/usr/include/lua5.1 -c lib/bcrypt/wrapper.c -o lib/bcrypt/wrapper.o -Ilib/bcrypt/
gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/main.c -o src/main.o -Ilib/bcrypt/
src/main.c: In function 'randomBytes':
src/main.c:39:6: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
gcc -shared -o bcrypt.so -L/usr/local/lib lib/bcrypt/crypt_blowfish.o lib/bcrypt/crypt_gensalt.o lib/bcrypt/wrapper.o src/main.o
Updating manifest for /usr/local/lib/luarocks/rocks

bcrypt leafo-1 is now built and installed in /usr/local/ (license: MIT)

from lapis.

leafo avatar leafo commented on August 22, 2024

It says it built, you should be able to ignore the warning.

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024
vagrant@precise32:/vagrant/web$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require "bcrypt"
error loading module 'bcrypt' from file '/usr/local/lib/lua/5.1/bcrypt.so':
    /usr/local/lib/lua/5.1/bcrypt.so: undefined symbol: _BF_body_r
stack traceback:
    [C]: ?
    [C]: in function 'require'
    stdin:1: in main chunk
    [C]: ?
> 

Then this happens :/

from lapis.

blablacio avatar blablacio commented on August 22, 2024

@qaisjp Take a look at this change, it might fix your problem: blablacio/luabcrypt@da76b39

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

thanks @blablacio - i'll test it one day.

from lapis.

qaisjp avatar qaisjp commented on August 22, 2024

bcrypt works all fine and dandy now 🎉

from lapis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.