{"id":790,"date":"2010-07-14T01:02:20","date_gmt":"2010-07-13T18:02:20","guid":{"rendered":"http:\/\/adityo.blog.binusian.org\/?p=790"},"modified":"2010-07-14T01:04:00","modified_gmt":"2010-07-13T18:04:00","slug":"symlink-workaround-on-proftpd","status":"publish","type":"post","link":"https:\/\/adityo.blog.binusian.org\/?p=790","title":{"rendered":"symlink workaround on proftpd"},"content":{"rendered":"<p>As we already know if you use sysmlink on your ftp directory the proftpd will not recognized it, soft link won&#8217;t work if your link target is not share out in proftpd. Besides, chroot in proftpd will mess up your soft link path if you use full path.<\/p>\n<p>here is some example<\/p>\n<p># ftp localhost<br \/>\nConnected to localhost (127.0.0.1).<br \/>\n220 FTP Server ready.<br \/>\nName (localhost:root): test<br \/>\n331 Password required for test<br \/>\nPassword:<br \/>\n230 User test logged in.<br \/>\nRemote system type is UNIX.<br \/>\nUsing binary mode to transfer files.<br \/>\nftp&gt; ls<br \/>\n227 Entering Passive Mode (127,0,0,1,195,10).<br \/>\n150 Opening ASCII mode data connection for file list<br \/>\ndrwx&#8212;&#8212;\u00a0\u00a0 3 test\u00a0\u00a0\u00a0\u00a0 test\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 4096 Jul 13 18:15 .<br \/>\ndrwx&#8212;&#8212;\u00a0\u00a0 3 test\u00a0\u00a0\u00a0\u00a0 test\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 4096 Jul 13 18:15 ..<br \/>\n-rw&#8212;&#8212;-\u00a0\u00a0 1 test\u00a0\u00a0\u00a0\u00a0 test\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 246 Jul\u00a0 5 03:11 .bash_history<br \/>\n-rw-r&#8211;r&#8211;\u00a0\u00a0 1 test\u00a0\u00a0\u00a0\u00a0 test\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 33 Jun 24 19:38 .bash_logout<br \/>\n-rw-r&#8211;r&#8211;\u00a0\u00a0 1 test\u00a0\u00a0\u00a0\u00a0 test\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 176 Jun 24 19:38 .bash_profile<br \/>\n-rw-r&#8211;r&#8211;\u00a0\u00a0 1 test\u00a0\u00a0\u00a0\u00a0 test\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 124 Jun 24 19:38 .bashrc<br \/>\nlrwxrwxrwx\u00a0\u00a0 1 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 13 Jul 13 18:15 adit -&gt; \/home\/adityo\/<br \/>\ndrwx&#8212;&#8212;\u00a0\u00a0 3 test\u00a0\u00a0\u00a0\u00a0 test\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 4096 Jun 24 19:50 mail<br \/>\n226 Transfer complete<br \/>\nftp&gt; cd adit<br \/>\n550 adit: No such file or directory<br \/>\nftp&gt; quit<br \/>\n221 Goodbye.<\/p>\n<h2>How Links Work<\/h2>\n<p>There are two types of links in  Unix: hard and symbolic.<\/p>\n<p><strong>A hard link<\/strong> is a file that is, for all  intents and purposes, the file to which it is linked. The difference between a hardlink and the linked file is one of placement in the filesystem. Editing the hardlink edits the linked file. One limitation of hard links is that linked files cannot reside on different filesystems. This means that if \/var and \/home are two different mount points in \/etc\/fstab (or \/etc\/vfstab), then a file in \/var\/tmp cannot be hardlinked with a file in \/home:<\/p>\n<pre>&gt; pwd\r\n\/var\/tmp\r\n  &gt; ln \/home\/tj\/tmp\/tmpfile tmplink\r\nln: cannot create hard link `tmplink' to `\/home\/tj\/tmp\/tmpfile': Invalid cross-device link<\/pre>\n<p><strong>A  symbolic link<\/strong> (also referred to as a &#8220;symlink&#8221;) is a file whose contents contain the name of the file to which the symbolic link points. For example:<\/p>\n<pre>lrwxrwxrwx   1 root     root           11 Mar  2  2000 rmt -&gt; \/sbin\/rmt<\/pre>\n<p>The  file rmt contains the nine characters \/sbin\/rmt. The reason symbolic links fail when chroot(2) is used to change the position of the root (\/)of the filesystem is that, once \/ is moved, the pointed-to file path changes. If, for example, if chroot(2) is used to change the filesystem root to \/ftp, then the symlink above would be actually be pointing to \/ftp\/sbin\/rmt. Chances that that link, if chroot(2) is used, now points to a path that does not exist. Symbolic links that point to nonexistent files are known as dangling symbolic links. Note that symbolic links to files underneath the new root, such as symlinks to a file in the same directory:<\/p>\n<pre>&gt; pwd\r\n\/var\/ftp\r\n  &gt; ls -l\r\n-rw-r--r--   1 root     root            0 Jan 16 11:50 tmpfile\r\n  lrwxrwxrwx   1 root     root            7 Jan 16 11:50 tmplink -&gt; tmpfile<\/pre>\n<p>will  be unaffected; only paths that point outside\/above the new root will be affected.<\/p>\n<h2>Filesystem Tricks<\/h2>\n<p>A typical scenario is one  where &#8220;DefaultRoot ~&#8221; is used to restrict users to their home directories, and where the administrator would like to have a shared upload directory, say \/var\/ftp\/incoming, in each user&#8217;s home directory. Symbolic links would normally be used to provide an arrangement like this. As mentioned above, though, when chroot(2) is used (which is what the DefaultRoot directive does), symlinks that point outside the new root (the user&#8217;s home directory in this case) will not work. To get around this apparent limitation, it is possible on modern operating systems to mount directories at several locations in the filesystem.<\/p>\n<p>To have an exact duplicate of  the \/var\/ftp\/incoming directory available in \/home\/bob\/incoming and \/home\/adityo\/incoming, use one of these commands:<\/p>\n<pre>    * Linux (as of the 2.4.0 kernel):\r\n\r\nmount --bind \/var\/ftp\/incoming \/home\/adityo\/incoming\r\n  mount -o bind \/home2\/test.com\/ \/home\/domains\/test.com\/\r\n\r\n    * BSD (as of 4.4BSD):\r\n\r\nmount_null \/var\/ftp\/incoming \/home\/adityo\/incoming\r\n\r\n    * Solaris:\r\n\r\nmount -F lofs \/var\/ftp\/incoming \/home\/adityo\/incoming\r\n\r\nset it on fstab\r\n<pre>\/var\/ftp\/incoming \/home\/bob\/incoming ext3 --bind 0 0\r\n\r\nreferer :\r\n- <a href=\"http:\/\/www.proftpd.org\/localsite\/Userguide\/linked\/chroot-symlinks.html\">http:\/\/www.proftpd.org\/localsite\/Userguide\/linked\/chroot-symlinks.html<\/a><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>As we already know if you use sysmlink on your ftp directory the proftpd will not recognized it, soft link won&#8217;t work if your link target is not share out in proftpd. Besides, chroot in proftpd will mess up your soft link path if you use full path. here is some example # ftp localhost [&hellip;]<\/p>\n","protected":false},"author":386,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6489,1],"tags":[6490],"class_list":["post-790","post","type-post","status-publish","format-standard","hentry","category-proftpd","category-uncategorized","tag-symlink-workaround-on-proftpd"],"_links":{"self":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/users\/386"}],"replies":[{"embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=790"}],"version-history":[{"count":5,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/790\/revisions"}],"predecessor-version":[{"id":794,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=\/wp\/v2\/posts\/790\/revisions\/794"}],"wp:attachment":[{"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adityo.blog.binusian.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}