1 /* This is a simple program which originally produced the KeyFile used
2 * by the test suite. The contents of that file shouldn't be regenerated,
3 * though, as the purpose of the tests using that file is to ensure that we
4 * can still read old KeyFiles.
9 #include <afs/cellconfig.h>
10 #include <afs/afsutil.h>
15 main(int argc
, char **argv
)
17 struct afsconf_dir
*dir
;
26 snprintf(buffer
, sizeof(buffer
), "%s/afs_XXXXXX", gettmpdir());
28 dirEnd
= buffer
+ strlen(buffer
);
30 /* Create a CellServDB file */
31 strcpy(dirEnd
, "/CellServDB");
32 file
= fopen(buffer
, "w");
33 fprintf(file
, ">example.org # An example cell\n");
34 fprintf(file
, "127.0.0.1 #test.example.org\n");
37 /* Create a ThisCell file */
38 strcpy(dirEnd
, "/ThisCell");
39 file
= fopen(buffer
, "w");
40 fprintf(file
, "example.org\n");
44 dir
= afsconf_Open(strdup(buffer
));
46 fprintf(stderr
, "Unable to open configuration directory\n");
50 afsconf_AddKey(dir
, 1, "\x01\x02\x04\x08\x10\x20\x40\x80", 1);
51 afsconf_AddKey(dir
, 2, "\x04\x04\x04\x04\x04\x04\x04\x04", 1);
52 afsconf_AddKey(dir
, 4, "\x19\x16\xfe\xe6\xba\x77\x2f\xfd", 1);
56 /* Copy out the resulting keyfile into our homedirectory */
57 strcpy(dirEnd
, "/KeyFile");
58 in
= open(buffer
, O_RDONLY
);
59 out
= open("KeyFile", O_WRONLY
| O_CREAT
, 0644);
63 len
= read(in
, block
, 1024);
65 write(out
, block
, len
);
69 fprintf(stderr
, "I/O error whilst copying file\n");
76 strcpy(dirEnd
, "/KeyFile");
78 strcpy(dirEnd
, "/CellServDB");
80 strcpy(dirEnd
, "/ThisCell");
82 strcpy(dirEnd
, "/UserList");