rxkad: Cleanup and build src/rxkad/test

We currently do not build 'fc_test' or any of the programs in
src/rxkad/test, and they've bitrotted as a result. Clean them up so
they can build again, and make them all built by default.

Some of these programs depend on higher-level libraries (like
libafsauthent) that depend on rxkad, so we cannot build the test
programs during the top-level 'make rxkad' target. So instead, create
a new top-level target called 'rxkad_test' that just builds the test
programs. Move 'fc_test' into the test subdir to make it easier to
build with the other test programs.

Change-Id: Ic5570efd9076e3e4feec18002d67ce8d58f321d1
Reviewed-on: https://gerrit.openafs.org/14750
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Andrew Deason 2021-08-08 20:36:14 -05:00
parent fc626da7fd
commit 1fe1dac4c5
11 changed files with 104 additions and 98 deletions

2
CODING
View File

@ -375,3 +375,5 @@ rxkad/ticket5.c : format-truncation : inside included file v5der.c in the
arithmetic on tm_year and tm_mon fields
lwp/process.c : dangling-pointer : Ignore the legitimate use of saving
the address of a stack variable
src/rxkad/test/stress_c.c
: deprecated : hcrypto single-DES

View File

@ -232,6 +232,9 @@ rxgk: cmd comerr hcrypto rfc3961 rx rxgk_depinstall
rxkad: cmd comerr hcrypto rfc3961 rx rxkad_depinstall
+${COMPILE_PART1} rxkad ${COMPILE_PART2}
rxkad_test: rxkad auth libafsauthent libafsrpc
+${COMPILE_PART1} rxkad/test ${COMPILE_PART2}
auth: cmd comerr hcrypto lwp rx rxkad audit sys auth_depinstall rxgk
+${COMPILE_PART1} auth ${COMPILE_PART2}
@ -622,7 +625,7 @@ finale_notest: project cmd comerr afsd butc tbutc tbudb @ENABLE_KERNEL_MODULE@ \
bozo @VFSCK@ volser tvolser tsalvaged dviced dvolser libafscp \
venus venustests update xstat afsmonitor rxdebug libafsrpc rfc3961 \
hcrypto libafsauthent libadmin man-pages tools platform kopenafs \
authtools $(DIR_roken) rxgk rx_test
authtools $(DIR_roken) rxgk rx_test rxkad_test
+${COMPILE_PART1} finale ${COMPILE_PART2}
finale_nolibafs_notest: project cmd comerr afsd butc tbutc tbudb libuafs audit kauth \
@ -630,7 +633,7 @@ finale_nolibafs_notest: project cmd comerr afsd butc tbutc tbudb libuafs audit k
volser tvolser tsalvaged dviced dvolser libafscp venus venustests \
update xstat afsmonitor rxdebug libafsrpc rfc3961 hcrypto \
libafsauthent libadmin man-pages tools platform kopenafs \
authtools $(DIR_roken) rxgk rx_test
authtools $(DIR_roken) rxgk rx_test rxkad_test
+${COMPILE_PART1} finale ${COMPILE_PART2}
finale: finale_notest test_build

View File

@ -4,4 +4,3 @@
/rxkad.h
/rxkad_errs.c
/fc_test

View File

