Skip to content

Commit

Permalink
Pass the $HOME directory to vpasswd
Browse files Browse the repository at this point in the history
So far the call to `vpasswd` broke since it `cd`s into `$HOME`, which is not
set in the fcgi environment.

This commit assembles the home directory from the configured user name and
passes a modified environment to the call of `vpasswd`.
  • Loading branch information
0x64746b committed May 17, 2015
1 parent bf98b4c commit 0b0753b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Deployment

1. Configure the domain of the email accounts
2. Configure the IMAP server
3. Generate 2 strong secrets to derive session keys and CSRF nonces from
4. Configure the log file and log level
3. Configure your Uberspace user name
4. Generate 2 strong secrets to derive session keys and CSRF nonces from

3. Create a `fcgi` file

Expand Down
5 changes: 4 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@

DOMAIN = '<YOUR EMAIL DOMAIN>'
UBERSPACE_SERVER = '<YOUR UBERSPACE SERVER>'
UBERSPACE_USER = '<YOUR USER>'

SECRET_KEY = '<REPLACE THIS WITH A SECRET, UNIQUE KEY!>'
WTF_CSRF_SECRET_KEY = '<REPLACE THIS WITH ANOTHER SECRET, UNIQUE KEY!>'

LOG_FILE = '/var/www/virtual/<YOUR USER>/uberspace_vpasswd/fcgi.log'
HOME = '/home/%s' % UBERSPACE_USER

LOG_FILE = '/var/www/virtual/%s/uberspace_vpasswd/fcgi.log' % UBERSPACE_USER
LOG_LEVEL = logging.DEBUG

DEBUG = True
8 changes: 5 additions & 3 deletions vpasswd.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ def _credentials_are_valid(email, password):


def _set_new_password(user, password):
command = 'vpasswd {}'.format(user)

vpasswd = pexpect.spawn(command)
vpasswd = pexpect.spawn(
command='vpasswd',
args=[user],
env={'HOME': app.config['HOME']}
)

vpasswd.expect('password:')
vpasswd.sendline(password)
Expand Down

0 comments on commit 0b0753b

Please sign in to comment.