~sircmpwn/himitsu-ssh

b7ee0239dc86666c459000bdf8c615c0e889c668 — Armin Preiml 1 year, 1 month ago 442dee9
update to latest stdlib
3 files changed, 19 insertions(+), 17 deletions(-)

M cmd/hissh-agent/main.ha
M cmd/hissh-export/main.ha
M cmd/hissh-import/main.ha
M cmd/hissh-agent/main.ha => cmd/hissh-agent/main.ha +13 -12
@@ 14,6 14,7 @@ use log;
use net::ssh::agent;
use net::unix;
use net;
use memio;
use os;
use path;
use strings;


@@ 59,7 60,7 @@ export fn main() void = {
	log::println("Terminated.");
};

fn handle_signal(sig: signal::sig, info: *signal::siginfo, ucontext: *void) void = {
fn handle_signal(sig: signal::sig, info: *signal::siginfo, ucontext: *opaque) void = {
	running = false;
};



@@ 133,7 134,7 @@ fn handle_req_ident(agent: *agent::agent) (void | agent::error | net::error) = {
			continue;
		};

		let source = bufio::fixed(buf, io::mode::READ);
		let source = memio::fixed(buf);
		const q = match (query::parse(&source)) {
		case let err: io::error =>
			return err;


@@ 184,7 185,7 @@ fn handle_req_ident(agent: *agent::agent) (void | agent::error | net::error) = {
			yield "";
		};

		let pkeybuf = bufio::fixed(pkey, io::mode::READ);
		let pkeybuf = memio::fixed(pkey);
		match (ssh::key_decoderawpub(key, &pkeybuf)) {
		case ssh::error =>
			log::printfln("Invalid SSH key: {}",


@@ 194,11 195,11 @@ fn handle_req_ident(agent: *agent::agent) (void | agent::error | net::error) = {
			yield;
		};

		const sink = bufio::dynamic(io::mode::WRITE);
		const sink = memio::dynamic();
		ssh::encode_pubkey(&sink, key)!;

		append(idents, agent::identity {
			pubkey = bufio::buffer(&sink),
			pubkey = memio::buffer(&sink),
			comment = strings::dup(comment),
		});
	};


@@ 216,7 217,7 @@ fn handle_sign_request(
	agent: *agent::agent,
	msg: *agent::sign_request,
) (void | agent::error | net::error) = {
	const source = bufio::fixed(msg.key, io::mode::READ);
	const source = memio::fixed(msg.key);
	const key = match (ssh::decodepublic(&source)) {
	case let key: *ssh::key =>
		yield key;


@@ 227,7 228,7 @@ fn handle_sign_request(
	};
	defer ssh::key_free(key);

	let req = bufio::dynamic(io::mode::WRITE);
	let req = memio::dynamic();
	defer io::close(&req)!;
	fmt::fprint(&req, "query -d proto=ssh pkey=")?;
	let b64en = base64::newencoder(&base64::std_encoding, &req);


@@ 237,7 238,7 @@ fn handle_sign_request(

	const himitsu = himitsu_connect()?;
	defer io::close(himitsu)!;
	io::writeall(himitsu, bufio::buffer(&req))?;
	io::writeall(himitsu, memio::buffer(&req))?;

	let comment = "";
	defer free(comment);


@@ 265,7 266,7 @@ fn handle_sign_request(
			continue;
		};

		let source = bufio::fixed(buf, io::mode::READ);
		let source = memio::fixed(buf);
		const q = match (query::parse(&source)) {
		case let err: io::error =>
			return err;


@@ 304,7 305,7 @@ fn handle_sign_request(
			yield "";
		};

		let keybuf = bufio::fixed(skey, io::mode::READ);
		let keybuf = memio::fixed(skey);
		match (ssh::key_decoderawpriv(key, &keybuf)) {
		case ssh::error =>
			log::printfln("Invalid SSH key: {}",


@@ 323,12 324,12 @@ fn handle_sign_request(
		return;
	};

	let buf = bufio::dynamic(io::mode::WRITE);
	let buf = memio::dynamic();
	defer io::close(&buf)!;
	ssh::sign(&buf, key, msg.data)!;

	const answer: agent::message = agent::sign_response {
		signature = bufio::buffer(&buf),
		signature = memio::buffer(&buf),
	};
	agent::writemsg(agent, &answer)?;
	log::printfln("Signed challenge with key {}", comment);

M cmd/hissh-export/main.ha => cmd/hissh-export/main.ha +3 -3
@@ 1,4 1,3 @@
use bufio;
use encoding::base64;
use fmt;
use format::ssh;


@@ 7,6 6,7 @@ use himitsu::client;
use himitsu::query;
use io;
use net;
use memio;
use os;
use strings;



@@ 61,7 61,7 @@ export fn main() void = {
			yield key;
		};

		const keybuf = bufio::fixed(strings::toutf8(key), io::mode::READ);
		const keybuf = memio::fixed(strings::toutf8(key));
		const key = query::parse(&keybuf)!;
		defer query::finish(&key);
		encode(&key);


@@ 90,7 90,7 @@ fn encode(key: *query::query) void = {
		return;
	};

	let pkeyh = bufio::fixed(pkey, io::mode::READ);
	let pkeyh = memio::fixed(pkey);
	ssh::key_decoderawpub(key, &pkeyh)!;

	ssh::encode_pubkeystr(os::stdout, key)!;

M cmd/hissh-import/main.ha => cmd/hissh-import/main.ha +3 -2
@@ 8,6 8,7 @@ use getopt;
use io;
use net::unix;
use net;
use memio;
use os;
use path;
use shlex;


@@ 33,7 34,7 @@ export fn main() void = {
	};
	defer ssh::key_free(privkey);

	let buf = bufio::dynamic(io::mode::WRITE);
	let buf = memio::dynamic();
	defer io::close(&buf)!;
	fmt::fprintf(&buf, "add proto=ssh type={} pkey='", ssh::keytype(privkey))!;
	let b64 = base64::newencoder(&base64::std_encoding, &buf);


@@ 62,7 63,7 @@ export fn main() void = {
	};
	defer io::close(conn)!;

	io::writeall(conn, bufio::buffer(&buf))!;
	io::writeall(conn, memio::buffer(&buf))!;

	match (bufio::scanline(conn)) {
	case io::EOF =>