Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1361269 - SymlInk target overwritten when the symlink is replaced by a file managed by rhncfg-client
Summary: SymlInk target overwritten when the symlink is replaced by a file managed by ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Configuration Management
Version: 570
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Eric Herget
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
Depends On:
Blocks: sat580-low
TreeView+ depends on / blocked
 
Reported: 2016-07-28 16:22 UTC by Radovan Drazny
Modified: 2017-06-21 12:11 UTC (History)
3 users (show)

Fixed In Version: rhncfg-5.10.87-8-sat
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-21 12:11:37 UTC


Attachments (Terms of Use)
Helper script creating the config channel and managed file on the satellite 5 server (deleted)
2016-07-28 16:22 UTC, Radovan Drazny
no flags Details
Main script presenting the issue. (deleted)
2016-07-28 16:22 UTC, Radovan Drazny
no flags Details

Description Radovan Drazny 2016-07-28 16:22:04 UTC
Created attachment 1185181 [details]
Helper script creating the config channel and managed file on the satellite 5 server

Description of problem:
Under certain conditions, rhncfg-client can overwrite local file that is not managed by Satellite 5 config management. 

Version-Release number of selected component (if applicable):
rhncfg-client-5.10.74-11.el7sat

How reproducible:
always

Steps to Reproduce:
Bug is triggered only under following condition:
rhncfg-client backup directory (/var/lib/rhncfg/backups by default) MUST be on a different filesystem than the file managed by the rhncfg-client.

1. On a client registered to a Satellite 5 server create a local file in a location on a different filesystem than the rhncfg-client backup directory.
2. Create a symlink pointing to the local file from step 1. This symlink must be on different filesystem than the rhncfg-client backup directory.
3. Create a configuration channel on the Satellite 5 server, containing a managed configuration file with the same path as the symlink created in step 2. Subscribe the client from step 1 to this configuration channel and enable the config management on this client.
4. Run "rhncfg-client get" on the client. Symlink will be backed up to the backup dir, and replaced with the managed file from step 3. 
5. Run "rhncfg-client get" again. Expected behavior is that file deployed in step 4 will get backed up, replacing the original backed up symlink. Instead, the symlink remains in the backup directory, and symlink target is overwritten by the backup. 

Actual results:
Symlink backup isn't replaced by the file backup, the original symlink target is overwritten instead.

Expected results:
Symlink backup is replaced by the file backup, original symlink target remains untouched.

Additional info:
Problem is in file /usr/share/rhn/config_common/transactions.py on lines 87-106. This code path is triggered by "OSError: [Errno 18] Invalid cross-device link" exception on line 87, which occurs only when backup dir lies on different filesystem than the original file. If both managed file/original symlink and backup directory are on the same filesystem, backup works as expected, and symlink target doesn't get overwritten. 

I have attached reproducer script to illustrate the problem. Place both files to same directory, make runtest.sh executable and run it on a client registered to a Satellite server with following parameters:

runtest.sh http://<satellite_server_domainname> <sat_username> <sat_password>

The script creates all files and filesystem in the /tmp directory, and config channel and managed file on the Satellite 5 server specified on the command line.

Comment 1 Radovan Drazny 2016-07-28 16:22:52 UTC
Created attachment 1185182 [details]
Main script presenting the issue.

Comment 2 Eric Herget 2017-02-22 21:32:40 UTC
spacewalk.github:
9bacb8c9ece1c385549da9267b7b9ec39bb607e9

rhncfg-5.10.102-1

Comment 4 Lukáš Hellebrandt 2017-04-19 09:45:19 UTC
Verified with rhncfg-5.10.87-9 against Sat5.8.

Used rdrazny's reproducer. The managed file contains "MANAGED", the backup file contains "MANAGED" (and is NOT a symlink) and the linked file contains "LOCAL".


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