summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-25 16:21:39 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-25 16:21:39 -0400
commitef8aad0268ae9dc9efebd96714ca23e5a5369b49 (patch)
treefec90cb3e5ef14419f6eaed374d6192ea02fc783
parent637c6db316c12384f89825e12bf47dda7609ebb9 (diff)
parent8a2e2059faecc3b4c4b11363d6fd620ec0535bed (diff)
downloadthird_party-func-ef8aad0268ae9dc9efebd96714ca23e5a5369b49.tar.gz
third_party-func-ef8aad0268ae9dc9efebd96714ca23e5a5369b49.tar.xz
third_party-func-ef8aad0268ae9dc9efebd96714ca23e5a5369b49.zip
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
-rwxr-xr-xfunc/certmaster.py18
-rw-r--r--modules/copyfile.py15
-rwxr-xr-xscripts/certmaster7
3 files changed, 28 insertions, 12 deletions
diff --git a/func/certmaster.py b/func/certmaster.py
index 59bfd36..b12ecdb 100755
--- a/func/certmaster.py
+++ b/func/certmaster.py
@@ -61,12 +61,22 @@ class CertMaster(object):
else:
self.cfg.autosign = False
self.cfg.listen_port = int(self.cfg.listen_port)
+ self.ca_key_file = '%s/funcmaster.key' % self.cfg.cadir
+ self.ca_cert_file = '%s/funcmaster.crt' % self.cfg.cadir
+ try:
+ if not os.path.exists(self.cfg.cadir):
+ os.makedirs(self.cfg.cadir)
+ # fixme - should we creating these separately?
+ if not os.path.exists(self.ca_key_file) and not os.path.exists(self.ca_cert_file):
+ func.certs.create_ca(ca_key_file=self.ca_key_file, ca_cert_file=self.ca_cert_file)
+ except (IOError, OsError), e:
+ print 'Cannot make certmaster certificate authority keys/certs, aborting: %s' % e
+ sys.exit(1)
+
# open up the cakey and cacert so we have them available
- ca_key_file = '%s/funcmaster.key' % self.cfg.cadir
- ca_cert_file = '%s/funcmaster.crt' % self.cfg.cadir
- self.cakey = func.certs.retrieve_key_from_file(ca_key_file)
- self.cacert = func.certs.retrieve_cert_from_file(ca_cert_file)
+ self.cakey = func.certs.retrieve_key_from_file(self.ca_key_file)
+ self.cacert = func.certs.retrieve_cert_from_file(self.ca_cert_file)
for dirpath in [self.cfg.cadir, self.cfg.certroot, self.cfg.csrroot]:
if not os.path.exists(dirpath):
diff --git a/modules/copyfile.py b/modules/copyfile.py
index 7d04abf..58b5ea4 100644
--- a/modules/copyfile.py
+++ b/modules/copyfile.py
@@ -47,10 +47,13 @@ class CopyFile(func_module.FuncModule):
return thissum.hexdigest()
- def copyfile(self, filepath, filebuf):
+ def copyfile(self, filepath, filebuf, mode=0644, uid=0, gid=0, force=None):
# -1 = problem file was not copied
# 1 = file was copied
# 0 = file was not copied b/c file is unchanged
+
+
+ # we should probably verify mode,uid,gid are valid as well
dirpath = os.path.dirname(filepath)
basepath = os.path.basename(filepath)
@@ -62,7 +65,7 @@ class CopyFile(func_module.FuncModule):
if os.path.exists(filepath):
local_sum = self.checksum(filepath)
- if remote_sum != local_sum:
+ if remote_sum != local_sum or force is not None:
# back up the localone
if os.path.exists(filepath):
if not self._backuplocal(filepath):
@@ -79,6 +82,14 @@ class CopyFile(func_module.FuncModule):
return -1
else:
return 0
+
+ # hmm, need to figure out proper exceptions -akl
+ try:
+ # we could intify the mode here if it's a string
+ os.chmod(filepath, mode)
+ os.chown(filepath, uid, gid)
+ except (IOError, OSError), e:
+ return -1
return 1
diff --git a/scripts/certmaster b/scripts/certmaster
index 1be4c58..f4bcf53 100755
--- a/scripts/certmaster
+++ b/scripts/certmaster
@@ -1,11 +1,6 @@
#!/usr/bin/python
-import sys
-import distutils.sysconfig
-
-sys.path.append("%s/func" % distutils.sysconfig.get_python_lib())
-
-import certmaster
+from func import certmaster
defaults = { 'listen_addr': 'localhost',
'listen_port': '51235',