File: pycacnf.py

package info (click to toggle)
pyca 20031118-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 644 kB
  • ctags: 933
  • sloc: python: 4,998; sh: 646; makefile: 43
file content (62 lines) | stat: -rwxr-xr-x 1,695 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
pycacnf.py - Read OpenSSL configuration file openssl.cnf
(c) by Michael Stroeder <michael@stroeder.com>
"""

__version__ = '0.6.6'

import os

########################################################################
# Some variables for configuration
########################################################################

# Full pathname of OpenSSL configuration file,
# most times named openssl.cnf
cnf_filename = '/etc/openssl/openssl.cnf'

# List of additional module directories
pylib = [
  os.environ.get('PYCALIB','/usr/local/pyca/pylib'),
  '/home/michael/Proj/python/pyca/pylib'
]

########################################################################
# There's nothing to configure below this line
########################################################################

import sys,os

# Extend the Python path
sys.path.extend(pylib)

if os.path.isfile('%s.pickle' % (cnf_filename)):

  # Try to read OpenSSL's config file from a pickled copy
  f=open('%s.pickle' % (cnf_filename),'rb')
  try:
    # first try to use the faster cPickle module
    from cPickle import load
  except ImportError:
    from pickle import load
  opensslcnf=load(f)
  f.close()

else:
  # Read OpenSSL's config file from source
  import openssl
  opensslcnf=openssl.cnf.OpenSSLConfigClass(cnf_filename)

# Diverse allgemeine Parameter aus der Sektion [ pyca ] uebernehmen
pyca_section = opensslcnf.data.get('pyca',{})

import htmlbase

htmlbase.bodyPARAM=pyca_section.get('htmlBodyParam','')

ErrorLog = pyca_section.get('ErrorLog','')
if ErrorLog:
  # Redirect error log to defined file
  # FIX ME! File locking for concurrent access needed?
  sys.stderr.flush()
  sys.stderr = open(ErrorLog,'a')