scp bug: newly created dirs do not inherit sgid bit

Petr Skovron xofon at pikomat.mff.cuni.cz
Wed Oct 12 01:20:03 EST 2005


     Dear developers,

     I discovered that directories created by scp when recursive
copying into a sgid directory do not inherit the sgid bit. I believe
this is a bug. A patch to fix this is attached.

     Regards,
       Petr Skovron
-------------- next part --------------
--- scp.c.orig	2005-10-11 16:50:17.000000000 +0200
+++ scp.c	2005-10-11 16:57:25.000000000 +0200
@@ -876,8 +876,12 @@
 					run_err("%s: set times: %s",
 					    vect[0], strerror(errno));
 			}
-			if (mod_flag)
+			if (mod_flag) {
+				if (stat(vect[0], &stb)==0)
+					mode= (mode & S_IRWXU) |
+					    (stb.st_mode & ~S_IRWXU);
 				(void) chmod(vect[0], mode);
+			}
 			if (vect[0])
 				xfree(vect[0]);
 			continue;


More information about the openssh-unix-dev mailing list