OpenSSH patches dealing with incorrect pathing

Mark Bradshaw bradshaw@staff.crosswalk.com
Wed Aug 8 15:46:00 GMT 2001


Corinna,
   I've found a few more pathing issues that I'd like to get patched in
OpenSSH.  I apologize for missing these when we did the last rounds.  I knew
the error existed.  I had just worked around it for so long that I forgot
about it.  <sigh>

Following are two patches that correct bad // pathing problems, like were
seen in the sftp apps.  They aren't (IMHO) as big a deal as the sftp
patches, since they only show up when the user either has no entry in the
passwd file, or has set their home directory to /.  When they do, however,
this causes ssh to try to put known_hosts files in //.ssh, which doesn't
work for some odd reason.  <grin>

As far as I can tell only ssh.c and tildexpand.c need to be patched.  Ssh.c
is patched where it tries to create the .ssh directory, and tildexpand.c is
patched where it expands the user's home directory (incorrectly).

Mark

================================================
diff for ssh.c

--- /usr/src/openssh-2.9p2-3/ssh.c	Tue Apr 17 14:14:35 2001
+++ ssh-new.c	Wed Aug  8 18:36:18 2001
@@ -680,7 +680,7 @@ main(int ac, char **av)
 	 * Now that we are back to our own permissions, create ~/.ssh
 	 * directory if it doesn\'t already exist.
 	 */
-	snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir,
_PATH_SSH_USER_DIR);
+	snprintf(buf, sizeof buf, "%.100s%s%.100s", pw->pw_dir,
strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR);
 	if (stat(buf, &st) < 0)
 		if (mkdir(buf, 0700) < 0)
 			error("Could not create directory '%.200s'.", buf);

=================================================
diff for tildexpand.c

--- /usr/src/openssh-2.9p2-3/tildexpand.c	Thu Feb  8 21:11:25 2001
+++ tildexpand-new.c	Wed Aug  8 18:37:45 2001
@@ -67,6 +67,6 @@ tilde_expand_filename(const char *filena
 	if (len > MAXPATHLEN)
 		fatal("Home directory too long (%d > %d", len-1,
MAXPATHLEN-1);
 	expanded = xmalloc(len);
-	snprintf(expanded, len, "%s/%s", pw->pw_dir, cp + 1);
+	snprintf(expanded, len, "%s%s%s", pw->pw_dir, strcmp(pw->pw_dir,
"/") ? "/" : "", cp + 1);
 	return expanded;
 }

==================================================

--
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/



More information about the Cygwin mailing list