summaryrefslogtreecommitdiffstats
path: root/src/lib/Client/Toolset.py
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2005-04-04 14:38:41 +0000
committerNarayan Desai <desai@mcs.anl.gov>2005-04-04 14:38:41 +0000
commit248e6145a75b7b25b0e5349fc750a79073f4ed51 (patch)
tree1d45d5cd0597b2394907917c9058a816aad861dd /src/lib/Client/Toolset.py
parent45586b4c51650b0352ddf06d27622bd845174729 (diff)
downloadbcfg2-248e6145a75b7b25b0e5349fc750a79073f4ed51.tar.gz
bcfg2-248e6145a75b7b25b0e5349fc750a79073f4ed51.tar.bz2
bcfg2-248e6145a75b7b25b0e5349fc750a79073f4ed51.zip
fix directory installation for wrongperms case
(Logical change 1.218) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@914 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client/Toolset.py')
-rw-r--r--src/lib/Client/Toolset.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py
index 3b2ed5c91..34644464f 100644
--- a/src/lib/Client/Toolset.py
+++ b/src/lib/Client/Toolset.py
@@ -178,8 +178,10 @@ class Toolset(object):
try:
fmode = lstat(entry.get('name'))[ST_MODE]
if S_ISREG(fmode) or S_ISLNK(fmode):
+ self.CondPrint('debug', "Non-directory entry already exists at %s" % (entry.get('name')))
unlink(entry.get('name'))
elif S_ISDIR(fmode):
+ self.CondPrint('debug', "Directory entry already exists at %s" % (entry.get('name')))
system("mv %s/ %s.bak" % (entry.get('name'), entry.get('name')))
else:
unlink(entry.get('name'))
@@ -220,24 +222,29 @@ class Toolset(object):
def InstallDirectory(self, entry):
'''Install Directory Entry'''
+ exists = False
self.CondPrint('verbose', "Installing Directory %s" % (entry.get('name')))
try:
fmode = lstat(entry.get('name'))
if not S_ISDIR(fmode[0]):
+ self.CondPrint("debug", "Found a non-directory entry at %s" % (entry.get('name')))
try:
unlink(entry.get('name'))
except OSError:
- self.CondPrint('debug', "Failed to unlink %s" % (entry.get('name')))
+ self.CondPrint('verbose', "Failed to unlink %s" % (entry.get('name')))
return False
+ else:
+ exists = True
except OSError:
# stat failed
pass
-
- try:
- mkdir(entry.get('name'))
- except OSError:
- self.CondPrint('debug', 'Failed to create directory %s' % (entry.get('name')))
- return False
+
+ if not exists:
+ try:
+ mkdir(entry.get('name'))
+ except OSError:
+ self.CondPrint('debug', 'Failed to create directory %s' % (entry.get('name')))
+ return False
try:
chown(entry.get('name'),
getpwnam(entry.get('owner'))[2], getgrnam(entry.get('group'))[2])