Hello team,
Here follow an complementary patch for commit
06a1f13b03f569c6a251e5fbe45069e6b8bb0c9f when handling directory symlinks.
After applying the patch:
#rhncfg-client elist
Mode Owner Group Size Rev Config Channel File
lrwxrwxrwx root root 14 1 teste
/boot/cross-dir -> /usr/local/bin
lrwxrwxrwx root root 11 2 teste
/boot/cross-link -> /etc/passwd
-rw-r--r-- root root 15 1 teste
/etc/test-file-regular
lrwxrwxrwx root root 10 2 teste
/root/sym-link-same-part -> /etc/hosts
lrwxrwxrwx root root 4 1 teste
/teste -> /tmp
#rhncfg-client verify
missing /boot/cross-dir
missing /boot/cross-link
missing /etc/test-file-regular
missing /root/sym-link-same-part
missing /teste
#rhncfg-client get
Deploying /etc/test-file-regular
Deploying /boot/cross-link
Deploying /root/sym-link-same-part
Deploying /teste
Deploying /boot/cross-dir
#rhncfg-client verify
/boot/cross-dir
/boot/cross-link
/etc/test-file-regular
/root/sym-link-same-part
/teste
#ls -lad /teste /boot/cross-dir
lrwxrwxrwx 1 root root 14 Nov 14 16:40 /boot/cross-dir -> /usr/local/bin
lrwxrwxrwx 1 root root 4 Nov 14 16:40 /teste -> /tmp
#rhncfg-client get
Deploying /etc/test-file-regular
Deploying /boot/cross-link
Deploying /root/sym-link-same-part
Deploying /teste
Deploying /boot/cross-dir
#ls -lad /teste /boot/cross-dir
lrwxrwxrwx 1 root root 14 Nov 14 16:41 /boot/cross-dir -> /usr/local/bin
lrwxrwxrwx 1 root root 4 Nov 14 16:41 /teste -> /tmp
#tree /var/lib/rhncfg/backups/
/var/lib/rhncfg/backups/
|-- boot
| |-- cross-dir.rhn-cfg-backup -> /usr/local/bin
| `-- cross-link.rhn-cfg-backup -> /etc/passwd
|-- etc
| `-- test-file-regular.rhn-cfg-backup
|-- root
| `-- sym-link-same-part.rhn-cfg-backup -> /etc/hosts
`-- teste.rhn-cfg-backup -> /tmp
5 directories, 3 files
Thank you.
Best Regards,
mmello
--
Marcelo Moreira de Mello
RHCA RHCSS RHCVA
Senior Software Maintenance Engineer/SEG
gpg id: 2048R/FDB110E5
gpg fingerprint: 3BE7 EF71 4DD7 6812 D309 8F18 BD42 D095 FDB1 10E5
From: Marcelo Moreira de Mello <mme...@redhat.com>
Date: Mon, 14 Nov 2011 16:32:00 -0200
Subject: [PATCH] 627490 - rhncfg-client handles symlinks to directories wrong
Complementary patch for commit 06a1f13b03f569c6a251e5fbe45069e6b8bb0c9f
lrwxrwxrwx 1 root root 4 Nov 14 16:33 /teste -> /tmp
2011-11-14 16:33:06 rpc_cli_repository.list_files:
2011-11-14 16:33:06 rpc_cli_repository.get_file_info: /teste
2011-11-14 16:33:06 transactions.add_preprocessed: preprocessing entry
2011-11-14 16:33:06 transactions.deploy: deploying transaction
2011-11-14 16:33:06 transactions.deploy: changed_dir_info: {}
2011-11-14 16:33:06 transactions.deploy: new_dirs: []
2011-11-14 16:33:06 transactions.deploy: done with directory creation, moving
on to files
2011-11-14 16:33:06 transactions._rename_to_backup: renaming /teste to backup
/var/lib/rhncfg/backups/teste.rhn-cfg-backup ...
2011-11-14 16:33:06 transactions._rename_to_backup: trying to use os.renames
2011-11-14 16:33:06 transactions._rename_to_backup: os.renames failed, using
shutil functions
2011-11-14 16:33:06 transactions._rename_to_backup: copying symlink /teste to
/var/lib/rhncfg/backups
2011-11-14 16:33:06 transactions._rename_to_backup: symlink /teste exists,
removing it
2011-11-14 16:33:06 transactions._rename_to_backup: backed up to
/var/lib/rhncfg/backups/teste.rhn-cfg-backup
2011-11-14 16:33:06 transactions.deploy: backup file
/var/lib/rhncfg/backups/teste.rhn-cfg-backup written
Deploying /teste
2011-11-14 16:33:06 transactions.deploy: deploying /teste ...
2011-11-14 16:33:06 transactions.deploy: new version of /teste deployed
2011-11-14 16:33:06 transactions.deploy: deploy transaction successful
2011-11-14 16:33:06 rpc_cli_repository.cleanup:
---
client/tools/rhncfg/config_common/transactions.py | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/client/tools/rhncfg/config_common/transactions.py
b/client/tools/rhncfg/config_common/transactions.py
index 0a90ba0..db778df 100644
--- a/client/tools/rhncfg/config_common/transactions.py
+++ b/client/tools/rhncfg/config_common/transactions.py
@@ -89,8 +89,16 @@ class DeployTransaction:
path_dir, path_file = os.path.split(path)
new_path_dir, new_path_file = os.path.split(new_path)
if os.path.isdir(new_path_dir):
- log_debug(9, "backup directory %s exists, copying
%s to it" % (new_path_dir, new_path_file))
- shutil.copy(path, new_path)
+ if os.path.islink(path):
+ log_debug(9, "copying symlink %s to %s"%
(path,new_path_dir))
+ linkto = os.readlink(path)
+ if os.path.exists(new_path):
+ log_debug(9, "symlink %s exists, removing
it"% (path))
+ os.unlink(new_path)
+ os.symlink(linkto,new_path)
+ else:
+ log_debug(9, "backup directory %s exists,
copying %s to it" % (new_path_dir, new_path_file))
+ shutil.copy(path, new_path)
else:
log_debug(9, "backup directory does not exist,
creating the tree now")
shutil.copytree(path_dir, new_path_dir, symlinks=0)
--
1.7.7.3
_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel