Red Hat Bugzilla – Bug 467189
rhncfg-manager download-channel does not set the correct permissions
Last modified: 2009-09-17 03:02:05 EDT
+++ This bug was initially created as a clone of Bug #428721 +++
Description of problem:
When using rhncfg-manager download-channel to download a configuration channel, the tool does not set the permissions on the downloaded files correctly to the settings entered through the satellite interface.
Steps to Reproduce:
Create a config channel (config-channel-name) and upload config files/create config file and under File Permissions Mode *: give anything apart from 644. Example - give 642
Then subscribe the system to this config channel.
On client system -
- go to a temporary directory
# cd /tmp
- use rhncfg-manager to download the required channel, specifying the temporary directory
# rhncfg-manager download-channel --topdir /tmp config-channel-name
- check the ownership and file permissions on the files downloaded
ls -al /tmp/config-channel-name
# ls -al /tmp/139616-Config/*
The files downloaded are having the permissions as 644 and not the ones specified on Satellite (642).
File permissions after download are 644
It should have been as the one specified under the config channel - 642
--- Engineering ---
It seems that we simply ignore the "mode" set from the WebUI while
downloading the config files. So, when these files get downloaded it uses
the default umask which sets the permissions to 644 for a file.
for file_path in r.list_files(ns):
#5/11/05 wregglej - 157066 dirs_created now gets returned by
(temp_file, info, dirs_created) = r.get_file_info(ns, file_path)
dest_file = utils.join_path(topdir, ns, file_path)
print "Deploying %s -> %s" % (file_path, dest_file)
utils.copyfile_p(temp_file, dest_file) -> This is where the file gets
copied to the destination.
get_file_info() - Returns all the attributes related to the configuration
file including the 'filemode'.
so looking at utils.copyfile_p():
def copyfile_p(src, dst):
Simple util function, copies src path to dst path, making
directories as necessary. File permissions are not preserved.
if not os.path.exists(dst):
copy(src, dst) - Copy data and mode bits ("cp src dst").
This is a simple copy, I tried using copy2() but that does help.
copy2(src, dst) - Copy data and all stat info ("cp -p src dst")
Probably, we'll have to somehow make the "mode" available to this
function, this issue is only while downloading the file using
rhncfg-manager, deploying config files take care of the mode set from the
Fixed in git repo.
Created commit a4ec562: 467189, 428721 - set filemode and ownership on config files
2 files changed, 9 insertions(+), 0 deletions(-)
Oops :), the right commit sha1 is
467189, 428721 - set filemode and ownership on config files
Spacewalk has been released for some time.