Bug 675208 - rhncfg-client cannot create cross-device symlinks
Summary: rhncfg-client cannot create cross-device symlinks
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Configuration Management
Version: 540
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Michael Mráka
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: sat54-blockers
TreeView+ depends on / blocked
 
Reported: 2011-02-04 16:05 UTC by Scott Mayhew
Modified: 2018-11-29 19:24 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-08-24 12:08:15 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Scott Mayhew 2011-02-04 16:05:30 UTC
Description of problem:


Version-Release number of selected component (if applicable):
5.4

How reproducible:
always

Steps to Reproduce:
1. Create a symbolic link type configuration file in a configuration channel, for example linking /bin/bash to /usr/bin/bash
2. Subscribe a system to the configuration channel.  The system should be configured so that the symlink would be on a separate filesystem (in this case /usr).
3. rhncfg-client get
  
Actual results:

Deploying /usr/bin/bash
Deploy failed, rollback successful
Traceback (most recent call last):
  File "/usr/bin/rhncfg-client", line 34, in ?
    sys.exit(Main().main() or 0)
  File "/usr/share/rhn/config_common/rhn_main.py", line 187, in main
    handler.run()
  File "/usr/share/rhn/config_client/rhncfgcli_get.py", line 71, in run
    dep_trans.deploy()
  File "/usr/share/rhn/config_common/transactions.py", line 357, in deploy
    os.rename(self.newtemp_by_path[path], path)
OSError: [Errno 18] Invalid cross-device link

Expected results:

The symlink should be deployed successfully.

Additional info:

symlink("/bin/bash", ".rhn-cfg-tmp_bash_1730_1296835109.74155688") = 0
stat("/usr/bin/bash", 0x7fffb0b56570)   = -1 ENOENT (No such file or directory)
stat("/usr/bin", {st_mode=S_IFDIR|0755, st_size=20480, ...}) = 0
gettimeofday({1296835109, 742060}, NULL) = 0
symlink("/bin/bash", ".rhn-cfg-tmp_bash_1730_1296835109.74205995") = 0
stat("/usr/bin/bash", 0x7fffb0b56570)   = -1 ENOENT (No such file or directory)
stat("/usr/bin/bash", 0x7fffb0b56310)   = -1 ENOENT (No such file or directory)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(204, 191), ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 opost isig icanon echo ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b256011c000
write(1, ""..., 24)                     = 24
rename(".rhn-cfg-tmp_bash_1730_1296835109.74205995", "/usr/bin/bash") = -1 EXDEV (Invalid cross-device link)

This is due to the steps deploy() method in transactions.py performs so it can roll back the change in the event that it fails.  The steps are documented in the comments:

        # 0. handle any dirs we need to create first
        #    a) if the dir exists, then just change the mode and owners, 
        #       else create it and then make sure the mode and owners are correct.
        #    b) if there are files, then continue
        # 1. write new version (tmp)
        #    a)  if anything breaks, remove all tmp versions and error out
        # 2. rename old version to backup
        #    a)  if anything breaks, rename all backed up files to original name,
        #        then do 1-a.
        # 3. rename tmp to target name
        #    a)  if anything breaks, remove all deployed files, then do 2-a.
        #
        # (yes, this leaves the backup version on disk...)

A temp file is created for the symlink in step 1, but the rename fails in step 3 because the temp file and the link name are on different devices.

Comment 5 Jan Pazdziora 2011-08-19 19:54:19 UTC
Please note that there is a Spacewalk bug 623774, with patch that I'm not very happy about. If you fix this Satellite bug, please make a note in the Spacewalk bugzilla as well.


Note You need to log in before you can comment on or make changes to this bug.