summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/utils/syncdaemon/resource.py
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-03-10 00:42:48 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-10 07:39:50 -0800
commit38d57757b33983052594e14582611ef05f753581 (patch)
treeae86f2bd37761148753ac5eb213304e969244cc5 /xlators/features/marker/utils/syncdaemon/resource.py
parent19e65beb16d2dc337d144e25337561ff6e82826a (diff)
syncdaemon: fortify purge implementation to not do silly things like following symlinks
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2377 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2377
Diffstat (limited to 'xlators/features/marker/utils/syncdaemon/resource.py')
-rw-r--r--xlators/features/marker/utils/syncdaemon/resource.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py
index dc3279d5290..6882164b9c5 100644
--- a/xlators/features/marker/utils/syncdaemon/resource.py
+++ b/xlators/features/marker/utils/syncdaemon/resource.py
@@ -12,7 +12,7 @@ import tempfile
import threading
from ctypes import *
from ctypes.util import find_library
-from errno import EEXIST, ENOENT, ENODATA, ENOTDIR, ELOOP
+from errno import EEXIST, ENOENT, ENODATA, ENOTDIR, ELOOP, EISDIR
from gconf import gconf
import repce
@@ -100,7 +100,17 @@ class Server(object):
me_also = entries == None
if not entries:
try:
- entries = os.listdir(path)
+ # if it's a symlink, prevent
+ # following it
+ try:
+ os.unlink(path)
+ return
+ except OSError:
+ ex = sys.exc_info()[1]
+ if ex.errno == EISDIR:
+ entries = os.listdir(path)
+ else:
+ raise
except OSError:
ex = sys.exc_info()[1]
if ex.errno in (ENOTDIR, ENOENT, ELOOP):
@@ -109,8 +119,9 @@ class Server(object):
return
except OSError:
ex = sys.exc_info()[1]
- if ex.errno != ENOENT:
- raise
+ if ex.errno == ENOENT:
+ return
+ raise
else:
raise
for e in entries: