diff -urN orig/rpc_client/cli_connect.c ./rpc_client/cli_connect.c --- orig/rpc_client/cli_connect.c 2000-08-05 20:03:22.000000000 +1000 +++ ./rpc_client/cli_connect.c 2002-11-13 11:05:05.000000000 +1100 @@ -104,6 +104,16 @@ con = (struct cli_connection *)malloc(sizeof(*con)); + /* the connection cacheing code will happily give us an + established unencrypted rpc connection when we need an + enrypted one. This is a quick hack to disable the + connection cache. The correct fix is to teach the + connection cache to return an encrypted connection if + possible (or if needed) */ + if (auth) { + reuse = False; + } + if (con == NULL) { return NULL; diff -urN orig/rpc_client/cli_pipe.c ./rpc_client/cli_pipe.c --- orig/rpc_client/cli_pipe.c 2000-08-10 02:00:09.000000000 +1000 +++ ./rpc_client/cli_pipe.c 2002-11-13 11:01:32.000000000 +1100 @@ -248,6 +248,17 @@ return True; } +/* + when the PDUs are reassembled we need to remove the chunk of auth + data at the end of each PDU. This is a convenience function to get + the length right. +*/ +static int auth_fudge(RPC_HDR *rhdr) +{ + if (!rhdr->auth_len) return 0; + return rhdr->auth_len + 8; +} + /**************************************************************************** receive response data from an rpc pipe, which may be large... @@ -375,7 +386,7 @@ } prs_append_data(rdata, prs_data(&rpdu, rpdu.offset), - rhdr.frag_len - rpdu.offset); + rhdr.frag_len - rpdu.offset - auth_fudge(&rhdr)); prs_free_data(&rpdu); /* only one rpc fragment, and it has been read */ @@ -428,7 +439,7 @@ { prs_append_data(rdata, prs_data(&rpdu, rpdu.offset), - rhdr.frag_len - rpdu.offset); + rhdr.frag_len - rpdu.offset - auth_fudge(&rhdr)); prs_free_data(&rpdu); } } @@ -566,15 +577,6 @@ { return False; } - - if (rhdr.auth_len != 0 && - (auth->cli_decode_pdu == NULL || - !auth->cli_decode_pdu(con, rdata, - rhdr.frag_len, rhdr.auth_len))) - { - return False; - } - } return True; @@ -675,14 +677,6 @@ return False; } } - - if (rhdr.auth_len != 0 && - (auth->cli_decode_pdu == NULL || - !auth->cli_decode_pdu(con, rdata, rhdr.frag_len, rhdr.auth_len))) - { - return False; - } - return True; } @@ -734,13 +728,6 @@ return False; } - if (rhdr.auth_len != 0 && - (auth->cli_decode_pdu == NULL || - !auth->cli_decode_pdu(con, rdata, rhdr.frag_len, rhdr.auth_len))) - { - return False; - } - return True; } diff -urN orig/rpc_parse/parse_netsec.c ./rpc_parse/parse_netsec.c --- orig/rpc_parse/parse_netsec.c 2000-04-25 00:10:53.000000000 +1000 +++ ./rpc_parse/parse_netsec.c 2002-11-11 21:17:46.000000000 +1100 @@ -222,7 +222,7 @@ int i; /* store the sequence number */ - SIVAL(dataN, 0, a->seq_num); + SIVAL(dataN, 0, 0 /* a->seq_num */); for (i = 0; i < sizeof(sess_kf0); i++) { @@ -279,6 +279,23 @@ return True; } +/* + save a lump of data into a file. Mostly used for debugging +*/ +BOOL file_save(const char *fname, void *packet, size_t length) +{ + int fd; + fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0644); + if (fd == -1) { + return False; + } + if (write(fd, packet, length) != length) { + return False; + } + close(fd); + return True; +} + BOOL netsec_decode(struct netsec_auth_struct *a, RPC_AUTH_NETSEC_CHK * verf, char *data, size_t data_len) { @@ -287,9 +304,16 @@ struct MD5Context ctx3; uchar sess_kf0[16]; int i; + static int count; + char *fname; + + count++; + + asprintf(&fname, "decode_in.%d.dat", count); + file_save(fname, data, data_len); /* store the sequence number */ - SIVAL(dataN, 0, a->seq_num); + SIVAL(dataN, 0, 0 /* a->seq_num */); for (i = 0; i < sizeof(sess_kf0); i++) { @@ -325,6 +349,10 @@ MD5Update(&ctx3, verf->data8, 8); dump_data_pw("data :\n", data, data_len); + + asprintf(&fname, "decode_data.%d.dat", count); + file_save(fname, data, data_len); + netsechash(digest1, data, data_len); dump_data_pw("datadec:\n", data, data_len); @@ -339,5 +367,8 @@ dump_data_pw("digest:\n", digest1, sizeof(digest1)); dump_data_pw("verf->data1:\n", verf->data1, sizeof(verf->data1)); + asprintf(&fname, "decode_out.%d.dat", count); + file_save(fname, data, data_len); + return memcmp(digest1, verf->data1, sizeof(verf->data1)) == 0; }