# # # patch "ssh_agent.cc" # from [1b43b391aea85c97ace886ece9a9417c2cc7fcfa] # to [c13d81c9480ae21aaead5e32fa431d22e481bba9] # ============================================================ --- ssh_agent.cc 1b43b391aea85c97ace886ece9a9417c2cc7fcfa +++ ssh_agent.cc c13d81c9480ae21aaead5e32fa431d22e481bba9 @@ -25,7 +25,7 @@ ssh_agent::connect() if (!authsocket) { - W(F("ssh_agent: ssh-agent socket not found")); + W(F("ssh_agent: connect: ssh-agent socket not found")); return; } @@ -33,20 +33,19 @@ ssh_agent::connect() strncpy(sunaddr.sun_path, authsocket, sizeof(sunaddr.sun_path)); sock = socket(AF_UNIX, SOCK_STREAM, 0); - E(sock >= 0, F("ssh_agent: could not open socket to ssh-agent")); + E(sock >= 0, F("ssh_agent: connect: could not open socket to ssh-agent")); int ret = fcntl(sock, F_SETFD, 1); if (ret == -1) { close(sock); - E(ret != -1, F("ssh_agent: could not set up socket for ssh-agent")); - return; + E(ret != -1, F("ssh_agent: connect: could not set up socket for ssh-agent")); } ret = ::connect(sock, (struct sockaddr *)&sunaddr, sizeof sunaddr); if (ret < 0) { close(sock); - E(ret >= 0, F("ssh_agent: could not connect to socket for ssh-agent")); + E(ret >= 0, F("ssh_agent: connect: could not connect to socket for ssh-agent")); } stream = shared_ptr(new Stream(sock)); } @@ -54,7 +53,7 @@ ssh_agent::get_long(char const * buf) u32 ssh_agent::get_long(char const * buf) { - L(FL("agent: get_long: %u %u %u %u") + L(FL("ssh_agent: get_long: %u %u %u %u") % (u32)((unsigned char)(buf)[0]) % (u32)((unsigned char)(buf)[1]) % (u32)((unsigned char)(buf)[2]) @@ -78,12 +77,12 @@ ssh_agent::get_string_from_buf(string co void ssh_agent::get_string_from_buf(string const & buf, u32 & loc, u32 & len, string & out) { - L(FL("agent: get_string_from_buf: buf length: %u, loc: %u" ) % buf.length() % loc); + L(FL("ssh_agent: get_string_from_buf: buf length: %u, loc: %u" ) % buf.length() % loc); len = get_long_from_buf(buf, loc); - L(FL("agent: get_string_from_buf: len: %u" ) % len); - E(loc + len <= buf.length(), F("agent: length (%i) of buf less than loc (%u) + len (%u)") % buf.length() % loc % len); + L(FL("ssh_agent: get_string_from_buf: len: %u" ) % len); + E(loc + len <= buf.length(), F("ssh_agent: length (%i) of buf less than loc (%u) + len (%u)") % buf.length() % loc % len); out = buf.substr(loc, len); - L(FL("agent: get_string_from_buf: out length: %u") % out.length()); + L(FL("ssh_agent: get_string_from_buf: out length: %u") % out.length()); loc += len; } @@ -94,7 +93,7 @@ ssh_agent::put_long(u32 l, char * buf) buf[1] = (char)(unsigned char)(l >> 16); buf[2] = (char)(unsigned char)(l >> 8); buf[3] = (char)(unsigned char)(l); - L(FL("agent: long_to_buf: %u %u %u %u") + L(FL("ssh_agent: long_to_buf: %u %u %u %u") % (u32)(unsigned char)buf[0] % (u32)(unsigned char)buf[1] % (u32)(unsigned char)buf[2] @@ -105,10 +104,10 @@ ssh_agent::put_long_into_buf(u32 l, stri ssh_agent::put_long_into_buf(u32 l, string & buf) { char lb[4]; - L(FL("agent: put_long_into_buf: long: %u, buf len: %i") % l % buf.length()); + L(FL("ssh_agent: put_long_into_buf: long: %u, buf len: %i") % l % buf.length()); put_long(l, lb); buf.append(lb, 4); - L(FL("agent: put_long_into_buf: buf len now %i") % buf.length()); + L(FL("ssh_agent: put_long_into_buf: buf len now %i") % buf.length()); } void @@ -116,7 +115,7 @@ ssh_agent::put_bigint_into_buf(BigInt co { int bytes = bi.bytes() + 1; Botan::byte bi_buf[bytes]; - L(FL("agent: put_bigint_into_buf: bigint.bytes(): %u, bigint: %s") % bi.bytes() % bi); + L(FL("ssh_agent: put_bigint_into_buf: bigint.bytes(): %u, bigint: %s") % bi.bytes() % bi); bi_buf[0] = 0x00; BigInt::encode(bi_buf + 1, bi); int hasnohigh = (bi_buf[1] & 0x80) ? 0 : 1; @@ -124,26 +123,26 @@ ssh_agent::put_bigint_into_buf(BigInt co bi_str.append((char *)(bi_buf + hasnohigh), bytes - hasnohigh); put_string_into_buf(bi_str, buf); bi_str[0] = bytes; - L(FL("agent: put_bigint_into_buf: buf len now %i") % buf.length()); + L(FL("ssh_agent: put_bigint_into_buf: buf len now %i") % buf.length()); } void ssh_agent::put_key_into_buf(RSA_PublicKey const & key, string & buf) { - L(FL("agent: put_key_into_buf: key e: %s, n: %s") % key.get_e() % key.get_n()); + L(FL("ssh_agent: put_key_into_buf: key e: %s, n: %s") % key.get_e() % key.get_n()); put_string_into_buf("ssh-rsa", buf); put_bigint_into_buf(key.get_e(), buf); put_bigint_into_buf(key.get_n(), buf); - L(FL("agent: put_key_into_buf: buf len now %i") % buf.length()); + L(FL("ssh_agent: put_key_into_buf: buf len now %i") % buf.length()); } void ssh_agent::put_string_into_buf(string const & str, string & buf) { - L(FL("agent: put_string_into_buf: str len %i, buf len %i") % str.length() % buf.length()); + L(FL("ssh_agent: put_string_into_buf: str len %i, buf len %i") % str.length() % buf.length()); put_long_into_buf(str.length(), buf); buf.append(str.c_str(), str.length()); - L(FL("agent: put_string_into_buf: buf len now %i") % buf.length()); + L(FL("ssh_agent: put_string_into_buf: buf len now %i") % buf.length()); } void @@ -158,12 +157,12 @@ ssh_agent::read_num_bytes(u32 const len, ret = stream->read(read_buf, min(get, bufsize)); E(ret >= 0, F("stream read failed (%i)") % ret); if (ret > 0) - L(FL("agent: read_num_bytes: read %i bytes") % ret); + L(FL("ssh_agent: read_num_bytes: read %i bytes") % ret); out.append(read_buf, ret); get -= ret; } - L(FL("agent: read_num_bytes: get: %u") % get); - L(FL("agent: read_num_bytes: length %u") % out.length()); + L(FL("ssh_agent: read_num_bytes: get: %u") % get); + L(FL("ssh_agent: read_num_bytes: length %u") % out.length()); } void @@ -176,7 +175,7 @@ ssh_agent::fetch_packet(string & packet) len = get_long_from_buf(len_buf, l); E(len > 0, F("zero-length packet from ssh-agent")); - L(FL("agent: get_keys response len %u") % len); + L(FL("ssh_agent: get_keys response len %u") % len); read_num_bytes(len, packet); } @@ -206,15 +205,15 @@ ssh_agent::get_keys() //first byte is packet type u32 packet_loc = 0; - E(packet.at(0) == 12, F("agent: packet type (%u) != 12") % (u32)packet.at(0)); + E(packet.at(0) == 12, F("ssh_agent: packet type (%u) != 12") % (u32)packet.at(0)); packet_loc += 1; u32 num_keys = get_long_from_buf(packet, packet_loc); - L(FL("agent: %u keys") % num_keys); + L(FL("ssh_agent: %u keys") % num_keys); for (u32 key_num = 0; key_num < num_keys; ++key_num) { - L(FL("agent: getting key # %u") % key_num); + L(FL("ssh_agent: getting key # %u") % key_num); u32 key_len; string key; @@ -224,49 +223,49 @@ ssh_agent::get_keys() string type; get_string_from_buf(key, key_loc, slen, type); - L(FL("agent: type: %s") % type); + L(FL("ssh_agent: type: %s") % type); if (type == "ssh-rsa") { - L(FL("agent: RSA")); + L(FL("ssh_agent: RSA")); string e_str; get_string_from_buf(key, key_loc, slen, e_str); BigInt e = BigInt::decode((unsigned char *)(e_str.c_str()), e_str.length(), BigInt::Binary); - L(FL("agent: e: %s, len %u") % e % slen); + L(FL("ssh_agent: e: %s, len %u") % e % slen); string n_str; get_string_from_buf(key, key_loc, slen, n_str); BigInt n = BigInt::decode((unsigned char *)(n_str.c_str()), n_str.length(), BigInt::Binary); - L(FL("agent: n: %s, len %u") % n % slen); + L(FL("ssh_agent: n: %s, len %u") % n % slen); RSA_PublicKey key(n, e); keys.push_back(key); } else - L(FL("agent: ignoring key of type '%s'") % type); + L(FL("ssh_agent: ignoring key of type '%s'") % type); //if (type == "ssh-dss") // { - // L(FL("agent: DSA (ignoring)")); + // L(FL("ssh_agent: DSA (ignoring)")); // string p; // get_string_from_buf(key, key_loc, slen, p); // //BigInt pb = BigInt::decode((unsigned char *)(p.c_str()), slen, BigInt::Binary); - // //L(FL("agent: p: %s, len %u") % pb % slen); + // //L(FL("ssh_agent: p: %s, len %u") % pb % slen); // string q; // get_string_from_buf(key, key_loc, slen, q); // //BigInt qb = BigInt::decode((unsigned char *)(q.c_str()), slen, BigInt::Binary); - // //L(FL("agent: q: %s, len %u") % qb % slen); + // //L(FL("ssh_agent: q: %s, len %u") % qb % slen); // string g; // get_string_from_buf(key, key_loc, slen, g); // //BigInt gb = BigInt::decode((unsigned char *)(g.c_str()), slen, BigInt::Binary); - // //L(FL("agent: g: %s, len %u") % gb % slen); + // //L(FL("ssh_agent: g: %s, len %u") % gb % slen); // string pub_key; // get_string_from_buf(key, key_loc, slen, pub_key); // //BigInt pkb = BigInt::decode((unsigned char *)(pub_key.c_str()), slen, BigInt::Binary); - // //L(FL("agent: pub_key: %s, len %u") % pkb % slen); + // //L(FL("ssh_agent: pub_key: %s, len %u") % pkb % slen); // } else // E(false, F("key type '%s' not recognized by ssh-agent code") % type); - L(FL("agent: packet length %u, packet loc %u, key length %u, key loc, %u") + L(FL("ssh_agent: packet length %u, packet loc %u, key length %u, key loc, %u") % packet.length() % packet_loc % key.length() @@ -275,7 +274,7 @@ ssh_agent::get_keys() string comment; u32 comment_len; get_string_from_buf(packet, packet_loc, comment_len, comment); - L(FL("agent: comment_len: %u, comment: %s") % comment_len % comment); + L(FL("ssh_agent: comment_len: %u, comment: %s") % comment_len % comment); } return keys; } @@ -283,7 +282,7 @@ ssh_agent::sign_data(RSA_PublicKey const void ssh_agent::sign_data(RSA_PublicKey const & key, string const & data, string & out) { - L(FL("agent: sign_data: key e: %s, n: %s, data len: %i") % key.get_e() % key.get_n() % data.length()); + L(FL("ssh_agent: sign_data: key e: %s, n: %s, data len: %i") % key.get_e() % key.get_n() % data.length()); string data_out; string key_buf; string full_sig; @@ -296,7 +295,7 @@ ssh_agent::sign_data(RSA_PublicKey const u32 flags = 0; put_long_into_buf(flags, data_out); - L(FL("agent: sign_data: data_out length: %u") % data_out.length()); + L(FL("ssh_agent: sign_data: data_out length: %u") % data_out.length()); string packet_out; put_string_into_buf(data_out, packet_out); @@ -307,19 +306,19 @@ ssh_agent::sign_data(RSA_PublicKey const fetch_packet(packet_in); u32 packet_in_loc = 0; - E(packet_in.at(0) == 14, F("agent: sign_data: packet_in type (%u) != 14") % (u32)packet_in.at(0)); + E(packet_in.at(0) == 14, F("ssh_agent: sign_data: packet_in type (%u) != 14") % (u32)packet_in.at(0)); packet_in_loc += 1; u32 full_sig_len; get_string_from_buf(packet_in, packet_in_loc, full_sig_len, full_sig); - L(FL("agent: sign_data: signed data length: %u (%u)") % full_sig_len % full_sig.length()); + L(FL("ssh_agent: sign_data: signed data length: %u (%u)") % full_sig_len % full_sig.length()); string type; u32 full_sig_loc = 0, type_len, out_len; get_string_from_buf(full_sig, full_sig_loc, type_len, type); - L(FL("agent: sign_data: type (%u), '%s'") % type_len % type); + L(FL("ssh_agent: sign_data: type (%u), '%s'") % type_len % type); get_string_from_buf(full_sig, full_sig_loc, out_len, out); - L(FL("agent: sign_data: output length %u") % out_len); + L(FL("ssh_agent: sign_data: output length %u") % out_len); } // Local Variables: