check for config file permissions since it contains passwords
This commit is contained in:
parent
288ea1f142
commit
6159a789b5
2 changed files with 16 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ from __future__ import with_statement
|
|||
|
||||
import re
|
||||
import os
|
||||
import stat
|
||||
from ConfigParser import SafeConfigParser
|
||||
from logging import warning, debug
|
||||
|
||||
|
|
@ -75,8 +76,15 @@ class Module:
|
|||
return self.klass(weboob, name, config)
|
||||
|
||||
class BackendsConfig:
|
||||
class WrongPermissions(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self, confpath):
|
||||
self.confpath = confpath
|
||||
mode = os.stat(confpath).st_mode
|
||||
if mode & stat.S_IRGRP or mode & stat.S_IROTH:
|
||||
raise self.WrongPermissions(
|
||||
u'Weboob will not start until config file %s is readable by group or other users.' % confpath)
|
||||
|
||||
def iter_backends(self):
|
||||
config = SafeConfigParser()
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ from functools import partial
|
|||
from inspect import getargspec
|
||||
|
||||
from weboob import Weboob
|
||||
from weboob.modules import BackendsConfig
|
||||
|
||||
class BaseApplication(object):
|
||||
# Application name
|
||||
|
|
@ -69,6 +70,13 @@ class BaseApplication(object):
|
|||
sys.exit(app.main(sys.argv))
|
||||
|
||||
class ConsoleApplication(BaseApplication):
|
||||
def __init__(self):
|
||||
try:
|
||||
BaseApplication.__init__(self)
|
||||
except BackendsConfig.WrongPermissions, e:
|
||||
print >>sys.stderr, 'Error: %s' % e.message
|
||||
sys.exit(1)
|
||||
|
||||
def ask(self, question, default=None, masked=False, regexp=None):
|
||||
"""
|
||||
Ask a question to user.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue