Merge lp:~james-page/charm-helpers/follow-symlinks into lp:charm-helpers

Proposed by James Page
Status: Merged
Approved by: Ryan Beisner
Approved revision: 672
Merged at revision: 672
Proposed branch: lp:~james-page/charm-helpers/follow-symlinks
Merge into: lp:charm-helpers
Diff against target: 21 lines (+2/-2)
1 file modified
charmhelpers/core/host.py (+2/-2)
To merge this branch: bzr merge lp:~james-page/charm-helpers/follow-symlinks
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+314280@code.launchpad.net

Description of the change

The chownr function does not follow symlinks when walking a path, even
when follow_links is set to True.

Ensure that this value is propagated to os.walk, ensuring that targets
of symlinks within the path are also part of the fileset upon which
file permissions are changed.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/core/host.py'
2--- charmhelpers/core/host.py 2016-12-13 06:23:05 +0000
3+++ charmhelpers/core/host.py 2017-01-07 16:36:06 +0000
4@@ -686,7 +686,7 @@
5 :param str path: The string path to start changing ownership.
6 :param str owner: The owner string to use when looking up the uid.
7 :param str group: The group string to use when looking up the gid.
8- :param bool follow_links: Also Chown links if True
9+ :param bool follow_links: Also follow and chown links if True
10 :param bool chowntopdir: Also chown path itself if True
11 """
12 uid = pwd.getpwnam(owner).pw_uid
13@@ -700,7 +700,7 @@
14 broken_symlink = os.path.lexists(path) and not os.path.exists(path)
15 if not broken_symlink:
16 chown(path, uid, gid)
17- for root, dirs, files in os.walk(path):
18+ for root, dirs, files in os.walk(path, followlinks=follow_links):
19 for name in dirs + files:
20 full = os.path.join(root, name)
21 broken_symlink = os.path.lexists(full) and not os.path.exists(full)

Subscribers

People subscribed via source and target branches