Bug 123833 - (PATCH) rdistd fails to create symlinks due to mktemp -> mkstemp change
(PATCH) rdistd fails to create symlinks due to mktemp -> mkstemp change
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: rdist (Show other bugs)
2
All Linux
medium Severity medium
: ---
: ---
Assigned To: Phil Knirsch
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-05-20 17:33 EDT by travis abbott
Modified: 2015-03-04 20:13 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-07-07 14:14:24 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch to fix this bug (434 bytes, patch)
2004-05-20 18:03 EDT, travis abbott
no flags Details | Diff

  None (edit)
Description travis abbott 2004-05-20 17:33:34 EDT
Description of problem:
 Attempting to rdist symbolic links to a target machine running Fedora
Core 2, it will always fail with the error `File exists'.

Version-Release number of selected component (if applicable):
rdist-6.1.5-32


How reproducible:
Always

Steps to Reproduce:
1. cd /tmp && rm -f foo bar && touch foo && ln -s foo bar && rdist -c
foo bar localhost:/tmp/a
2. Note the error message.
  
Actual results:
[root@latrine tmp]# cd /tmp && rm -f foo bar && touch foo && ln -s foo
bar && rdist -c foo bar localhost:/tmp/a
localhost: updating host localhost
localhost: foo: updating
localhost: bar: installing
localhost: latrine: REMOTE ERROR: /tmp/a/rdistgOyCUj -> foo: symlink
failed: File exists
localhost: updating of localhost finished


Expected results:
[root@latrine tmp]# cd /tmp && rm -f foo bar && touch foo && ln -s foo
bar && rdist -c foo bar localhost:/tmp/a
localhost: updating host localhost
localhost: foo: updating
localhost: bar: installing
localhost: updating of localhost finished


Additional info:
 This bug is caused in src/server.c. As rdist transfers each file, it
creates a temporary file first then moves it into place. The prevision
version of rdist shipped with FC1 (rdist-6.1.5-30.1) used 'mktemp()'
to generate filenames, which is bad. So the new version uses
'mkstemp()', which is better, except that it actually creates the file
on disk. The file is closed at link server.c:1491, yet it is left on
disk. This will cause 'symlink()' calls to fail when using this tmp
filename as the 2nd param. The file needs to be 'unlink()'ed as well
as closed.

Proposed fix:
change:
                } else if (fd >= 0)
                        close(fd);
to:
                } else if (fd >= 0) {
                        close(fd);
                        unlink(new); /* For symlinks */
                }

At line 1490 in src/server.c.
Comment 1 travis abbott 2004-05-20 18:03:30 EDT
Created attachment 100393 [details]
Patch to fix this bug

Run from rdist-6.1.5 directory, patch -Np1 < symlink.patch
Should fix the problem.
Comment 2 Phil Knirsch 2004-05-25 08:22:26 EDT
*** Bug 123931 has been marked as a duplicate of this bug. ***
Comment 3 Phil Knirsch 2004-05-25 09:04:55 EDT
OK, i've updated the rawhide version of rdist to include that fix.

Also preliminary test versions of the rpms for AS2.1 and RHEL3 are
available here:

http://people.redhat.com/pknirsch/

These packages are unsigned and not officially supported by Red Hat.
Either an errata or for the next update release these packages will be
officially released.

Thanks and sorry for the inconvenience.

Read ya, Phil
Comment 6 Derek T. Yarnell 2004-06-17 23:49:26 EDT
This is really not acceptable why redhat has not had an errata for
this yet. We use rdist to move our /usr/local trees about. Argh.
Comment 7 Matthew Miller 2006-07-07 14:14:24 EDT
So, looks like no fix ever went out for this, but the fix did go into rawhide
and FC3 on. It's pretty much too late for FC2, unfortunately. I'm going to mark
this as fixed in rawhide, although the "didn't actually get pushed as an update
and probably shoulda been" should get noted by someone.

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