From 5fdcf47476c8be57ac0608109979f449d4882279 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Mon, 7 Sep 2009 03:10:13 +0000 Subject: 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 git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5415 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Client/Tools/POSIX.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/lib') 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: -- cgit v1.2.3-1-g7c22