marcwebbie / passpie

:closed_lock_with_key: Multiplatform command-line password manager
http://passpie.readthedocs.org/
MIT License
921 stars 68 forks source link

read/write permissions during `init` within Administrative console #76

Closed zQueal closed 8 years ago

zQueal commented 9 years ago
λ passpie -D /Users/{username}/.passpie init --passphrase {password}
Traceback (most recent call last):
  File "C:\Python27\Scripts\passpie-script.py", line 9, in <module>
    load_entry_point('passpie==0.3.3', 'console_scripts', 'passpie')()
  File "C:\Python27\lib\site-packages\click\core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "C:\Python27\lib\site-packages\click\core.py", line 644, in main
    rv = self.invoke(ctx)
  File "C:\Python27\lib\site-packages\click\core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python27\lib\site-packages\click\core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python27\lib\site-packages\click\core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "C:\Python27\lib\site-packages\passpie-0.3.3-py2.7.egg\passpie\cli.py", line 157, in init
    with Cryptor(config.path) as cryptor:
  File "C:\Python27\lib\site-packages\passpie-0.3.3-py2.7.egg\passpie\crypt.py", line 38, in __init__
    self._gpg = gnupg.GPG(binary=self._binary, homedir=self._homedir)
  File "C:\Python27\lib\site-packages\gnupg\gnupg.py", line 125, in __init__
    ignore_homedir_permissions=ignore_homedir_permissions,
  File "C:\Python27\lib\site-packages\gnupg\_meta.py", line 177, in __init__
    self.homedir = os.path.expanduser(home) if home else _util._conf
  File "C:\Python27\lib\site-packages\gnupg\_util.py", line 744, in __set__
    getattr(obj, self.fset.__name__)(value)
  File "C:\Python27\lib\site-packages\gnupg\_meta.py", line 430, in _homedir_setter
    raise RuntimeError(str(ae))
RuntimeError: Homedir ''c:\users\{username}\appdata\local\temp\tmp1l3i3t'' needs read/write permissions
λ pip freeze
cffi==1.2.1
click==4.0
cryptography==1.0.2
enum34==1.0.4
gitdb==0.6.4
GitPython==1.0.1
gnupg==2.0.2
idna==2.0
ipaddress==1.0.14
passpie==0.3.3
psutil==3.0.1
pyasn1==0.1.9
pycparser==2.14
pyOpenSSL==0.15.1
PyYAML==3.11
six==1.10.0
smmap==0.9.0
tabulate==0.7.5
tinydb==2.3.2
λ pip install -U passpie
Requirement already up-to-date: passpie in c:\python27\lib\site-packages
Requirement already up-to-date: gnupg==2.0.2 in c:\python27\lib\site-packages (from passpie)
Requirement already up-to-date: tabulate==0.7.5 in c:\python27\lib\site-packages (from passpie)
Requirement already up-to-date: tinydb==2.3.2 in c:\python27\lib\site-packages (from passpie)
Requirement already up-to-date: GitPython==1.0.1 in c:\python27\lib\site-packages (from passpie)
Requirement already up-to-date: click==4.0 in c:\python27\lib\site-packages (from passpie)
Requirement already up-to-date: PyYAML==3.11 in c:\python27\lib\site-packages (from passpie)
Requirement already up-to-date: psutil>=1.2.1 in c:\python27\lib\site-packages (from gnupg==2.0.2->passpie)
Requirement already up-to-date: gitdb>=0.6.4 in c:\python27\lib\site-packages (from GitPython==1.0.1->passpie)
Requirement already up-to-date: smmap>=0.8.5 in c:\python27\lib\site-packages (from gitdb>=0.6.4->GitPython==1.0.1->passpie)

Any ideas?


I went as far as to set this up on a remote server. It went fine. I exported the passpie.db as well as ~/.passpie and moved them to my local PC and get this error:

