Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <911C684A29ACD311921800508B7293BA010A8AC2@cnmail> From: Mark Bradshaw To: "'Corinna Vinschen'" Subject: RE: SFTP server when / is c:\ Date: Tue, 24 Jul 2001 15:44:19 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Note-from-DJ: This may be spam Corinna, Here's the patches needed to deal with the sftp double slash path problem. As I mentioned before it only comprised one change on the server side, and one change on the client side. I was able to do both with one line changes, and the logic is simple so I think it's got a decent chance of passing muster. The diffs following are against the 2.9p2 source, not the latest openssh cvs snapshot. If you'd like I can make new diff's against the latest source. I wasn't sure which you'd want. The change to the client side happens in sftp-int.c. This patch corrects the functioning of get and put when in the root directory. I made a change to the path_append function. This is where the double slash is originating. I added a check that determines if the path is equal to "/". If it's not then the result of the function is path + "/" + file. Otherwise it's just path + file. The server side patch happens in sftp-server.c, and corrects the function of ls and dir in the root directory. The change is in the process_readdir function. It determines if the path is equal to "/". If it is it empties path out. Then when the lines below it create a path by doing path + "/" + filename it only uses one forward slash. There were other ways to do the patch, but I wanted to keep it as lightweight as possible. Both patches only affect operations when in root. I think the changes are good for openssh in general since the existing logic is (IMO) incorrect. Neither piece of code has been patched in the latest OpenSSH cvs source code. I appreciate you taking a look at this. I didn't want to start throwing stuff onto the openssh developers list without having you give it the once-over. Mark ------------------------- --- /usr/src/openssh-2.9p2-2/sftp-int.c Tue May 8 20:39:19 2001 +++ /tmp/openssh-2.9p2/sftp-int.c Tue Jul 24 15:00:08 2001 @@ -204,7 +204,7 @@ path_append(char *p1, char *p2) ret = xmalloc(len); strlcpy(ret, p1, len); - strlcat(ret, "/", len); + if ( strcmp(p1,"/") != 0 ) strlcat(ret, "/", len); strlcat(ret, p2, len); return(ret); -------------------------- --- /sftp-server.c Tue Jul 24 15:14:17 2001 +++ /usr/src/openssh-2.9p2-2/sftp-server.c Fri Apr 13 10:28:42 2001 @@ -753,7 +753,6 @@ process_readdir(void) stats = xrealloc(stats, nstats * sizeof(Stat)); } /* XXX OVERFLOW ? */ + if ( strcmp(path, "/") ==0 ) path[0] = 0; snprintf(pathname, sizeof pathname, "%s/%s", path, dp->d_name); if (lstat(pathname, &st) < 0) -------------------------- -----Original Message----- From: Corinna Vinschen [mailto:cygwin AT cygwin DOT com] Sent: Tuesday, July 24, 2001 2:27 PM To: 'cygwin AT cygwin DOT com' Subject: Re: SFTP server when / is c:\ On Tue, Jul 24, 2001 at 12:44:08PM -0400, Mark Bradshaw wrote: > SFTP server has some unfortunate logic that occurs when you try to ls, get, > or put things in root (/). It's got logic all over the place that creates > paths that start with "//". Cygwin doesn't like to deal with these kind of > paths. This causes ls, get, and put (at least) to not work in /. > > When you do an ls (for example) sftp server creates pathnames to pass back. > It does this by combining the path + "/" + filename. This works great as > long as the path doesn't includes a final /, which it normally doesn't. > However, when you switch to / the path is / (obviously). The ls would then > end up coming back with things like //., //.., //cygwin.bat, etc. > > Seems that unix machines deal with these double slash paths, but cygwin > doesn't? Am I on track here. Either way, I'm wondering which direction is > the best to attempt a patch with. Patch sftp-server.c in lots of spots, or > cygwin in (?) spots? Patching sftp-server even if that will result in some... resistance by the maintainers is appropriate. Cygwin has to deal with // paths (//server/share/...) and we can't change that. If you're able to create a clean and neat patch I will try to convince the maintainers of openssh. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin AT cygwin DOT com Red Hat, Inc. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/