aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Weingärtner <timo@tiwe.de>2013-11-02 11:38:40 +0100
committerTimo Weingärtner <timo@tiwe.de>2013-11-02 11:38:40 +0100
commitb05034bc176b38b3b3f31c7a2e1e53b4c16f61e2 (patch)
tree55cd463c578e078a3d582566c97d27ce79381045
parentd11b2c830b7c7676d9c275d038f6a9593af2a4b8 (diff)
downloadssh-agent-filter-b05034bc176b38b3b3f31c7a2e1e53b4c16f61e2.tar.gz
replace __gnu_cxx::stdio_filebuf with boost::iostreams
-rw-r--r--Makefile2
-rw-r--r--ssh-agent-filter.C15
2 files changed, 10 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index f07d0d1..d929b6c 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@
CXXFLAGS ?= -g -O2 -Wall -Wold-style-cast
CXXFLAGS += -std=c++11
-LDFLAGS += -lstdc++ -lboost_program_options -lboost_filesystem -lboost_system -lnettle
+LDFLAGS += -lstdc++ -lboost_program_options -lboost_filesystem -lboost_system -lboost_iostreams -lnettle
all: ssh-agent-filter.1 afssh.1 ssh-askpass-noinput.1
diff --git a/ssh-agent-filter.C b/ssh-agent-filter.C
index dd1b508..b4234c3 100644
--- a/ssh-agent-filter.C
+++ b/ssh-agent-filter.C
@@ -25,6 +25,10 @@ namespace po = boost::program_options;
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
+#include <boost/iostreams/stream_buffer.hpp>
+#include <boost/iostreams/device/file_descriptor.hpp>
+namespace io = boost::iostreams;
+
#include <string>
#include <vector>
#include <set>
@@ -32,7 +36,6 @@ namespace fs = boost::filesystem;
#include <sstream>
#include <stdexcept>
#include <thread>
-#include <ext/stdio_filebuf.h>
#include <csignal>
#include <cstdlib>
@@ -201,7 +204,7 @@ void parse_cmdline (int const argc, char const * const * const argv) {
}
void setup_filters () {
- __gnu_cxx::stdio_filebuf<char> agent_filebuf{make_upstream_agent_conn(), std::ios::in | std::ios::out};
+ io::stream_buffer<io::file_descriptor> agent_filebuf{make_upstream_agent_conn(), io::close_handle};
std::iostream agent{&agent_filebuf};
agent.exceptions(std::ios::badbit | std::ios::failbit);
@@ -325,7 +328,7 @@ rfc4251string handle_request (rfc4251string const & r) {
switch (request_code) {
case SSH2_AGENTC_REQUEST_IDENTITIES:
{
- __gnu_cxx::stdio_filebuf<char> agent_filebuf{make_upstream_agent_conn(), std::ios::in | std::ios::out};
+ io::stream_buffer<io::file_descriptor> agent_filebuf{make_upstream_agent_conn(), io::close_handle};
std::iostream agent{&agent_filebuf};
agent.exceptions(std::ios::badbit | std::ios::failbit);
rfc4251string agent_answer;
@@ -383,7 +386,7 @@ rfc4251string handle_request (rfc4251string const & r) {
}
if (allow) {
- __gnu_cxx::stdio_filebuf<char> agent_filebuf{make_upstream_agent_conn(), std::ios::in | std::ios::out};
+ io::stream_buffer<io::file_descriptor> agent_filebuf{make_upstream_agent_conn(), io::close_handle};
std::iostream agent{&agent_filebuf};
agent.exceptions(std::ios::badbit | std::ios::failbit);
rfc4251string agent_answer;
@@ -428,8 +431,8 @@ void handle_client (int const sock) {
// we could use only one streambuf and iostream but when
// switching from read to write an lseek call is made that
// fails with ESPIPE and causes an exception
- __gnu_cxx::stdio_filebuf<char> client_filebuf_in{sock, std::ios::in};
- __gnu_cxx::stdio_filebuf<char> client_filebuf_out{sock, std::ios::out};
+ io::stream_buffer<io::file_descriptor_source> client_filebuf_in{sock, io::close_handle};
+ io::stream_buffer<io::file_descriptor_sink> client_filebuf_out{sock, io::never_close_handle};
std::istream client_in{&client_filebuf_in};
std::ostream client_out{&client_filebuf_out};
client_out.exceptions(std::ios::badbit | std::ios::failbit);