mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-09-03 20:52:56 -05:00
Make data type of certificates more obvious/predictable internally.
For the most part certificates will be treated as being in DER format. When we load a certificate we will generally accept it in any format but will convert it to DER before proceeding in normalize_certificate(). This also re-arranges a bit of code to pull some certificate-specific functions out of ipalib/plugins/service.py into ipalib/x509.py. This also tries to use variable names to indicate what format the certificate is in at any given point: dercert: DER cert: PEM nsscert: a python-nss Certificate object rawcert: unknown format ticket 32
This commit is contained in:
@@ -30,6 +30,7 @@ import re
|
||||
from types import NoneType
|
||||
|
||||
from ipalib import errors
|
||||
from ipalib.text import _
|
||||
from ipapython import dnsclient
|
||||
|
||||
|
||||
@@ -185,3 +186,20 @@ def validate_ipaddr(ipaddr):
|
||||
except socket.error:
|
||||
return False
|
||||
return True
|
||||
|
||||
def check_writable_file(filename):
|
||||
"""
|
||||
Determine if the file is writable. If the file doesn't exist then
|
||||
open the file to test writability.
|
||||
"""
|
||||
if filename is None:
|
||||
raise errors.FileError(reason='Filename is empty')
|
||||
try:
|
||||
if os.path.exists(filename):
|
||||
if not os.access(filename, os.W_OK):
|
||||
raise errors.FileError(reason=_('Permission denied: %(file)s') % dict(file=filename))
|
||||
else:
|
||||
fp = open(filename, 'w')
|
||||
fp.close()
|
||||
except (IOError, OSError), e:
|
||||
raise errors.FileError(reason=str(e))
|
||||
|
||||
Reference in New Issue
Block a user