Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 49321

Summary: rcp to /dev/null with devfs enabled causes error
Product: [Retired] Red Hat Linux Reporter: Need Real Name <pedretti>
Component: rshAssignee: Phil Knirsch <pknirsch>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: pedretti, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-07-20 17:37:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2001-07-17 23:43:24 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.77 [en] (X11; U; Linux 2.4.2-2 i686)

Description of problem:
When rcp'ing a file to /dev/null, an error is caused because the devfs
implementation of /dev/null doesn't seem to allow ftruncate() to be called
on it.  rcp calls ftruncate() after the end of a transfer (on the
receiver).  This was never a problem before using a non-devfs /dev/null. 

Our batch queueing software copies the stdout and stderr files back to the
submitting host using rcp.  Many of our scripts copy these to /dev/null
when they are not needed.  Hence the problem.  Because an error is thrown,
there is a delay of ~30 at the end of every batch job.

As a quick fix, I modified rcp.c and recompiled. This worked but I'm
guessing it would be better to fix devfs to allow ftruncate calls. 



How reproducible:
Always

Steps to Reproduce:
[pedretti@foo ~]$ rcp filename foo:/dev/null




	

Actual Results:  rcp: can't truncate /dev/null: Permission denied

Expected Results:  No error messages

Additional info:

My fix, beginning line 883 in rcp.c:

if (ftruncate(ofd, size)) {
    /* fix to avoid calling ftruncate() on /dev/null */
    if (strncmp(np, "/dev/null", 9) != 0) {
        error("rcp: can't truncate %s: %s\n", 
            np, strerror(errno));
            wrerr = DISPLAYED;
    }
}

Comment 1 Phil Knirsch 2002-01-30 12:58:22 UTC
I agree. On the other hand, according to the 'official' specification for
ftruncate the behaviour of it is unspecified for anything but regular files or
shared memory segments, so an app must not rely on the fact that it does
anything reasonable on anything else.

So i'll fix it a little more thoroughly than you did, but it needs to be fixed
in rcp as it is broken there.

The next version (0.17-6) will have the fix included. Should be available via
rawhide real soon now (in the next couple of days).

Read ya, Phil