diff --git a/src/command_download.cc b/src/command_download.cc index c6d436da..94b06214 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -391,6 +391,7 @@ initialize_command_download() { ADD_CD_VALUE("is_hash_checked", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_hash_checked))); ADD_CD_VALUE("is_hash_checking", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_hash_checking))); ADD_CD_VALUE("is_multi_file", rak::on(std::mem_fun(&core::Download::file_list), std::mem_fun(&torrent::FileList::is_multi_file))); + ADD_CD_VALUE("is_private", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_private))); ADD_CD_VARIABLE_STRING_PUBLIC("custom1", "rtorrent", "custom1"); ADD_CD_VARIABLE_STRING_PUBLIC("custom2", "rtorrent", "custom2"); @@ -449,7 +450,6 @@ initialize_command_download() { ADD_CD_VALUE_UNI("peers_accounted", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::peers_accounted))); ADD_CD_VALUE_MEM_BI("peer_exchange", &core::Download::download, &torrent::Download::set_pex_enabled, &torrent::Download::is_pex_enabled); - ADD_CD_VALUE_UNI("private", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_private))); ADD_CD_VALUE_MEM_UNI("up_rate", &torrent::Download::mutable_up_rate, &torrent::Rate::rate); ADD_CD_VALUE_MEM_UNI("up_total", &torrent::Download::mutable_up_rate, &torrent::Rate::total); diff --git a/src/command_events.cc b/src/command_events.cc index 24236ec0..3ab9c909 100644 --- a/src/command_events.cc +++ b/src/command_events.cc @@ -124,7 +124,7 @@ apply_start_tied() { const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr)); if (!tiedToFile.empty() && fs.update(rak::path_expand(tiedToFile))) - control->core()->download_list()->start_normal(*itr); + control->core()->download_list()->start_try(*itr); } return torrent::Object(); @@ -140,7 +140,7 @@ apply_stop_untied() { const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr)); if (!tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile))) - control->core()->download_list()->stop_normal(*itr); + control->core()->download_list()->stop_try(*itr); } return torrent::Object(); @@ -152,7 +152,7 @@ apply_close_untied() { rak::file_stat fs; const std::string& tiedToFile = rpc::call_command_string("d.get_tied_to_file", rpc::make_target(*itr)); - if (!tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile))) + if (rpc::call_command_value("d.get_ignore_commands", rpc::make_target(*itr)) == 0 && !tiedToFile.empty() && !fs.update(rak::path_expand(tiedToFile))) control->core()->download_list()->close(*itr); } diff --git a/src/command_network.cc b/src/command_network.cc index c129ccc3..5bf5fc4d 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -204,12 +204,16 @@ apply_scgi(const std::string& arg, int type) { sa.sa_inet()->clear(); saPtr = &sa; + control->core()->push_log("The SCGI socket has not been bound to any address and likely poses a security risk."); + } else if (std::sscanf(arg.c_str(), "%1023[^:]:%i%c", address, &port, &dummy) == 2) { if ((err = rak::address_info::get_address_info(address, PF_INET, SOCK_STREAM, &ai)) != 0) throw torrent::input_error("Could not bind address: " + std::string(rak::address_info::strerror(err)) + "."); saPtr = ai->address(); + control->core()->push_log("The SCGI socket is bound to a specific network device yet may still pose a security risk, consider using 'scgi_local'."); + } else { throw torrent::input_error("Could not parse address."); } diff --git a/src/rpc/parse_commands.cc b/src/rpc/parse_commands.cc index 2d6de082..cc42d412 100644 --- a/src/rpc/parse_commands.cc +++ b/src/rpc/parse_commands.cc @@ -162,17 +162,25 @@ parse_command_file(const std::string& path) { try { unsigned int getCount = 0; - while (file.getline(buffer + getCount, 4096 - getCount).good()) { + while (file.good() + && !file.getline(buffer + getCount, 4096 - getCount).fail()) { + if (file.gcount() == 0) throw torrent::internal_error("parse_command_file(...) file.gcount() == 0."); - - int escaped = parse_count_escaped(buffer + getCount, buffer + getCount + file.gcount() - 1); + int lineLength = file.gcount() - 1; + // In case we are at the end of the file and the last character is + // not a line feed, we'll just increase the read character count so + // that the last would also be included in option line. + if (file.eof() && file.get() != '\n') + lineLength++; + + int escaped = parse_count_escaped(buffer + getCount, buffer + getCount + lineLength); lineNumber++; - getCount += file.gcount() - 1; + getCount += lineLength; if (getCount == 4096 - 1) - throw torrent::input_error("Exceeded max line lenght."); + throw torrent::input_error("Exceeded max line length."); if (escaped & 0x1) { // Remove the escape characters and continue reading.