#include <roken.h>
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
#ifdef IGNORE_SOME_GCC_WARNINGS
# pragma GCC diagnostic warning "-Wdeprecated-declarations"
#endif
#include <tap/basic.h>
#include "test.h"
+#include "common.h"
#define TEST_PORT 1234
/* Now, what happens if we're doing something over the network instead */
+ code = rx_Init(0);
+ is_int(code, 0, "Initialised RX");
+
/* Fake up an rx ticket. Note that this will be for the magic 'superuser' */
code = afsconf_ClientAuth(dir, &class, &classIndex);
is_int(code, 0, "Can successfully create superuser token");
/* Start a connection to our test service with it */
- code = rx_Init(0);
- is_int(code, 0, "Started RX");
-
he = gethostbyname("localhost");
if (!he) {
printf("Couldn't look up server hostname");
exit(1);
}
- afsconf_BuildServerSecurityObjects(globalDir, 0, &classes, &numClasses);
+ afsconf_BuildServerSecurityObjects(globalDir, &classes, &numClasses);
service = rx_NewService(0, TEST_SERVICE_ID, "test", classes, numClasses,
TEST_ExecuteRequest);
if (service == NULL) {
int main(int argc, char **argv)
{
struct afsconf_dir *dir;
- char buffer[1024];
+ char *dirname;
int serverPid, clientPid, waited, stat;
char keymaterial[]="\x19\x17\xff\xe6\xbb\x77\x2e\xfc";
- char *dirEnd;
- FILE *file;
int code;
/* Start the client and the server if requested */
/* Otherwise, do the basic configuration, then start the client and
* server */
- snprintf(buffer, sizeof(buffer), "%s/afs_XXXXXX", gettmpdir());
- mkdtemp(buffer);
- dirEnd = buffer + strlen(buffer);
-
- /* Create a CellServDB file */
- strcpy(dirEnd, "/CellServDB");
- file = fopen(buffer, "w");
- fprintf(file, ">example.org # An example cell\n");
- fprintf(file, "127.0.0.1 #test.example.org\n");
- fclose(file);
-
- /* Create a ThisCell file */
- strcpy(dirEnd, "/ThisCell");
- file = fopen(buffer, "w");
- fprintf(file, "example.org\n");
- fclose(file);
-
- *dirEnd='\0';
- /* Start with a blank configuration directory */
- dir = afsconf_Open(strdup(buffer));
+ dirname = buildTestConfig();
+
+ dir = afsconf_Open(dirname);
if (dir == NULL) {
fprintf(stderr, "Unable to configure directory.\n");
exit(1);
exit(1);
}
- printf("Config directory is %s\n", buffer);
+ printf("Config directory is %s\n", dirname);
serverPid = fork();
if (serverPid == -1) {
/* Bang */
} else if (serverPid == 0) {
- execl(argv[0], argv[0], "-server", buffer, NULL);
+ execl(argv[0], argv[0], "-server", dirname, NULL);
exit(1);
}
clientPid = fork();
waitpid(serverPid, &stat, 0);
exit(1);
} else if (clientPid == 0) {
- execl(argv[0], argv[0], "-client", buffer, NULL);
+ execl(argv[0], argv[0], "-client", dirname, NULL);
}
do {
/* Client and server are both done, so cleanup after everything */
- strcpy(dirEnd, "/KeyFile");
- unlink(buffer);
- strcpy(dirEnd, "/CellServDB");
- unlink(buffer);
- strcpy(dirEnd, "/ThisCell");
- unlink(buffer);
- strcpy(dirEnd, "/UserList");
- unlink(buffer);
- *dirEnd='\0';
- rmdir(buffer);
+ /* unlinkTestConfig(dirname); */
return 0;
}