[rsh] rcp: handle copying of directories with ending slash well (#784467)

Adam Tkac atkac at fedoraproject.org
Tue Jan 31 16:31:54 UTC 2012


commit c0f15b59f4dd0967d6099eb3ba8de841f01840ac
Author: Adam Tkac <atkac at redhat.com>
Date:   Tue Jan 31 17:31:39 2012 +0100

    rcp: handle copying of directories with ending slash well (#784467)
    
    Signed-off-by: Adam Tkac <atkac at redhat.com>

 netkit-rsh-0.17-rh784467.patch |   50 ++++++++++++++++++++++++++++++++++++++++
 rsh.spec                       |    7 ++++-
 2 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/netkit-rsh-0.17-rh784467.patch b/netkit-rsh-0.17-rh784467.patch
new file mode 100644
index 0000000..9f24ada
--- /dev/null
+++ b/netkit-rsh-0.17-rh784467.patch
@@ -0,0 +1,50 @@
+diff -up netkit-rsh-0.17/rcp/rcp.c.rh784467 netkit-rsh-0.17/rcp/rcp.c
+--- netkit-rsh-0.17/rcp/rcp.c.rh784467	2012-01-31 15:47:57.996697245 +0100
++++ netkit-rsh-0.17/rcp/rcp.c	2012-01-31 17:11:23.489578305 +0100
+@@ -511,6 +511,37 @@ notreg:			(void)close(f);
+ 	}
+ }
+ 
++static char *
++rcp_basename(char *path)
++{
++	char *bname;
++
++	if (path == NULL || *path == '\0')
++		return NULL;
++
++retry:
++	/* Note this is GNU basename */
++	bname = basename(path);
++	if (*bname == '\0') {
++		/* path ends with '/', strip them all */
++		char *end = path + strlen(path) - 1;
++		while (path <= end && *end == '/') {
++			*end = '\0';
++			end--;
++		}
++
++		if (end < path) {
++			/* The path consists only from '/' chars */
++			*path = '/';
++			return path;
++		} else {
++			/* We removed all trailing '/' characters */
++			goto retry;
++		}
++	} else
++		return bname;
++}
++
+ static void
+ rsource(char *name, struct stat *statp)
+ {
+@@ -522,7 +553,7 @@ rsource(char *name, struct stat *statp)
+ 		error("rcp: %s: %s\n", name, strerror(errno));
+ 		return;
+ 	}
+-	last = strrchr(name, '/');
++	last = rcp_basename(name);
+ 	if (last == 0)
+ 		last = name;
+ 	else
diff --git a/rsh.spec b/rsh.spec
index 2f8ccf5..04c30dc 100644
--- a/rsh.spec
+++ b/rsh.spec
@@ -1,7 +1,7 @@
 Summary: Clients for remote access commands (rsh, rlogin, rcp)
 Name: rsh
 Version: 0.17
-Release: 67%{?dist}
+Release: 68%{?dist}
 License: BSD
 Group: Applications/Internet
 
@@ -78,6 +78,7 @@ Patch39: netkit-rsh-0.17-rh461903.patch
 Patch40: netkit-rsh-0.17-rh473492.patch
 Patch41: netkit-rsh-0.17-rh650119.patch
 Patch42: netkit-rsh-0.17-rh710987.patch
+Patch43: netkit-rsh-0.17-rh784467.patch
 
 %description
 The rsh package contains a set of programs which allow users to run
@@ -145,6 +146,7 @@ from other machines
 %patch40 -p1 -b .rh473492
 %patch41 -p1 -b .rh650119
 %patch42 -p1 -b .rh710987
+%patch43 -p1 -b .rh784467
 
 # No, I don't know what this is doing in the tarball.
 rm -f rexec/rexec
@@ -214,6 +216,9 @@ rm -rf ${RPM_BUILD_ROOT}
 %{_mandir}/man8/*.8*
 
 %changelog
+* Tue Jan 31 2012 Adam Tkac <atkac redhat com> - 0.17-68
+- rcp: handle copying of directories with ending slash well (#784467)
+
 * Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.17-67
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 


More information about the scm-commits mailing list