X-Git-Url: https://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=tests%2Fcommon%2Fconfig.c;h=8f143b4172d24f0b49c8c34715b2eecf8a443624;hp=1170240dddaa440924a66d8fdbfc700154dfa466;hb=34afb3e6b903fc1659b1c869fa2fb4226038e076;hpb=799b3373ecfeebf790d71c6e5bf60b0845519b2d diff --git a/tests/common/config.c b/tests/common/config.c index 1170240..8f143b4 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 * @@ -71,6 +74,9 @@ char * afstest_BuildTestConfig(void) { char *dir = NULL; FILE *file; + struct hostent *host; + char hostname[255]; + struct in_addr iaddr; if (asprintf(&dir, "%s/afs_XXXXXX", gettmpdir()) == -1) goto fail; @@ -78,10 +84,20 @@ afstest_BuildTestConfig(void) { if (mkdtemp(dir) == NULL) goto fail; - /* Create a CellServDB */ + /* Work out which IP address to use in our CellServDB. We figure this out + * according to the IP address which ubik is most likely to pick for one of + * our db servers */ + + gethostname(hostname, sizeof(hostname)); + host = gethostbyname(hostname); + if (!host) + return NULL; + + memcpy(&iaddr, host->h_addr, 4); + file = openConfigFile(dir, "CellServDB"); fprintf(file, ">example.org # An example cell\n"); - fprintf(file, "127.0.0.1 #test.example.org\n"); + fprintf(file, "%s #test.example.org\n", inet_ntoa(iaddr)); fclose(file); /* Create a ThisCell file */ @@ -110,3 +126,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); +}