@ -28,19 +28,8 @@ LT_deps=$(top_builddir)/src/comerr/liboafs_comerr.la \
LT_libs=$(LDFLAGS_hcrypto) $(LIB_hcrypto)
fc_test_OBJS=fc_test.o
fc_test_LIBS=\
${TOP_LIBDIR}/librxkad.a \
${TOP_LIBDIR}/libafshcrypto_lwp.a \
${TOP_LIBDIR}/librx.a \
${TOP_LIBDIR}/liblwp.a \
${TOP_LIBDIR}/libafsutil.a
all: ${TOP_LIBDIR}/librxkad.a liboafs_rxkad.la librxkad_pic.la depinstall
test: fc_test
generated: \
rxkad_errs.c rxkad.h
@ -101,7 +90,6 @@ bg-fcrypt.o bg-fcrypt.lo: rxkad.h
crc.o crc.lo: rxkad.h
crypt_conn.o crypt_conn.lo: rxkad.h
fcrypt.o fcrypt.lo: rxkad.h
fc_test.o fc_test.lo: rxkad.h
rxkad_client.o rxkad_client.lo: rxkad.h
rxkad_common.o rxkad_common.lo: rxkad.h
rxkad_server.o rxkad_server.lo: rxkad.h
@ -113,11 +101,6 @@ tcrypt.o: tcrypt.c AFS_component_version_number.o
tcrypt: tcrypt.o librxkad.a
$(AFS_LDRULE) tcrypt.o librxkad.a
fc_test: ${fc_test_OBJS} ${fc_test_LIBS}
$(AFS_LDRULE) ${fc_test_OBJS} ${fc_test_LIBS} ${XLIBS}
fc_test.o: ${INCLS}
#
# Install targets
#
@ -143,11 +126,9 @@ dest: librxkad.a fcrypt.h rxkad.h rxkad_prototypes.h
# Misc. targets
#
clean:
cd test && $(MAKE) clean
$(LT_CLEAN)
$(RM) -f *.o *.a tcrypt core rxkad_errs.c rxkad.h \
AFS_component_version_number.c fc_test
test:
cd test; $(MAKE)
AFS_component_version_number.c
include ../config/Makefile.version

View File

@ -64,7 +64,21 @@ struct rxkad_global_stats rxkad_global_stats;
pthread_mutex_t rxkad_global_stats_lock;
pthread_key_t rxkad_stats_key;
#else /* AFS_PTHREAD_ENV && !KERNEL */
/*
* On DARWIN, if rxkad_stats is in the 'common' section, the linker can
* complain that rxkad_stats is undefined. It's not clear why this happens, but
* we can avoid it if we give rxkad_stats an initializer, preventing it from
* going in the 'common' section.
*
* On some other platforms (FBSD), the initializer causes warnings/errors
* because of the arrays/structs inside rxkad_stats. So only do this for
* DARWIN.
*/
# ifdef AFS_DARWIN_ENV
struct rxkad_stats rxkad_stats = { 0 };
# else
struct rxkad_stats rxkad_stats;
# endif
#endif /* AFS_PTHREAD_ENV && !KERNEL */
#if defined(AFS_PTHREAD_ENV) && !defined(KERNEL)

10
src/rxkad/test/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# After changing this file, please run
# git ls-files -i --exclude-standard
# to check that you haven't inadvertently ignored any tracked files.
/fc_test
/stress
/stress.h
/stress_errs.c
/stress_errs.h
/th_stress

View File

@ -24,30 +24,40 @@ LIBS=${TOP_LIBDIR}/libauth.a \
${TOP_LIBDIR}/libafshcrypto_lwp.a \
${TOP_LIBDIR}/librx.a \
${TOP_LIBDIR}/libafscom_err.a \
${TOP_LIBDIR}/util.a
${TOP_LIBDIR}/util.a \
${TOP_LIBDIR}/libopr.a \
${TOP_LIBDIR}/libafsrfc3961.a \
${LIB_hcrypto} \
${LIB_roken}
THLIBS= $(top_builddir)/src/cmd/liboafs_cmd.la \
THLIBS= ${TOP_LIBDIR}/libcmd.a \
${TOP_LIBDIR}/libafscom_err.a \
${TOP_LIBDIR}/libafsauthent.a ${TOP_LIBDIR}/libafsrpc.a \
${MT_LIBS} ${ULIBS} ${LIBRPC} -lpthread
${LIB_hcrypto} \
${LIB_roken} \
${MT_LIBS} -lpthread
THRULE = ${MT_CC} $(COMMON_CFLAGS) $(MT_CFLAGS)
noversion all test system: stress
fc_test_OBJS=fc_test.o
noversion all test system: stress th_stress fc_test
dest install:
clean:
$(LT_CLEAN)
$(RM) -f *.o stress.cs.c stress.ss.c stress.xdr.c stress.h \
stress_errs.c stress_errs.h stress th_*
stress_errs.c stress_errs.h stress th_* fc_test
stress.ss.o: stress.ss.c
stress.cs.o: stress.cs.c
stress.ss.o: stress.ss.c stress.h
stress.cs.o: stress.cs.c stress.h
stress.xdr.o: stress.xdr.c stress.h
th_stress.ss.o: stress.ss.c
th_stress.ss.o: stress.ss.c stress.h
${THRULE} -c stress.ss.c -o th_stress.ss.o
th_stress.cs.o: stress.cs.c
th_stress.cs.o: stress.cs.c stress.h
${THRULE} -c stress.cs.c -o th_stress.cs.o
th_stress.xdr.o: stress.xdr.c stress.h
@ -83,6 +93,8 @@ stress_s.o: stress_errs.h
stress.o: ${HEADERS}
stress_c.o: ${HEADERS}
stress_s.o: ${HEADERS}
fc_test.o: ${HEADERS}
CFLAGS_fc_test.o = -I$(TOP_SRCDIR)/rxkad -I$(TOP_OBJDIR)/src/rxkad
th_stress.o: stress.c ${HEADERS}
${THRULE} -c $(srcdir)/stress.c -o th_stress.o
@ -100,9 +112,10 @@ stress: stress.o stress.xdr.o stress_c.o stress_s.o stress.cs.o \
${LIBS} ${XLIBS}
th_stress: th_stress.o th_stress.xdr.o th_stress_c.o th_stress_s.o \
th_stress.cs.o th_stress.ss.o stress_errs.o \
${LIBRPC}
th_stress.cs.o th_stress.ss.o stress_errs.o
$(LT_LDRULE_static) th_stress.o th_stress.xdr.o th_stress_c.o \
th_stress_s.o th_stress.cs.o th_stress.ss.o stress_errs.o \
${THLIBS}
fc_test: ${fc_test_OBJS}
$(AFS_LDRULE) ${fc_test_OBJS} ${LIBS} ${XLIBS}

View File

@ -36,8 +36,9 @@
#include <roken.h>
#include "rxkad.h"
#include <rx/rxkad.h>
#include <rx/rx.h>
#include <rx/rx_packet.h>
#include "private_data.h"
#define ROUNDS 16
@ -47,7 +48,7 @@
typedef afs_int32 int32;
typedef afs_uint32 u_int32;
const char the_quick[] = "The quick brown fox jumps over the lazy dogs.\0\0";
static char the_quick[] = "The quick brown fox jumps over the lazy dogs.\0\0";
const unsigned char key1[8] =
{ 0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87 };
@ -82,15 +83,27 @@ main(void)
char ciph[100], clear[100];
u_int32 data[2];
u_int32 iv[2];
struct rx_connection conn;
struct rx_connection *conn;
struct rx_securityClass obj;
struct rx_securityOps ops;
struct rxkad_cprivate cpriv;
struct rx_packet packet;
int fail = 0;
conn.securityObject = &obj;
obj.privateData = (void *)&cpriv;
memset(&cpriv, 0, sizeof(cpriv));
memset(&obj, 0, sizeof(obj));
memset(&ops, 0, sizeof(ops));
if (rx_Init(0) != 0) {
fprintf(stderr, "error: rx_Init failed\n");
exit(1);
}
cpriv.type = 0;
obj.privateData = &cpriv;
obj.ops = &ops;
conn = rx_NewConnection(0, 0, 0, &obj, RX_SECIDX_KAD);
if (sizeof(int32) != 4) {
fprintf(stderr, "error: sizeof(int32) != 4\n");
@ -145,8 +158,8 @@ main(void)
packet.wirevec[2].iov_len = 0;
/* For unknown reasons bytes 4-7 are zeroed in rxkad_EncryptPacket */
rxkad_EncryptPacket(&conn, sched, iv, sizeof(the_quick), &packet);
rxkad_DecryptPacket(&conn, sched, iv, sizeof(the_quick), &packet);
rxkad_EncryptPacket(conn, (const fc_KeySchedule *)sched, (const fc_InitializationVector *)iv, sizeof(the_quick), &packet);
rxkad_DecryptPacket(conn, (const fc_KeySchedule *)sched, (const fc_InitializationVector *)iv, sizeof(the_quick), &packet);
clear[4] ^= 'q';
clear[5] ^= 'u';
clear[6] ^= 'i';

View File

@ -29,6 +29,7 @@
#include <afs/auth.h>
#include <afs/com_err.h>
#include <afs/cmd.h>
#include <afs/opr.h>
#include <rx/rxkad.h>
#include "stress.h"
@ -137,8 +138,8 @@ CommandProc(struct cmd_syndesc *as, void *arock)
if (as->parms[aMELT1b].items)
meltdown_1pkt = 0;
if (as->parms[aRECLAIM].items)
rxi_doreclaim = 0;
/* Ignore aRECLAIM/-noreclaim; the relevant option (rxi_doreclaim) doesn't
* exist anymore. */
if (as->parms[a2DCHOICE].items)
rxi_2dchoice = 0;
@ -346,9 +347,9 @@ main(int argc, char **argv)
cmd_AddParm(ts, "-trace", CMD_SINGLE, CMD_OPTIONAL,
"file for per-call trace info");
cmd_AddParm(ts, "-nomd1pkt", CMD_FLAG, CMD_OPTIONAL,
"dont prefer one-packet calls");
cmd_AddParm(ts, "-noreclaim", CMD_FLAG, CMD_OPTIONAL,
"dont aggressively reclaim packets");
"don't prefer one-packet calls");
cmd_AddParm(ts, "-noreclaim", CMD_FLAG, CMD_OPTIONAL | CMD_HIDDEN,
"don't aggressively reclaim packets [ignored]");
cmd_AddParm(ts, "-no2dchoice", CMD_FLAG, CMD_OPTIONAL,
"disable rx_getcall 2d choice code");
cmd_AddParm(ts, "-maxskew", CMD_SINGLE, CMD_OPTIONAL,

View File

@ -14,13 +14,19 @@
#include <roken.h>
#ifdef IGNORE_SOME_GCC_WARNINGS
# pragma GCC diagnostic warning "-Wdeprecated-declarations"
#endif
#include <afs/stds.h>
#include <afs/com_err.h>
#include <afs/afsutil.h>
#include <rx/rxkad.h>
#include <rx/rxkad_convert.h>
#include <rx/rx_packet.h>
#include <afs/auth.h>
#include <des_prototypes.h>
#include <hcrypto/des.h>
#include "stress.h"
#include "stress_internal.h"
#ifdef AFS_PTHREAD_ENV
@ -76,8 +82,8 @@ GetTicket(long *versionP, struct ktc_encryptionKey *session,
long code;
/* create random session key, using key for seed to good random */
des_init_random_number_generator(ktc_to_cblock(&serviceKey));
code = des_random_key(ktc_to_cblock(session));
DES_init_random_number_generator(ktc_to_cblock(&serviceKey));
code = DES_new_random_key(ktc_to_cblock(session));
if (code)
return code;
@ -430,7 +436,7 @@ RunLoadTest(struct clientParms *parms, struct rx_connection *conn)
static long
RepeatLoadTest(struct clientParms *parms, struct rx_connection *conn)
{
long code;
long code = 0;
long count;
if (parms->repeatInterval == 0) {
@ -478,8 +484,6 @@ RepeatLoadTest(struct clientParms *parms, struct rx_connection *conn)
/* For backward compatibility, don't try to use the CallNumber stuff unless
* we're compiling against the new Rx. */
#ifdef rx_GetPacketCksum
struct multiChannel {
struct rx_connection *conn;
int done;
@ -582,7 +586,7 @@ CheckCallFailure(struct rx_connection *conn, long codes[], long code,
for (i = 0; i < RX_MAXCALLS; i++)
if (!((codes[i] == 0) || (codes[i] == code) || (codes[i] == -3)))
okay = 0;
if (conn->error)
if (rx_ConnError(conn))
okay = 0;
if (!okay) {
fprintf(stderr, "%s produced these errors:\n", msg);
@ -606,23 +610,11 @@ CheckCallFailure(struct rx_connection *conn, long codes[], long code,
return 0;
}
#endif /* rx_GetPacketCksum */
static long
RunCallTest(struct clientParms *parms, long host,
struct rx_securityClass *sc, long si)
{
long code;
#ifndef rx_GetPacketCksum
code = RXKST_BADARGS;
afs_com_err(whoami, code,
"Older versions of Rx don't support Get/Set callNumber Vector procedures: can't run this CallTest");
return code;
#else
int i, ch;
struct rx_connection *conn;
long firstCall;
@ -801,13 +793,8 @@ RunCallTest(struct clientParms *parms, long host,
rx_DestroyConnection(conn);
return retCode;
#endif /* rx_GetPacketCksum */
}
#ifdef rx_GetPacketCksum
static struct {
int op;
u_long epoch; /* connection to attack */
@ -975,22 +962,10 @@ SlowCall(void * rock)
return (void *)(intptr_t)temp_rc;
}
#endif /* rx_GetPacketCksum */
static long
RunHijackTest(struct clientParms *parms, long host,
struct rx_securityClass *sc, long si)
{
#ifndef rx_GetPacketCksum
code = RXKST_BADARGS;
afs_com_err(whoami, code,
"Older versions of Rx don't export packet tracing routines: can't run this HijackTest");
return code;
#else
long code;
struct rx_connection *conn = 0;
struct rx_connection *otherConn = 0;
@ -1017,8 +992,8 @@ RunHijackTest(struct clientParms *parms, long host,
RXKST_SERVICEID, sc, si); \
if (!(conn)) return RXKST_NEWCONNFAILED; \
outgoingOps.client = 1; \
outgoingOps.epoch = (conn)->epoch; \
outgoingOps.cid = (conn)->cid; }
outgoingOps.epoch = rx_GetConnectionEpoch(conn); \
outgoingOps.cid = rx_GetConnectionId(conn); }
HIJACK_CONN(conn);
@ -1047,7 +1022,7 @@ RunHijackTest(struct clientParms *parms, long host,
if (code != RXKADSEALEDINCON) {
afs_com_err(whoami, code, "doing FastCall with ZEROCKSUM");
return code;
} else if (!conn->error) {
} else if (!rx_ConnError(conn)) {
code = RXKST_NOCONNERROR;
afs_com_err(whoami, code, "doing FastCall with ZEROCKSUM");
return code;
@ -1065,7 +1040,7 @@ RunHijackTest(struct clientParms *parms, long host,
if (code != RXKADSEALEDINCON) {
afs_com_err(whoami, code, "doing FastCall with ZEROCKSUM");
return code;
} else if (!conn->error) {
} else if (!rx_ConnError(conn)) {
code = RXKST_NOCONNERROR;
afs_com_err(whoami, code, "doing FastCall with ZEROCKSUM");
return code;
@ -1082,14 +1057,14 @@ RunHijackTest(struct clientParms *parms, long host,
* case, which the server will discard. */
#define RedirectChallenge(conn,otherConn) \
(incomingOps.epoch = (conn)->epoch, \
incomingOps.cid = (conn)->cid, \
(incomingOps.epoch = rx_GetConnectionEpoch(conn),\
incomingOps.cid = rx_GetConnectionId(conn),\
incomingOps.client = 1, \
incomingOps.newEpoch = (otherConn)->epoch, \
incomingOps.newCid = (otherConn)->cid, \
incomingOps.newEpoch = rx_GetConnectionEpoch(otherConn),\
incomingOps.newCid = rx_GetConnectionId(otherConn),\
incomingOps.op = IO_REDIRECTCHALLENGE, \
outgoingOps.epoch = (otherConn)->epoch, \
outgoingOps.cid = (otherConn)->cid, \
outgoingOps.epoch = rx_GetConnectionEpoch(otherConn),\
outgoingOps.cid = rx_GetConnectionId(otherConn),\
outgoingOps.client = 1, \
outgoingOps.op = OO_COUNT, \
outgoingOps.counts[RX_PACKET_TYPE_RESPONSE] = 0)
@ -1198,9 +1173,6 @@ RunHijackTest(struct clientParms *parms, long host,
rx_DestroyConnection(otherConn);
rx_DestroyConnection(conn);
return code;
#endif /* rx_GetPacketCksum */
}
long

View File

@ -21,8 +21,6 @@ extern long serviceKeyVersion;
#define RXKST_CLIENT_INST ""
#define RXKST_CLIENT_CELL "rxtest.openafs.org"
extern int errno;
struct serverParms {
char *whoami;
u_int threads;