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

Unable to use on Linux. #6

Closed
heywoodlh opened this issue Sep 22, 2017 · 27 comments
Closed

Unable to use on Linux. #6

heywoodlh opened this issue Sep 22, 2017 · 27 comments

Comments

@heywoodlh
Copy link
Contributor

The issue that I get is an "Invalid Password" error.

So with the code I added with my forks, I removed the import statement from pysqlcipher3 because it didn't work on Linux. The original import statement worked just fine on OS X.

This was the original statement:
from pysqlcipher3 import dbapi2 as sqlite

I changed it to:
from sqlite3 import dbapi2 as sqlite

Which fixed the issue described here of 'pysqlcipher3 module not found': Install Issues

However, I can't seem to decrypt the file on Linux. This is the output of the error that I get:
sqlite3.DatabaseError: file is not a database which results in an "Invalid Password" notification due to the try/except statement.

I tried using the original code from your commit history before my forks but that won't work as I keep running into the 'pysqlcipher3 module not found'.

Any ideas on knowing how to fix this on Linux? I have only tested on Ubuntu and Kali Linux. I have not tried the program on any non-Debian based Linux distros yet.

@nmaupu
Copy link
Contributor

nmaupu commented Oct 20, 2017

I have the exact same problem on Linux and on Mac OS.
I tried the lib pysqlcipher3 alone (under mac os) and it does work :

#!/usr/bin/env python3

from pysqlcipher3 import dbapi2 as sqlite

conn = sqlite.connect('walletx.db')
c = conn.cursor()
c.execute("PRAGMA key = 'mypass'")
c.execute("PRAGMA kdf_iter = 24000")
c.execute("""SELECT name FROM sqlite_master WHERE type='table';""")

print(c.fetchall())

c.close()

Result :

[('Identity',), ('sqlite_sequence',), ('Cards',), ('Favorites',), ('Folders',), ('Folder_Cards',), ('Pool',), ('Password_History',), ('SecuritySettings',), ('Attachment',)]

@nmaupu
Copy link
Contributor

nmaupu commented Oct 20, 2017

I fixed my own issue on this PR : #7

@heywoodlh
Copy link
Contributor Author

Hmm. Tried running the code on Linux didn't see a difference. Also, the repo currently works just fine for me on OS X. So I'm not sure what the difference is there.

The import statement that you used in that code is exactly the same as the current repo:

if sys.platform == 'darwin':

    from pysqlcipher3 import dbapi2 as sqlite

    def copyToClip(message):

        p = subprocess.Popen(['pbcopy'],

                            stdin=subprocess.PIPE, close_fds=True)

        p.communicate(input=message.encode('utf-8'))

@heywoodlh
Copy link
Contributor Author

Hopefully that didn't come off rude. I think your pull request is awesome! Hadn't even thought of making 'Y' the default response on the prompt to save the master password in the keychain.

I just don't know how this relates to this issue of enpass-cli not working on Linux. If you have additional insight that would help fix the Linux issue, that would be awesome. I totally would love to get this working under Linux.

@nmaupu
Copy link
Contributor

nmaupu commented Oct 21, 2017

I am gonna check with my linux machine on monday.

@heywoodlh
Copy link
Contributor Author

Thank you!

@nmaupu
Copy link
Contributor

nmaupu commented Oct 23, 2017

When I changed the linux import to :

from pysqlcipher3 import dbapi2 as sqlite

It works.

@heywoodlh
Copy link
Contributor Author

What Linux distro are you using? I have tried it on Kali Linux and Ubuntu and neither work. I'll have to stand up a new Linux VM and see if it is just my instances of Linux that are the problem.

@nmaupu
Copy link
Contributor

nmaupu commented Oct 23, 2017

Debian testing
Try with my sample code copied above, it's reduced to the strict minimum.

@heywoodlh
Copy link
Contributor Author

Interesting. Let me test on a new VM and I'll report back.

@heywoodlh
Copy link
Contributor Author

Still not working correctly. I changed the import statement for Linux back to

from pysqlcipher3 import dbapi2 as sqlite

The error I get is still:

ModuleNotFoundError: No module named 'pysqlcipher3'

Not only did I install the dependencies in requirements.txt which includes pysqlcipher3==1.0.2 but I tried pip install pysqlcipher3. I have tried this in both Ubuntu 16.04, and Kali Linux.

I typically use virtual environments to keep all the repos separate, but I also tried installing the requirements globally outside of the virtualenv and running outside of the virtualenv.

@heywoodlh
Copy link
Contributor Author

Any suggestions on getting around this would be appreciated! :)

@TheReptile
Copy link

I tried installing this on Linux Mint and it failed as well, the pysqlcipher3 module wouldn't install.
I needed to install python3-dev before pysqlcipher3 would install. But with the recent changes I always get the error 'Invalid Password'

@nmaupu
Copy link
Contributor

nmaupu commented Oct 23, 2017

pip3 install pysqlcipher3

?

@heywoodlh
Copy link
Contributor Author

Yeah I installed via pip3, not working.

@TheReptile
Copy link

the pip3 method wouldn't work until I installed python3-dev first.

@heywoodlh
Copy link
Contributor Author

@TheReptile are you able to import pyslqcipher3 from a python3 interpreter?

@TheReptile
Copy link

@heywoodlh Yes that seems to work here.

@heywoodlh
Copy link
Contributor Author

Weird. I can't seem to import it. And I've got python3-dev installed.

@TheReptile
Copy link

I just looked through my history and I also installed libsqlcipher-dev not sure if that was also needed.

@heywoodlh
Copy link
Contributor Author

Interesting. Still not working for me for some reason.

@heywoodlh
Copy link
Contributor Author

Also, can you successfully use the past versions of the repo?

https://github.com/HazCod/enpass-cli/tree/d984e7a0d2e99b637ceb4d10a8d1dd876aa8e058

@TheReptile
Copy link

Yes, the older version works for me, after I remove the hardcoded path for niels in the script
I'll check later how I managed to get this working, it caused me some pain as well.

@heywoodlh
Copy link
Contributor Author

Awesome. Thanks! Please submit a pull request when you figure out what the difference is that allows it to work on the old version vs the new version.

If you look at the history of the repo, the code I added to pass.py included a whole bunch of changes in order to optimize its usage on OS X. However, I tried to make separate the Linux code from OS X so it should have remained the same. Except for the import statement that uses this line from sqlite3 import dbapi2 as sqlite instead of from pysqlcipher3 import dbapi2 as sqlite because I couldn't get pysqlcipher3 to import on any of my Linux machines.

So I still need to figure out why I can't get pysqlcipher3 to import on my Linux machines.

@heywoodlh
Copy link
Contributor Author

Fresh install of Arch Linux, still having the problem of not being able to import pysqlcipher3. Trying to build pysqlcipher3 manually to see if that will fix the problem.

@heywoodlh
Copy link
Contributor Author

I was able to fix the issue by building pysqlcipher3 manually.

Everything works for me now. I am also going to build the option to store the master password in the keychain for Linux and submit a pull request when that is complete.

@sajben94
Copy link

sajben94 commented Mar 7, 2018

Install libsqlcipher-dev

sudo apt update
sudo apt install libsqlcipher-dev

then build pysqlcipher3 from source

git clone https://github.com/rigglemania/pysqlcipher3
cd pysqlcipher3
python setup.py build_amalgamation
python setup.py install

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants