summaryrefslogtreecommitdiff
path: root/net-fs/curlftpfs
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /net-fs/curlftpfs
reinit the tree, so we can have metadata
Diffstat (limited to 'net-fs/curlftpfs')
-rw-r--r--net-fs/curlftpfs/Manifest10
-rw-r--r--net-fs/curlftpfs/curlftpfs-0.9.2-r3.ebuild42
-rw-r--r--net-fs/curlftpfs/files/curlftpfs-0.9.2-64bit_filesize.patch11
-rw-r--r--net-fs/curlftpfs/files/curlftpfs-0.9.2-darwin.patch17
-rw-r--r--net-fs/curlftpfs/files/curlftpfs-0.9.2-fix-escaping.patch420
-rw-r--r--net-fs/curlftpfs/files/curlftpfs-0.9.2-memleak-nocache.patch60
-rw-r--r--net-fs/curlftpfs/files/curlftpfs-0.9.2-memleak.patch24
-rw-r--r--net-fs/curlftpfs/metadata.xml11
8 files changed, 595 insertions, 0 deletions
diff --git a/net-fs/curlftpfs/Manifest b/net-fs/curlftpfs/Manifest
new file mode 100644
index 000000000000..c668602799ca
--- /dev/null
+++ b/net-fs/curlftpfs/Manifest
@@ -0,0 +1,10 @@
+AUX curlftpfs-0.9.2-64bit_filesize.patch 626 SHA256 95d880b3a43387f5ae6e5b3ed9309060bbdc3757fb7631af50edf386c7a6805c SHA512 3b23ee31c5008fffec3032c9ab440a584d672a3936f8fae943af31e5936964e8b5641f5778f56b5c656e9af26156d0a1f31e49ef8c4eb526ec8a83ff7076fcb7 WHIRLPOOL 26be2399dca4464cb1e8e130bd3cc2a765d1cc9cca5901e52c5f91a7ba56950c4350cae70161c01c12c96f9eeeb4922ca2a8836f4659db93b4d3e37c76438d10
+AUX curlftpfs-0.9.2-darwin.patch 517 SHA256 0f4abd06c2e17c1c66379443e06df0211dff25f1def8cfeeb84887bd791234bb SHA512 81e77c00c6b13b2f023ad1230fbd2c48bcf902454207e7b221d507086df1facffd603e1e1ab615b28a3d44d886941a509c0d1246279cceea197286073d6a322d WHIRLPOOL 14b5ed218a08c4cdb55dda4e27f034e2dbac593b5b375d7fe709d5f4424c937d075dbc8b0d03e2decb99bd0242fd66fb220bbc05e5c5b7dc111969c11201063c
+AUX curlftpfs-0.9.2-fix-escaping.patch 15750 SHA256 af8d67fc8f3d704ea39b93cefccbb6cd61910e92bbde00732a67c1ab5eeda9c3 SHA512 9373aabf3748de309196d27fe26367ac0b8625df69a095d5ea67a1033b1c5db19820f3a5e5040e4fbdb38e55b24c620f351a21906fc3ad3d681bb08c7cef1e72 WHIRLPOOL 839e5389c8b156a257414082fc0745be0c9eb74c3f0e3be92d07f9683a2ac73384a373ef05794b53fe74ff60a3efad95da66f47f9cb6c8bcf2222c096d15a1a7
+AUX curlftpfs-0.9.2-memleak-nocache.patch 1810 SHA256 d51e86585061c4dc15145d50d139331d9ae332643332467291e7e7313e3c4e48 SHA512 b53ed1acfea1aa539c0f69ab7dd961a635ded7299500337a7453fa2445e61590ec39a9010ac105d230880b09a90d388b8564295a185e5b44f3398903a6d1d5d4 WHIRLPOOL 8794b31cc4cb6bd75b2f3461d1c82127582d5fb1f78b6621739dfd11eb6e985bc7a0cc69e953a55bfa563411d3cf49305756e7bc479116ccbed3d7cdea1664f1
+AUX curlftpfs-0.9.2-memleak.patch 834 SHA256 b81de7d8eac46a390f1baf4071efde62c77148908562ea9a255acc9fd8d35f97 SHA512 dee0eac27bd09208f44d20d3c0627499da0664601abfb0cb5a3a979c988c71713ef00850f2b72e71c38a9dac09698e55cfbc6249bb1e2196a07a783b0fcd49bc WHIRLPOOL 17e3d417734ca610753c2435e736d3d833183b3346873039bc352d9cb36748f792b34e3c46f1609c1d0d94e30db7d702d17a7544a3edef4766fbfdaf918e9130
+DIST curlftpfs-0.9.2.tar.gz 365503 SHA256 4eb44739c7078ba0edde177bdd266c4cfb7c621075f47f64c85a06b12b3c6958 SHA512 df07c418d175f766c89525017fc56e79726061eee0c3a6607ded0e1bf24f64f1475ba0e546157b65892194e3c4414c120822bf8fb175437e68366f82de216067 WHIRLPOOL c14686eeadafe2f26f9c79fd44ab0d66403e79ec724d5eae28a8b3838ac676755edc1d86583c4de73486fc0dc5d49eabb2b57f7cb477edaccfab33b2aa9f0931
+EBUILD curlftpfs-0.9.2-r3.ebuild 995 SHA256 9e66b6ca6c6521b1c7e8aa5270f86d3ce847f030b7acb67527fd60d9960a7a3b SHA512 bfe01cc652c49b7c96aa18c634375317fc6b5e44fca0e3dc12b6608e7e9457e52e72fbdeaf49a06d1ff90cd4914dd58b13a72073a6e8c8a00da0f812b493a420 WHIRLPOOL 63c65b1166f02c920579eb9d1efde26621677662f477d74059ca617bc8539fe0ed60f1b3e84380a473d0c7b3656843d2ac11612691d96661903fa5f2850e69a5
+MISC ChangeLog 2782 SHA256 b4662960212ecec6344af4f25333ad1759f859cfee1d7d64fdee785dc6064a8c SHA512 2980732cf0d5f8a87901d6bb023e7a79dac385a4d1edf884602bc927a85370ea185132fc7e3632dcafd086f1c6b23ea7222b99da790d396d03d71f5381e75f9c WHIRLPOOL 92b594feb841446ea69d82879c345869074a42dbcc10cdbcf855f7336139de752c78c6dbc604ee4691edf63770907da531592c3f057a1d724ba03251f47d63b5
+MISC ChangeLog-2015 5171 SHA256 1282db4d1c382caa6e08946c972448598be93b70b2cf333aa3ae412a43c86609 SHA512 3af64b7e431266818c7125438f04363eeba90ce9224fbd0c984f19b1e23a99b67fb8e62ae801c4430db3608950e9e547ef3fef2794f318a07f9f5f6d3d154d3b WHIRLPOOL ae40b24eb2f0c824787be33ce43db6bd0088139b5e8d7896f5bc5a9c9f70f44a1922597444321fd1c8d8cf934900b363fb116185ede4526d547980ce6c2f4c86
+MISC metadata.xml 340 SHA256 4b7fce668410f349fc61e83f2efe5bea27488954175e7d6d11170b190c2b0232 SHA512 4e0ec7a3f4ed5e5e1bf875275776d6d610bca1b6fbb8200e208eff80150df4e98bea430a976deef94405fcbf825aa5ba992b40e30175a30ebccc30d53591eba3 WHIRLPOOL 8820d948587a5695837bb877258a1153e999347d55b3c1bfc20dea17c196a03553d92256bb1b15bd538bdc3e84abb3d6a92a146e8029ef860ec16d1f461a115d
diff --git a/net-fs/curlftpfs/curlftpfs-0.9.2-r3.ebuild b/net-fs/curlftpfs/curlftpfs-0.9.2-r3.ebuild
new file mode 100644
index 000000000000..b63fa315a634
--- /dev/null
+++ b/net-fs/curlftpfs/curlftpfs-0.9.2-r3.ebuild
@@ -0,0 +1,42 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+
+inherit eutils autotools
+
+DESCRIPTION="File system for accessing ftp hosts based on FUSE"
+HOMEPAGE="http://curlftpfs.sourceforge.net/"
+SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="amd64 arm x86 ~amd64-linux ~x86-linux ~x86-macos"
+IUSE=""
+RESTRICT="test" # bug 258460
+
+RDEPEND=">=net-misc/curl-7.17.0
+ >=sys-fs/fuse-2.2
+ >=dev-libs/glib-2.0"
+DEPEND="${RDEPEND}
+ virtual/pkgconfig"
+
+src_prepare() {
+ epatch "${FILESDIR}"/${P}-64bit_filesize.patch
+ epatch "${FILESDIR}"/${PN}-0.9.2-darwin.patch
+ epatch "${FILESDIR}"/${PN}-0.9.2-memleak.patch
+ epatch "${FILESDIR}"/${PN}-0.9.2-memleak-nocache.patch
+ epatch "${FILESDIR}"/${PN}-0.9.2-fix-escaping.patch
+
+ # automake-1.13.1 obsoletes AM_* bit #469818
+ sed -i -e 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/' configure.ac || die
+
+ epatch_user
+
+ eautoreconf
+}
+
+src_install() {
+ default
+ dodoc README
+}
diff --git a/net-fs/curlftpfs/files/curlftpfs-0.9.2-64bit_filesize.patch b/net-fs/curlftpfs/files/curlftpfs-0.9.2-64bit_filesize.patch
new file mode 100644
index 000000000000..38b6f33a2ba5
--- /dev/null
+++ b/net-fs/curlftpfs/files/curlftpfs-0.9.2-64bit_filesize.patch
@@ -0,0 +1,11 @@
+--- ftpfs.c.old 2009-11-28 14:28:05.000000000 +0300
++++ ftpfs.c 2009-11-28 14:28:19.000000000 +0300
+@@ -503,7 +503,7 @@
+
+ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_URL, fh->full_path);
+ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_UPLOAD, 1);
+- curl_easy_setopt_or_die(fh->write_conn, CURLOPT_INFILESIZE, -1);
++ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_INFILESIZE, (curl_off_t)-1);
+ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_READFUNCTION, write_data_bg);
+ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_READDATA, fh);
+ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_LOW_SPEED_LIMIT, 1);
diff --git a/net-fs/curlftpfs/files/curlftpfs-0.9.2-darwin.patch b/net-fs/curlftpfs/files/curlftpfs-0.9.2-darwin.patch
new file mode 100644
index 000000000000..fd0bd1f0cfe5
--- /dev/null
+++ b/net-fs/curlftpfs/files/curlftpfs-0.9.2-darwin.patch
@@ -0,0 +1,17 @@
+https://sourceforge.net/tracker/?func=detail&atid=816359&aid=2799820&group_id=160565
+
+diff -ur configure.ac configure.ac
+--- configure.ac 2008-04-23 15:37:42 +0400
++++ configure.ac 2009-06-02 09:46:05 +0400
+@@ -18,6 +18,11 @@
+ AC_MSG_ERROR(["We need libcurl with support for FTP protocol."])
+ fi
+
++case $host_os in
++ darwin*)
++ CFLAGS="$CFLAGS -D__off_t=off_t"
++ ;;
++esac
+ CFLAGS="$CFLAGS -Wall -W -Wno-sign-compare -D_REENTRANT $GLIB_CFLAGS $FUSE_CFLAGS $LIBCURL_CPPFLAGS"
+ LIBS="$GLIB_LIBS $FUSE_LIBS $LIBCURL"
+
diff --git a/net-fs/curlftpfs/files/curlftpfs-0.9.2-fix-escaping.patch b/net-fs/curlftpfs/files/curlftpfs-0.9.2-fix-escaping.patch
new file mode 100644
index 000000000000..df15bddd562f
--- /dev/null
+++ b/net-fs/curlftpfs/files/curlftpfs-0.9.2-fix-escaping.patch
@@ -0,0 +1,420 @@
+fix handling of special symbols in file operations.
+
+Path fixes at least following cases:
+ - attempt to enter directory named '#'
+ - attempt to open file named '#'
+ - attempt to dereference link named '#'
+ - attempt to chown file / dir named '#'
+
+The fix is basically following mechanical conversion:
+--- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, something);
++++ something_uri = path_to_uri(something);
++++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, something_uri);
+=== curl_easy_perform();
++++ free_uri(something_uri);
+
+What is not yet converted is ftp hostname.
+
+Reported-by: Jaakko Perttilä
+Gentoo-bug: http://bugs.gentoo.org/458110
+Based-on-patch: https://github.com/jomat/curlftpfs/commit/da20298fd0d0dcefc7d6d69ffecbc5544e783cfe
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+diff --git a/ftpfs.c b/ftpfs.c
+index ffd0b28..f21a267 100644
+--- a/ftpfs.c
++++ b/ftpfs.c
+@@ -257,6 +257,7 @@ static int ftpfs_getdir(const char* path, fuse_cache_dirh_t h,
+ int err = 0;
+ CURLcode curl_res;
+ char* dir_path = get_fulldir_path(path);
++ char* dir_path_uri = path_to_uri(dir_path);
+
+ DEBUG(1, "ftpfs_getdir: %s\n", dir_path);
+ struct buffer buf;
+@@ -264,7 +265,7 @@ static int ftpfs_getdir(const char* path, fuse_cache_dirh_t h,
+
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, dir_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, dir_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &buf);
+ curl_res = curl_easy_perform(ftpfs.connection);
+ pthread_mutex_unlock(&ftpfs.lock);
+@@ -278,6 +279,7 @@ static int ftpfs_getdir(const char* path, fuse_cache_dirh_t h,
+ NULL, NULL, NULL, 0, h, filler);
+ }
+
++ free_uri(dir_path_uri);
+ free(dir_path);
+ buf_free(&buf);
+ return op_return(err, "ftpfs_getdir");
+@@ -287,6 +289,7 @@ static int ftpfs_getattr(const char* path, struct stat* sbuf) {
+ int err;
+ CURLcode curl_res;
+ char* dir_path = get_dir_path(path);
++ char* dir_path_uri = path_to_uri(dir_path);
+
+ DEBUG(2, "ftpfs_getattr: %s dir_path=%s\n", path, dir_path);
+ struct buffer buf;
+@@ -294,7 +297,7 @@ static int ftpfs_getattr(const char* path, struct stat* sbuf) {
+
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, dir_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, dir_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &buf);
+ curl_res = curl_easy_perform(ftpfs.connection);
+ pthread_mutex_unlock(&ftpfs.lock);
+@@ -309,6 +312,7 @@ static int ftpfs_getattr(const char* path, struct stat* sbuf) {
+ err = parse_dir((char*)buf.p, dir_path + strlen(ftpfs.host) - 1,
+ name, sbuf, NULL, 0, NULL, NULL);
+
++ free_uri(dir_path_uri);
+ free(dir_path);
+ buf_free(&buf);
+ if (err) return op_return(-ENOENT, "ftpfs_getattr");
+@@ -329,6 +333,7 @@ static size_t ftpfs_read_chunk(const char* full_path, char* rbuf,
+ int running_handles = 0;
+ int err = 0;
+ struct ftpfs_file* fh = get_ftpfs_file(fi);
++ char* full_path_uri = path_to_uri(full_path); /* TODO: optimize bu pushing up conversion to context */
+
+ DEBUG(2, "ftpfs_read_chunk: %s %p %zu %lld %p %p\n",
+ full_path, rbuf, size, offset, fi, fh);
+@@ -355,7 +360,7 @@ static size_t ftpfs_read_chunk(const char* full_path, char* rbuf,
+
+ cancel_previous_multi();
+
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &fh->buf);
+ if (offset) {
+ char range[15];
+@@ -444,6 +449,7 @@ static size_t ftpfs_read_chunk(const char* full_path, char* rbuf,
+
+ pthread_mutex_unlock(&ftpfs.lock);
+
++ free_uri(full_path_uri);
+ if (err) return CURLFTPFS_BAD_READ;
+ return size;
+ }
+@@ -497,11 +503,12 @@ int write_thread_ctr = 0;
+ static void *ftpfs_write_thread(void *data) {
+ struct ftpfs_file *fh = data;
+ char range[15];
+-
++ char* full_path_uri = path_to_uri(fh->full_path); /* TODO: optimize bu pushing up conversion to context */
++
+ DEBUG(2, "enter streaming write thread #%d path=%s pos=%lld\n", ++write_thread_ctr, fh->full_path, fh->pos);
+
+
+- curl_easy_setopt_or_die(fh->write_conn, CURLOPT_URL, fh->full_path);
++ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_URL, full_path_uri);
+ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_UPLOAD, 1);
+ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_INFILESIZE, (curl_off_t)-1);
+ curl_easy_setopt_or_die(fh->write_conn, CURLOPT_READFUNCTION, write_data_bg);
+@@ -541,6 +548,8 @@ static void *ftpfs_write_thread(void *data) {
+
+ sem_post(&fh->data_written); /* ftpfs_write may return */
+
++ free_uri(full_path_uri);
++
+ return NULL;
+ }
+
+@@ -621,16 +630,19 @@ static void free_ftpfs_file(struct ftpfs_file *fh) {
+ }
+
+ static int buffer_file(struct ftpfs_file *fh) {
++ char* full_path_uri = path_to_uri(fh->full_path); /* TODO: optimize bu pushing up conversion to context */
+ // If we want to write to the file, we have to load it all at once,
+ // modify it in memory and then upload it as a whole as most FTP servers
+ // don't support resume for uploads.
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, fh->full_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &fh->buf);
+ CURLcode curl_res = curl_easy_perform(ftpfs.connection);
+ pthread_mutex_unlock(&ftpfs.lock);
+
++ free_uri(full_path_uri);
++
+ if (curl_res != 0) {
+ return -EACCES;
+ }
+@@ -643,10 +655,11 @@ static int create_empty_file(const char * path)
+ int err = 0;
+
+ char *full_path = get_full_path(path);
++ char* full_path_uri = path_to_uri(full_path);
+
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_INFILESIZE, 0);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_UPLOAD, 1);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_READDATA, NULL);
+@@ -656,7 +669,9 @@ static int create_empty_file(const char * path)
+
+ if (curl_res != 0) {
+ err = -EPERM;
+- }
++ }
++
++ free_uri(full_path_uri);
+ free(full_path);
+ return err;
+ }
+@@ -875,6 +890,7 @@ static int ftpfs_chmod(const char* path, mode_t mode) {
+
+ struct curl_slist* header = NULL;
+ char* full_path = get_dir_path(path);
++ char* full_path_uri = path_to_uri(full_path);
+ char* filename = get_file_name(path);
+ char* cmd = g_strdup_printf("SITE CHMOD %.3o %s", mode_c, filename);
+ struct buffer buf;
+@@ -885,7 +901,7 @@ static int ftpfs_chmod(const char* path, mode_t mode) {
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_POSTQUOTE, header);
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &buf);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_NOBODY, ftpfs.safe_nobody);
+ CURLcode curl_res = curl_easy_perform(ftpfs.connection);
+@@ -896,12 +912,13 @@ static int ftpfs_chmod(const char* path, mode_t mode) {
+ if (curl_res != 0) {
+ err = -EPERM;
+ }
+-
++
+ buf_free(&buf);
+ curl_slist_free_all(header);
++ free_uri(full_path_uri);
+ free(full_path);
+ free(filename);
+- free(cmd);
++ free(cmd);
+ return op_return(err, "ftpfs_chmod");
+ }
+
+@@ -912,6 +929,7 @@ static int ftpfs_chown(const char* path, uid_t uid, gid_t gid) {
+
+ struct curl_slist* header = NULL;
+ char* full_path = get_dir_path(path);
++ char* full_path_uri = path_to_uri(full_path);
+ char* filename = get_file_name(path);
+ char* cmd = g_strdup_printf("SITE CHUID %i %s", uid, filename);
+ char* cmd2 = g_strdup_printf("SITE CHGID %i %s", gid, filename);
+@@ -924,7 +942,7 @@ static int ftpfs_chown(const char* path, uid_t uid, gid_t gid) {
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_POSTQUOTE, header);
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &buf);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_NOBODY, ftpfs.safe_nobody);
+ CURLcode curl_res = curl_easy_perform(ftpfs.connection);
+@@ -938,6 +956,7 @@ static int ftpfs_chown(const char* path, uid_t uid, gid_t gid) {
+
+ buf_free(&buf);
+ curl_slist_free_all(header);
++ free_uri(full_path_uri);
+ free(full_path);
+ free(filename);
+ free(cmd);
+@@ -1001,6 +1020,7 @@ static int ftpfs_rmdir(const char* path) {
+ int err = 0;
+ struct curl_slist* header = NULL;
+ char* full_path = get_dir_path(path);
++ char* full_path_uri = path_to_uri(full_path);
+ char* filename = get_file_name(path);
+ char* cmd = g_strdup_printf("RMD %s", filename);
+ struct buffer buf;
+@@ -1014,7 +1034,7 @@ static int ftpfs_rmdir(const char* path) {
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_POSTQUOTE, header);
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &buf);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_NOBODY, ftpfs.safe_nobody);
+ CURLcode curl_res = curl_easy_perform(ftpfs.connection);
+@@ -1028,6 +1048,7 @@ static int ftpfs_rmdir(const char* path) {
+
+ buf_free(&buf);
+ curl_slist_free_all(header);
++ free_uri(full_path_uri);
+ free(full_path);
+ free(filename);
+ free(cmd);
+@@ -1038,6 +1059,7 @@ static int ftpfs_mkdir(const char* path, mode_t mode) {
+ int err = 0;
+ struct curl_slist* header = NULL;
+ char* full_path = get_dir_path(path);
++ char* full_path_uri = path_to_uri(full_path);
+ char* filename = get_file_name(path);
+ char* cmd = g_strdup_printf("MKD %s", filename);
+ struct buffer buf;
+@@ -1048,7 +1070,7 @@ static int ftpfs_mkdir(const char* path, mode_t mode) {
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_POSTQUOTE, header);
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &buf);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_NOBODY, ftpfs.safe_nobody);
+ CURLcode curl_res = curl_easy_perform(ftpfs.connection);
+@@ -1062,6 +1084,7 @@ static int ftpfs_mkdir(const char* path, mode_t mode) {
+
+ buf_free(&buf);
+ curl_slist_free_all(header);
++ free_uri(full_path_uri);
+ free(full_path);
+ free(filename);
+ free(cmd);
+@@ -1076,6 +1099,7 @@ static int ftpfs_unlink(const char* path) {
+ int err = 0;
+ struct curl_slist* header = NULL;
+ char* full_path = get_dir_path(path);
++ char* full_path_uri = path_to_uri(full_path);
+ char* filename = get_file_name(path);
+ char* cmd = g_strdup_printf("DELE %s", filename);
+ struct buffer buf;
+@@ -1086,7 +1110,7 @@ static int ftpfs_unlink(const char* path) {
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_POSTQUOTE, header);
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, full_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &buf);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_NOBODY, ftpfs.safe_nobody);
+ CURLcode curl_res = curl_easy_perform(ftpfs.connection);
+@@ -1100,6 +1124,7 @@ static int ftpfs_unlink(const char* path) {
+
+ buf_free(&buf);
+ curl_slist_free_all(header);
++ free_uri(full_path_uri);
+ free(full_path);
+ free(filename);
+ free(cmd);
+@@ -1301,6 +1326,7 @@ static int ftpfs_readlink(const char *path, char *linkbuf, size_t size) {
+ int err;
+ CURLcode curl_res;
+ char* dir_path = get_dir_path(path);
++ char* dir_path_uri = path_to_uri(dir_path);
+
+ DEBUG(2, "dir_path: %s %s\n", path, dir_path);
+ struct buffer buf;
+@@ -1308,7 +1334,7 @@ static int ftpfs_readlink(const char *path, char *linkbuf, size_t size) {
+
+ pthread_mutex_lock(&ftpfs.lock);
+ cancel_previous_multi();
+- curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, dir_path);
++ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, dir_path_uri);
+ curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &buf);
+ curl_res = curl_easy_perform(ftpfs.connection);
+ pthread_mutex_unlock(&ftpfs.lock);
+@@ -1323,6 +1349,7 @@ static int ftpfs_readlink(const char *path, char *linkbuf, size_t size) {
+ err = parse_dir((char*)buf.p, dir_path + strlen(ftpfs.host) - 1,
+ name, NULL, linkbuf, size, NULL, NULL);
+
++ free_uri(dir_path_uri);
+ free(dir_path);
+ buf_free(&buf);
+ if (err) return op_return(-ENOENT, "ftpfs_readlink");
+diff --git a/path_utils.c b/path_utils.c
+index db3d7e4..214b5e6 100644
+--- a/path_utils.c
++++ b/path_utils.c
+@@ -92,3 +92,72 @@ char* get_dir_path(const char* path) {
+
+ return ret;
+ }
++
++/*
++ * the chars not needed to be escaped:
++ * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
++ */
++static inline int is_unreserved_rfc3986(char c)
++{
++ int is_locase_alpha = (c >= 'a' && c <= 'z');
++ int is_upcase_alpha = (c >= 'a' && c <= 'z');
++ int is_digit = (c >= '0' && c <= '9');
++ int is_special = c == '-'
++ || c == '.'
++ || c == '_'
++ || c == '~';
++ int is_unreserved = is_locase_alpha
++ || is_upcase_alpha
++ || is_digit
++ || is_special;
++
++ return is_unreserved;
++}
++
++static inline int is_unreserved(char c)
++{
++ return is_unreserved_rfc3986(c) || c == '/';
++}
++
++char* path_to_uri(const char* path)
++{
++ static const char hex[] = "0123456789ABCDEF";
++ size_t path_len = strlen(path);
++ size_t host_len = strlen(ftpfs.host);
++ /* at worst: c -> %XX */
++ char * encoded_path = malloc (3 * path_len + 1);
++ const char * s = path;
++ char * d = encoded_path;
++
++ /*
++ * 'path' is always prefixed with 'ftpfs.host'
++ */
++ memcpy (d, ftpfs.host, host_len);
++ s += host_len;
++ d += host_len;
++
++ for (; *s; ++s)
++ {
++ char c = *s;
++ if (is_unreserved (c))
++ {
++ *d++ = c;
++ }
++ else
++ {
++ unsigned int hi = ((unsigned)c >> 4) & 0xF;
++ unsigned int lo = ((unsigned)c >> 0) & 0xF;
++ *d++ = '%';
++ *d++ = hex[hi];
++ *d++ = hex[lo];
++ }
++ }
++ *d = '\0';
++
++ return encoded_path;
++}
++
++void free_uri(char* path)
++{
++ free(path);
++}
+diff --git a/path_utils.h b/path_utils.h
+index 084ae4d..e3e9bca 100644
+--- a/path_utils.h
++++ b/path_utils.h
+@@ -6,4 +6,11 @@ char* get_full_path(const char* path);
+ char* get_fulldir_path(const char* path);
+ char* get_dir_path(const char* path);
+
++/*
++ * Transforms UNIX path to RFC3986 encoded path
++ * (CURLOPT_URL accepts only such paths)
++ */
++char* path_to_uri(const char* path);
++void free_uri(char* path);
++
+ #endif /* __CURLFTPFS_PATH_UTILS_H__ */
diff --git a/net-fs/curlftpfs/files/curlftpfs-0.9.2-memleak-nocache.patch b/net-fs/curlftpfs/files/curlftpfs-0.9.2-memleak-nocache.patch
new file mode 100644
index 000000000000..344233c2b83e
--- /dev/null
+++ b/net-fs/curlftpfs/files/curlftpfs-0.9.2-memleak-nocache.patch
@@ -0,0 +1,60 @@
+Picked-from: http://pkgs.fedoraproject.org/cgit/curlftpfs.git/tree/curlftpfs-0.9.2-memleak-cached%23591299.patch?h=f18
+
+@@ -, +, @@
+---
+ cache.c | 2 1 + 1 - 0 !
+ ftpfs-ls.c | 19 15 + 4 - 0 !
+ 2 files changed, 16 insertions(+), 5 deletions(-)
+--- b/cache.c
++++ b/cache.c
+@@ -25,7 +25,7 @@ struct cache {
+ time_t last_cleaned;
+ };
+
+-static struct cache cache;
++struct cache cache;
+
+ struct node {
+ struct stat stat;
+--- b/ftpfs-ls.c
++++ b/ftpfs-ls.c
+@@ -25,6 +25,13 @@
+ #include "charset_utils.h"
+ #include "ftpfs-ls.h"
+
++struct cache {
++ int on;
++ char incomplete[];
++};
++
++extern struct cache cache;
++
+ static int parse_dir_unix(const char *line,
+ struct stat *sbuf,
+ char *file,
+@@ -243,8 +250,10 @@ int parse_dir(const char* list, const ch
+ reallink = g_strdup(link);
+ }
+ int linksize = strlen(reallink);
+- cache_add_link(full_path, reallink, linksize+1);
+- DEBUG(1, "cache_add_link: %s %s\n", full_path, reallink);
++ if (cache.on) {
++ cache_add_link(full_path, reallink, linksize+1);
++ DEBUG(1, "cache_add_link: %s %s\n", full_path, reallink);
++ }
+ if (linkbuf && linklen) {
+ if (linksize > linklen) linksize = linklen - 1;
+ strncpy(linkbuf, reallink, linksize);
+@@ -257,8 +266,10 @@ int parse_dir(const char* list, const ch
+ DEBUG(1, "filler: %s\n", file);
+ filler(h, file, &stat_buf);
+ } else {
+- DEBUG(1, "cache_add_attr: %s\n", full_path);
+- cache_add_attr(full_path, &stat_buf);
++ if (cache.on) {
++ DEBUG(1, "cache_add_attr: %s\n", full_path);
++ cache_add_attr(full_path, &stat_buf);
++ }
+ }
+
+ DEBUG(2, "comparing %s %s\n", name, file);
diff --git a/net-fs/curlftpfs/files/curlftpfs-0.9.2-memleak.patch b/net-fs/curlftpfs/files/curlftpfs-0.9.2-memleak.patch
new file mode 100644
index 000000000000..27163ac229e0
--- /dev/null
+++ b/net-fs/curlftpfs/files/curlftpfs-0.9.2-memleak.patch
@@ -0,0 +1,24 @@
+Picked-from: https://github.com/jomat/curlftpfs/commit/b8ce5599a17a1f9e00c93cff3a81fe88f51e8bd3
+Upstream-bug: https://sourceforge.net/tracker/?func=detail&aid=2924678&group_id=160565&atid=816357
+
+commit b8ce5599a17a1f9e00c93cff3a81fe88f51e8bd3
+Author: jomat <jomat@copete.de>
+Date: Sun Oct 16 18:41:37 2011 +0000
+
+ added patch agains memory leak
+
+ see also https://sourceforge.net/tracker/?func=detail&aid=2924678&group_id=160565&atid=816357
+
+diff --git a/ftpfs.c b/ftpfs.c
+index 0346354..96146f7 100644
+--- a/ftpfs.c
++++ b/ftpfs.c
+@@ -615,6 +615,8 @@ static void free_ftpfs_file(struct ftpfs_file *fh) {
+ sem_destroy(&fh->data_need);
+ sem_destroy(&fh->data_written);
+ sem_destroy(&fh->ready);
++ if (fh->buf.size) { buf_free(&fh->buf); }
++ if (fh->stream_buf.size) { buf_free(&fh->stream_buf); }
+ free(fh);
+ }
+
diff --git a/net-fs/curlftpfs/metadata.xml b/net-fs/curlftpfs/metadata.xml
new file mode 100644
index 000000000000..d18ff5806215
--- /dev/null
+++ b/net-fs/curlftpfs/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>slyfox@gentoo.org</email>
+ <name>Sergei Trofimovich</name>
+ </maintainer>
+ <upstream>
+ <remote-id type="sourceforge">curlftpfs</remote-id>
+ </upstream>
+</pkgmetadata>