From 9b0a78321f59c44f875589d09a486a0a61edc79a Mon Sep 17 00:00:00 2001 From: Nathan Owens Date: Mon, 31 Dec 2018 23:21:18 -0600 Subject: [PATCH] rtorrent: fix xmlrpc bugs --- .../patches/fix-xml-rpc-overflow.patch | 76 +++++++++++++++++++ .../patches/properly-close-xmlrpc-log.patch | 34 +++++++++ srcpkgs/rtorrent/template | 2 +- 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/rtorrent/patches/fix-xml-rpc-overflow.patch create mode 100644 srcpkgs/rtorrent/patches/properly-close-xmlrpc-log.patch diff --git a/srcpkgs/rtorrent/patches/fix-xml-rpc-overflow.patch b/srcpkgs/rtorrent/patches/fix-xml-rpc-overflow.patch new file mode 100644 index 00000000000..a1136295e8d --- /dev/null +++ b/srcpkgs/rtorrent/patches/fix-xml-rpc-overflow.patch @@ -0,0 +1,76 @@ +From 1f418366d4e56d96420459ea868a3c23f7c297e8 Mon Sep 17 00:00:00 2001 +From: chros +Date: Mon, 1 Oct 2018 23:27:58 +0100 +Subject: [PATCH] Fix 'list' type method (See #25) + +--- + src/command_dynamic.cc | 28 +++++++++++++++++++++++----- + 1 file changed, 23 insertions(+), 5 deletions(-) + +diff --git src/command_dynamic.cc src/command_dynamic.cc +index 91eb3c46..a8d0ff02 100644 +--- src/command_dynamic.cc ++++ src/command_dynamic.cc +@@ -139,6 +139,8 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) { + case rpc::object_storage::flag_function_type: + system_method_generate_command2(&value, itrArgs, args.end()); + break; ++ case rpc::object_storage::flag_list_type: ++ break; + case rpc::object_storage::flag_multi_type: + break; + default: +@@ -152,7 +154,17 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) { + if (!(flags & rpc::object_storage::flag_private)) + cmd_flags |= rpc::CommandMap::flag_public_xmlrpc; + +- control->object_storage()->insert_str(rawKey, value, flags); ++ if ((flags & rpc::object_storage::mask_type) == rpc::object_storage::flag_list_type) { ++ torrent::Object valueList = torrent::Object::create_list(); ++ torrent::Object::list_type& valueListType = valueList.as_list(); ++ ++ if ((itrArgs)->is_list()) ++ valueListType = (itrArgs)->as_list(); ++ ++ control->object_storage()->insert_str(rawKey, valueList, flags); ++ } else { ++ control->object_storage()->insert_str(rawKey, value, flags); ++ } + + if ((flags & rpc::object_storage::mask_type) == rpc::object_storage::flag_function_type || + (flags & rpc::object_storage::mask_type) == rpc::object_storage::flag_multi_type) { +@@ -208,6 +220,13 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) { + &rpc::command_base_call_string, + cmd_flags, NULL, NULL); + break; ++ case rpc::object_storage::flag_list_type: ++ rpc::commands.insert_slot >::type> ++ (create_new_key<5>(rawKey, ".set"), ++ std::bind(&rpc::object_storage::set_str_list, control->object_storage(), rawKey, std::placeholders::_2), ++ &rpc::command_base_call_list, ++ cmd_flags, NULL, NULL); ++ break; + case rpc::object_storage::flag_function_type: + case rpc::object_storage::flag_multi_type: + default: break; +@@ -310,10 +329,6 @@ system_method_insert(const torrent::Object::list_type& args) { + new_flags = rpc::object_storage::flag_string_type; + else if (options.find("list") != std::string::npos) + new_flags = rpc::object_storage::flag_list_type; +- else if (options.find("simple") != std::string::npos) +- new_flags = rpc::object_storage::flag_function_type; +- else +- throw torrent::input_error("No support for 'list' variable type."); + + if (options.find("static") != std::string::npos) + new_flags |= rpc::object_storage::flag_static; +@@ -447,6 +462,9 @@ initialize_command_dynamic() { + + CMD2_ANY_LIST ("method.insert", std::bind(&system_method_insert, std::placeholders::_2)); + CMD2_ANY_LIST ("method.insert.value", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_value_type)); ++ CMD2_ANY_LIST ("method.insert.bool", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_bool_type)); ++ CMD2_ANY_LIST ("method.insert.string", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_string_type)); ++ CMD2_ANY_LIST ("method.insert.list", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_list_type)); + + CMD2_METHOD_INSERT("method.insert.simple", rpc::object_storage::flag_function_type); + CMD2_METHOD_INSERT("method.insert.c_simple", rpc::object_storage::flag_constant | rpc::object_storage::flag_function_type); diff --git a/srcpkgs/rtorrent/patches/properly-close-xmlrpc-log.patch b/srcpkgs/rtorrent/patches/properly-close-xmlrpc-log.patch new file mode 100644 index 00000000000..67a7bd46225 --- /dev/null +++ b/srcpkgs/rtorrent/patches/properly-close-xmlrpc-log.patch @@ -0,0 +1,34 @@ +From 3d88ac2cc89ad203eb9ea75e4933d36bbda4d04d Mon Sep 17 00:00:00 2001 +From: pyroscope +Date: Fri, 15 Jun 2018 19:37:57 +0200 +Subject: [PATCH] fix: properly close the XMLRPC log, resetting the handle + after close + +--- + src/thread_worker.cc | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git src/thread_worker.cc src/thread_worker.cc +index d6fa2f61..939d7026 100644 +--- src/thread_worker.cc ++++ src/thread_worker.cc +@@ -113,14 +113,15 @@ ThreadWorker::change_xmlrpc_log() { + if (scgi() == NULL) + return; + +- if (scgi()->log_fd() != -1) ++ if (scgi()->log_fd() != -1) { + ::close(scgi()->log_fd()); +- +- if (m_xmlrpcLog.empty()) { ++ scgi()->set_log_fd(-1); + control->core()->push_log("Closed XMLRPC log."); +- return; + } + ++ if (m_xmlrpcLog.empty()) ++ return; ++ + scgi()->set_log_fd(open(rak::path_expand(m_xmlrpcLog).c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644)); + + if (scgi()->log_fd() == -1) { diff --git a/srcpkgs/rtorrent/template b/srcpkgs/rtorrent/template index 005914d6cdb..6e01ad2d764 100644 --- a/srcpkgs/rtorrent/template +++ b/srcpkgs/rtorrent/template @@ -1,7 +1,7 @@ # Template file for 'rtorrent' pkgname=rtorrent version=0.9.7 -revision=3 +revision=4 build_style=gnu-configure configure_args="--with-xmlrpc-c" hostmakedepends="automake libtool pkg-config"