16,18 → 16,19 |
-> http://web.archive.org/http://oss.wired-networks.net/bugzilla/show_bug.cgi?id=111 |
(ref3) http://docs.python.org/library/zlib.html |
""" |
from Crypto.Cipher import AES |
import ConfigParser |
import getopt |
import libxml2 |
import os |
import stat |
import sys |
import zlib |
from Crypto.Cipher import AES |
|
|
__author__ = 'Toni Corvera' |
__date__ = '$Date$' |
__revision__ = '$Rev$' |
__version_info__ = ( 0, 2, 0 ) |
__version_info__ = ( 0, 3, 0 ) |
__version__ = '.'.join(map(str, __version_info__)) |
RELEASE=True |
|
101,6 → 102,39 |
doc.freeDoc() |
ctxt.xpathFreeContext() |
|
def world_readable(path): |
assert os.path.exists(path) |
if sys.platform == 'win32': |
return True |
st = os.stat(path) |
return bool(st.st_mode & stat.S_IROTH) |
|
def load_config(): |
""" |
load_config() -> ( str file, str pass ) |
Load configuration file is one is found |
""" |
cfg = os.path.join(os.path.expanduser('~'), '.relevation.conf') |
pw = None |
fl = None |
if os.path.isfile(cfg): |
if os.access(cfg, os.R_OK): |
wr = world_readable(cfg) |
if wr: |
sys.stderr.write('Configuration (~/.relevation.conf) is world-readable!!!\n') |
parser = ConfigParser.ConfigParser() |
parser.read(cfg) |
ops = parser.options('relevation') |
if 'file' in ops: |
fl = os.path.expanduser(parser.get('relevation', 'file')) |
if 'password' in ops: |
if wr and sys.platform != 'win32': # TODO: how to check in windows? |
sys.stderr.write('Your password can be read by anyone!!!\n') |
pw = parser.get('relevation', 'password') |
else: # exists but not readable |
sys.stderr.write('Configuration file (~/.relevation.conf) is not readable!\n') |
return ( fl, pw ) |
|
def main(): |
datafile = None |
password = None |
108,6 → 142,9 |
caseInsensitive = True |
|
sys.stderr.write('Relevation v%s, (c) 2011 Toni Corvera\n\n' % __version__) |
|
( datafile, password ) = load_config() |
|
try: |
# gnu_getopt requires py >= 2.3 |
ops, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:s:0ciah', |