aboutsummaryrefslogtreecommitdiffstats
path: root/share/Perms.py
diff options
context:
space:
mode:
authorAndreas Hasenack <andreas@mandriva.com>2008-01-11 13:28:21 +0000
committerAndreas Hasenack <andreas@mandriva.com>2008-01-11 13:28:21 +0000
commit8008f5d72be144a46b1cb48613e0dc785aee1aad (patch)
treed7513d2f40034e50be709e8b1a0cebd455adb4e9 /share/Perms.py
parent9501f9cc00da922dfc0c71a2d94c578df9cd8e84 (diff)
downloadmsec-8008f5d72be144a46b1cb48613e0dc785aee1aad.tar
msec-8008f5d72be144a46b1cb48613e0dc785aee1aad.tar.gz
msec-8008f5d72be144a46b1cb48613e0dc785aee1aad.tar.bz2
msec-8008f5d72be144a46b1cb48613e0dc785aee1aad.tar.xz
msec-8008f5d72be144a46b1cb48613e0dc785aee1aad.zip
- properly dereference symlinks when checking for remote filesystem (#14387)
Diffstat (limited to 'share/Perms.py')
-rwxr-xr-xshare/Perms.py27
1 files changed, 4 insertions, 23 deletions
diff --git a/share/Perms.py b/share/Perms.py
index 59dab97..ff4af73 100755
--- a/share/Perms.py
+++ b/share/Perms.py
@@ -117,20 +117,6 @@ def build_non_localfs_regexp():
else:
return re.compile(regexp + REGEXP_END)
-# resolv symlink
-def get_sylink_name(path):
- try:
- p = os.readlink(path)
- except OSError:
- return path
- if p and p[0] != '/':
- p = os.path.dirname(path) + '/' + p
- p = os.path.abspath(p)
- if p == path:
- return path
- else:
- return get_sylink_name(p)
-
# put the new perm/group/owner in the assoc variable according to the
# content of the path file.
assoc = {}
@@ -192,20 +178,15 @@ def fix_perms(path, _interactive, force):
if fieldcount == 4:
for f in glob.glob(fields[0]):
newperm = perm
- if fs_regexp and fs_regexp.search(f):
- _interactive and log(_('Non local file: "%s". Nothing changed.') % fields[0])
- continue
+ f = os.path.realpath(f)
try:
full = os.lstat(f)
except OSError:
continue
- if stat.S_ISLNK(full[stat.ST_MODE]):
- f = get_sylink_name(f)
- try:
- full = os.stat(f)
- except OSError:
- continue
+ if fs_regexp and fs_regexp.search(f):
+ _interactive and log(_('Non local file: "%s". Nothing changed.') % fields[0])
+ continue
mode = stat.S_IMODE(full[stat.ST_MODE])