From b05034bc176b38b3b3f31c7a2e1e53b4c16f61e2 Mon Sep 17 00:00:00 2001 From: Timo Weingärtner Date: Sat, 2 Nov 2013 11:38:40 +0100 Subject: replace __gnu_cxx::stdio_filebuf with boost::iostreams --- Makefile | 2 +- ssh-agent-filter.C | 15 +++++++++------ 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 namespace fs = boost::filesystem; +#include +#include +namespace io = boost::iostreams; + #include #include #include @@ -32,7 +36,6 @@ namespace fs = boost::filesystem; #include #include #include -#include #include #include @@ -201,7 +204,7 @@ void parse_cmdline (int const argc, char const * const * const argv) { } void setup_filters () { - __gnu_cxx::stdio_filebuf agent_filebuf{make_upstream_agent_conn(), std::ios::in | std::ios::out}; + io::stream_buffer 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 agent_filebuf{make_upstream_agent_conn(), std::ios::in | std::ios::out}; + io::stream_buffer 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 agent_filebuf{make_upstream_agent_conn(), std::ios::in | std::ios::out}; + io::stream_buffer 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 client_filebuf_in{sock, std::ios::in}; - __gnu_cxx::stdio_filebuf client_filebuf_out{sock, std::ios::out}; + io::stream_buffer client_filebuf_in{sock, io::close_handle}; + io::stream_buffer 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); -- cgit v1.2.3