summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-01-16 16:11:27 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-01-16 16:11:27 +0000
commit36aa72ac90b0a9635fa7b349698d72635809fc00 (patch)
tree6735032931797978c40cdfc060fa850107587196 /src/lib
parentefc5b0da2354f921e0a80441e583204a63bfc84a (diff)
downloadbcfg2-36aa72ac90b0a9635fa7b349698d72635809fc00.tar.gz
bcfg2-36aa72ac90b0a9635fa7b349698d72635809fc00.tar.bz2
bcfg2-36aa72ac90b0a9635fa7b349698d72635809fc00.zip
Make bcfg2 -P actually paranoid (Resolves Ticket #359)
* ConfigFile entry installation halted if backup cannot be created git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2683 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Client/Tools/POSIX.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py
index b086085a9..8fcd8b608 100644
--- a/src/lib/Client/Tools/POSIX.py
+++ b/src/lib/Client/Tools/POSIX.py
@@ -233,6 +233,12 @@ class POSIX(Bcfg2.Client.Tools.Tool):
return False
# If we get here, then the parent directory should exist
+ if entry.get("paranoid", False) and self.setup.get("paranoid", False):
+ bkupnam = entry.get('name').replace('/', '_')
+ if self.cmd.run("cp %s /var/cache/bcfg2/%s" % (entry.get('name'), bkupnam))[0]:
+ self.logger.error("Failed to create backup file for ConfigFile %s" % \
+ (entry.get('name')))
+ return False
try:
newfile = open("%s.new"%(entry.get('name')), 'w')
if entry.get('encoding', 'ascii') == 'base64':
@@ -249,8 +255,6 @@ class POSIX(Bcfg2.Client.Tools.Tool):
except KeyError:
os.chown(newfile.name, 0, 0)
os.chmod(newfile.name, calcPerms(S_IFREG, entry.get('perms')))
- if entry.get("paranoid", False) and self.setup.get("paranoid", False):
- self.cmd.run("cp %s /var/cache/bcfg2/%s" % (entry.get('name')))
os.rename(newfile.name, entry.get('name'))
return True
except (OSError, IOError), err: