Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQlite error: tables are not created #67

Closed
rubenmdh opened this issue Oct 21, 2019 · 7 comments
Closed

SQlite error: tables are not created #67

rubenmdh opened this issue Oct 21, 2019 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@rubenmdh
Copy link

rubenmdh commented Oct 21, 2019

Hello,
I am trying to install lolisafe in production mode and for some reason lolisafe doesn't generate the database tables at all.
I've followed the six steps specified in the readme.md but as soon as I try to start it the following error is shown:

~/lolisafe# yarn start
yarn run v1.19.1
$ node ./lolisafe.js
[2019-10-21 11:42:38] { [Error: SQLITE_ERROR: no such table: files] errno: 1, code: 'SQLITE_ERROR' }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I've tried both with an unprivileged user and with root, both fail, so this is not a permissions issue. "ls" to the database directory shows the db file as 0 bytes.
This is on a Debian Buster installation within a LXC container with a recent kernel. I am using the nodejs version available in Buster repositories (v10.15.2)

@BobbyWibowo
Copy link
Owner

Ah yes, sorry about that.

The main script lolisafe.js doesn't wait for DB tables to be created first, before proceeding to query the tables (for file identifiers cache and whatnot). And since it exits immediately upon error, the database is never fully initiated.

Meanwhile, try to delete any leftover, and possibly broken anyway, db file with rm database/db in lolisafe's root dir.
Then you can try to run node to start node shell, also in lolisafe's root dir, and then execute the commands below through it:

require('./database/db.js')(require('knex')({ client: 'sqlite3', connection: { filename: './database/db' }, useNullAsDefault: true }))

That should properly initiate the sqlite databse with all the required tables and whatnot.

I'll commit a permanent fix in a few hours. Thanks for the report! 👍

@BobbyWibowo BobbyWibowo self-assigned this Oct 21, 2019
@rubenmdh
Copy link
Author

Thank you for your fast response. After following the instructions you gave me, it works flawlessly.

Thank you for mantaining this fork, I've been using it for quite a while now and it is just awesome.
I will close this issue now as the commit will roll out soon.

BobbyWibowo added a commit that referenced this issue Oct 21, 2019
Fixed #67

Changed default admin account to username root & password changeme,
for new installations.
Also updated README.md to mention it.
@rubenmdh
Copy link
Author

I have to reopen this as I can't log in to the root account.

I've checked that the default admin details should be as follow:
Username: root
Password: changeme

I am unable to log in with these details. Do I have to initialize the root account somehow?

@rubenmdh rubenmdh reopened this Oct 21, 2019
@BobbyWibowo
Copy link
Owner

Ah, if your DB was created BEFORE the bug fix commit (that is, through the instructions I sent previously), the default login was username root & password root.
But I forgot that a couple weeks ago, I enforced password min length to 6 chars in the auth page, thus preventing new installations from using root password (cause it's only 4 chars).
So I decided to also change the default password in that bug fix commit to changeme, but that will only apply to new DB created AFTER the commit.

@BobbyWibowo
Copy link
Owner

If necessary, you can execute the commands below in node shell to forcefully update the admin account's password (if starting over with a clean DB is not an option):

db = require('knex')({ client: 'sqlite3', connection: { filename: './database/db' }, useNullAsDefault: true })

require('bcrypt').hash('changeme', 10).then(pass => db.table('users').where('username', 'root').first().update('password', pass))

Make sure to execute the command line by line.
It'll update the password to changeme.

@rubenmdh
Copy link
Author

If necessary, you can execute the commands below in node shell to forcefully update the admin account's password (if starting over with a clean DB is not an option):

db = require('knex')({ client: 'sqlite3', connection: { filename: './database/db' }, useNullAsDefault: true })

require('bcrypt').hash('changeme', 10).then(pass => db.table('users').where('username', 'root').first().update('password', pass))

Make sure to execute the command line by line.
It'll update the password to changeme.

Thanks for the help, I just logged in changing the minlength value from the password box to 4. This works for logging in although it doesn't for registering, which is the expected scenario.

Feel free to close this issue if everything seems ok to you.

@BobbyWibowo
Copy link
Owner

Aha, I had the impression that I also forced the min length on the login API, which was why I didn't bother to suggest temporarily editing the input's minlength attribute.
I guess it wouldn't make much sense to force it on the API to begin with, so I'll leave it as it is.
Anyway, good to know it's working for you 👍

@BobbyWibowo BobbyWibowo added the bug Something isn't working label May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants