summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-09-07 03:10:13 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-09-07 03:10:13 +0000
commit5fdcf47476c8be57ac0608109979f449d4882279 (patch)
tree5926547966853e2cdc4ee1fd01eed029e16da6da /src/lib
parentf431b4b08bf2e0b28225bfdf84f62aa2a8aa9bbb (diff)
downloadbcfg2-5fdcf47476c8be57ac0608109979f449d4882279.tar.gz
bcfg2-5fdcf47476c8be57ac0608109979f449d4882279.tar.bz2
bcfg2-5fdcf47476c8be57ac0608109979f449d4882279.zip
POSIX: Replace incorrect SymLinks
We were ignoring existing symlink entries even though they were incorrect. This commit adds the ability for the client to check for incorrect symlinks and replace them if they exist. Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5415 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Client/Tools/POSIX.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/Client/Tools/POSIX.py b/src/lib/Client/Tools/POSIX.py
index bc9626e88..37a4111d4 100644
--- a/src/lib/Client/Tools/POSIX.py
+++ b/src/lib/Client/Tools/POSIX.py
@@ -129,16 +129,22 @@ class POSIX(Bcfg2.Client.Tools.Tool):
def InstallSymLink(self, entry):
'''Install SymLink Entry'''
self.logger.info("Installing Symlink %s" % (entry.get('name')))
- if os.path.exists(entry.get('name')):
+ if os.path.lexists(entry.get('name')):
try:
fmode = os.lstat(entry.get('name'))[ST_MODE]
if S_ISREG(fmode) or S_ISLNK(fmode):
- self.logger.debug("Non-directory entry already exists at %s" % \
- (entry.get('name')))
+ self.logger.debug("Non-directory entry already exists at "
+ "%s. Unlinking entry." % (entry.get('name')))
os.unlink(entry.get('name'))
elif S_ISDIR(fmode):
- self.logger.debug("Directory entry already exists at %s" % (entry.get('name')))
- self.cmd.run("mv %s/ %s.bak" % (entry.get('name'), entry.get('name')))
+ self.logger.debug("Directory entry already exists at %s" % \
+ (entry.get('name')))
+ self.cmd.run("mv %s/ %s.bak" % \
+ (entry.get('name'),
+ entry.get('name')))
+ elif S_ISLNK(fmode):
+ self.logger.debug("Replacing existing SymLink with the one "
+ "specified in bcfg2")
else:
os.unlink(entry.get('name'))
except OSError: