From 954aa2338ce3fbaee81defe45a4d99da69d0baf7 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Mon, 30 May 2011 18:18:33 +0100 Subject: [PATCH] tests: Move code to add new DES keys to common Make the code which adds a new (static) DES key to a cell's configuration generally available, as this will also be useful in constructing other tests Change-Id: I5d284016628e9d25a198607ffd6f8f1a63ddf652 Reviewed-on: http://gerrit.openafs.org/4807 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- tests/auth/superuser-t.c | 7 ++----- tests/common/common.h | 3 +++ tests/common/config.c | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/auth/superuser-t.c b/tests/auth/superuser-t.c index dae89c1..dd53b98 100644 --- a/tests/auth/superuser-t.c +++ b/tests/auth/superuser-t.c @@ -38,6 +38,7 @@ #include #include +#define HC_DEPRECATED #include #include @@ -436,7 +437,6 @@ int main(int argc, char **argv) struct afsconf_dir *dir; char *dirname; int serverPid, clientPid, waited, stat; - char keymaterial[]="\x19\x17\xff\xe6\xbb\x77\x2e\xfc"; int code; /* Start the client and the server if requested */ @@ -465,10 +465,7 @@ int main(int argc, char **argv) exit(1); } - DES_set_odd_parity((DES_cblock *)keymaterial); - - /* Add a key to it so we can use it for connection tests */ - code = afsconf_AddKey(dir, 1, keymaterial, 1); + code = afstest_AddDESKeyFile(dir); if (code) { afs_com_err("superuser-t", code, "while adding new key\n"); exit(1); diff --git a/tests/common/common.h b/tests/common/common.h index 9f8fe2b..2bd2a27 100644 --- a/tests/common/common.h +++ b/tests/common/common.h @@ -24,3 +24,6 @@ extern char *afstest_BuildTestConfig(void); extern void afstest_UnlinkTestConfig(char *); + +struct afsconf_dir; +extern int afstest_AddDESKeyFile(struct afsconf_dir *dir); diff --git a/tests/common/config.c b/tests/common/config.c index 1170240..7574465 100644 --- a/tests/common/config.c +++ b/tests/common/config.c @@ -30,8 +30,11 @@ #include #include +#include #include +#include + #include "common.h" static FILE * @@ -110,3 +113,14 @@ afstest_UnlinkTestConfig(char *dir) unlinkConfigFile(dir, "UserList"); rmdir(dir); } + +int +afstest_AddDESKeyFile(struct afsconf_dir *dir) +{ + char keymaterial[]="\x19\x17\xff\xe6\xbb\x77\x2e\xfc"; + + /* Make sure that it is actually a valid key */ + DES_set_odd_parity((DES_cblock *)keymaterial); + + return afsconf_AddKey(dir, 1, keymaterial, 1); +} -- 1.9.4