λ passpie status
Passphrase:
ERROR:gnupg:[Error 123] The filename, directory name, or volume label syntax is incorrect: "C:\\Users\\{username}\\'c:"
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\gnupg\_util.py", line 322, in _create_if_necessary
    os.makedirs(directory, 0x1C0)
  File "C:\Python27\lib\os.py", line 150, in makedirs
    makedirs(head, mode)
  File "C:\Python27\lib\os.py", line 150, in makedirs
    makedirs(head, mode)
  File "C:\Python27\lib\os.py", line 150, in makedirs
    makedirs(head, mode)
  File "C:\Python27\lib\os.py", line 150, in makedirs
    makedirs(head, mode)
  File "C:\Python27\lib\os.py", line 150, in makedirs
    makedirs(head, mode)
  File "C:\Python27\lib\os.py", line 150, in makedirs
    makedirs(head, mode)
  File "C:\Python27\lib\os.py", line 157, in makedirs
    mkdir(name, mode)
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: "C:\\Users\\{username}\\'c:"
Traceback (most recent call last):
  File "C:\Python27\Scripts\passpie-script.py", line 9, in <module>
    load_entry_point('passpie==0.3.3', 'console_scripts', 'passpie')()
  File "C:\Python27\lib\site-packages\click\core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "C:\Python27\lib\site-packages\click\core.py", line 644, in main
    rv = self.invoke(ctx)
  File "C:\Python27\lib\site-packages\click\core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python27\lib\site-packages\click\core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python27\lib\site-packages\click\core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "C:\Python27\lib\site-packages\passpie\cli.py", line 323, in status
    ensure_passphrase(db, passphrase)
  File "C:\Python27\lib\site-packages\passpie\cli.py", line 92, in ensure_passphrase
    with Cryptor(db._storage.path) as cryptor:
  File "C:\Python27\lib\site-packages\passpie\crypt.py", line 38, in __init__
    self._gpg = gnupg.GPG(binary=self._binary, homedir=self._homedir)
  File "C:\Python27\lib\site-packages\gnupg\gnupg.py", line 125, in __init__
    ignore_homedir_permissions=ignore_homedir_permissions,
  File "C:\Python27\lib\site-packages\gnupg\_meta.py", line 177, in __init__
    self.homedir = os.path.expanduser(home) if home else _util._conf
  File "C:\Python27\lib\site-packages\gnupg\_util.py", line 744, in __set__
    getattr(obj, self.fset.__name__)(value)
  File "C:\Python27\lib\site-packages\gnupg\_meta.py", line 430, in _homedir_setter
    raise RuntimeError(str(ae))
RuntimeError: Homedir ''c:\users\{username}\appdata\local\temp\tmp9p0dxq'' needs read/write permissions

However, if I simply exec passpie I can view what's in the database:

λ passpie
╒═════════════════╤══════════════════════╤════════════╤═══════════╕
│ Name            │ Login                │ Password   │ Comment   │
╞═════════════════╪══════════════════════╪════════════╪═══════════╡
│ social/Facebook │ ----.-----@gmail.com │ *****      │           │
╘═════════════════╧══════════════════════╧════════════╧═══════════╛

Looks like there is a bug in tempfile.mkdtemp(). A user experienced it here, too and this is the fix. (to remove the need for temp files).


I forked the repository in an attempt to fix this myself, but I know nothing of Python. I was able to get past the permission error by using a different method that wasn't using tempfiles:

λ passpie init
Passphrase:
Repeat for confirmation:
Traceback (most recent call last):
  File "C:\Python27\Scripts\passpie-script.py", line 9, in <module>
    load_entry_point('passpie==0.3.3', 'console_scripts', 'passpie')()
  File "C:\Python27\lib\site-packages\click\core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "C:\Python27\lib\site-packages\click\core.py", line 644, in main
    rv = self.invoke(ctx)
  File "C:\Python27\lib\site-packages\click\core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python27\lib\site-packages\click\core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python27\lib\site-packages\click\core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "C:\Python27\lib\site-packages\passpie\cli.py", line 161, in init
    with Cryptor(config.path) as cryptor:
  File "C:\Python27\lib\site-packages\passpie\crypt.py", line 39, in __init__
    self._gpg = gnupg.GPG(binary=self._binary, homedir=self._homedir)
  File "C:\Python27\lib\site-packages\gnupg\gnupg.py", line 162, in __init__
    self.create_trustdb()
  File "C:\Python27\lib\site-packages\gnupg\gnupg.py", line 172, in create_trustdb
    if self.is_gpg2():
  File "C:\Python27\lib\site-packages\gnupg\gnupg.py", line 212, in is_gpg2
    return _util._is_gpg2(self.binary_version)
  File "C:\Python27\lib\site-packages\gnupg\_util.py", line 529, in _is_gpg2
    (major, minor, micro) = _match_version_string(version)
  File "C:\Python27\lib\site-packages\gnupg\_util.py", line 607, in _match_version_string
    major, minor, micro = int(g[0]), int(g[2]), int(g[4])
TypeError: int() argument must be a string or a number, not 'NoneType'
marcwebbie commented 9 years ago

That is actually a great fix, Thanks for that, I will look into adding this to the mainstream code.

zQueal commented 8 years ago

Any update on this? Just tried a fresh install of Passpie and it still seems to be utterly broken for Windows.

marcwebbie commented 8 years ago

Hello @zQueal passpie is now working on windows. you can try installing HEAD version on your windows machine and tell me what do you have.

pip install --upgrade https://github.com/marcwebbie/passpie/tarball/master

Tested on windows 10 with default command prompt.

zQueal commented 8 years ago

Awesome! Totally worth the wait. Thanks for taking the time. I've tested this and it seems to be almost feature complete. Some new bugs, but I'll make new tickets.

Thanks!