host.mkdir can create inaccessible directories
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Charm Helpers |
New
|
Undecided
|
Unassigned |
Bug Description
host.mkdir works by:
- first calling os.makedirs(
- then os.chown(abspath, uid, gid)
- and finally os.chmod(abspath, uid, gid).
The first creates the full path. Any directories that don't exist in the full path are created with the requested permissions.
The second changes ownership of the final component of the path.
The third resets permissions of the final component of the path.
The problem is that if I call host.mkdir(
Instead, host.mkdir needs to calculate the absolute path and create the path one segment at a time, resetting the ownership and permissions if the segment did not already exist. This should normally Do What You Want, without allowing directories that should be protected to have their permissions opened up by an odd config setting.
The proposed fix will also address Bug #1421827