Bug 2129 - sftp symlink incorrectly makes target path absolute
Summary: sftp symlink incorrectly makes target path absolute
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 6.2p1
Hardware: Other FreeBSD
: P5 normal
Assignee: Damien Miller
URL:
Keywords:
Depends on:
Blocks: V_6_5
  Show dependency treegraph
 
Reported: 2013-07-25 07:34 AEST by Xin Li
Modified: 2016-08-02 10:42 AEST (History)
1 user (show)

See Also:


Attachments
patch to address sftp chroot symlink issue (567 bytes, patch)
2013-07-25 07:34 AEST, Xin Li
no flags Details | Diff
improved patch (572 bytes, patch)
2013-08-08 14:44 AEST, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Xin Li 2013-07-25 07:34:39 AEST
Created attachment 2319 [details]
patch to address sftp chroot symlink issue

I'd like to report a possible regression in sftp(1).  In earlier
OpenSSH versions, when doing 'symlink' over sftp, the system will
create a symbolic link with relative path, and now it creates a
symbolic link with absolute path.  When doing chroot, this would make
an unusable symbolic link.

The behavior change was introduced in OpenBSD src/usr.bin/ssh/sftp.c,v
1.132 and based on my understanding of the commit log, this is not
intentional.

How to reproduce:

# sftp dtest
sftp> symlink ./l1 22
sftp> ^D

# ssh dtest "ls -l 22"
lrwxr-xr-x  1 delphij  delphij  23 Jun 21 17:28 22@ -> /home/delphij/l1

What's expected:

lrwxr-xr-x  1 delphij  delphij  4 Jun 21 17:25 22@ -> ./l1

The attached patch should fix this.
Comment 1 Damien Miller 2013-08-08 14:44:01 AEST
Created attachment 2327 [details]
improved patch

That patch is incorrect - it would break hardlinking. This one only skips the canonicalistion for symlinks.
Comment 2 Damien Miller 2013-08-08 14:52:30 AEST
patch applied - will be in openssh-6.4
Comment 3 Damien Miller 2016-08-02 10:42:00 AEST
Close all resolved bugs after 7.3p1 release