d2c042d5568d94d50c5b41a0754927b6480e8fb9
2 * Copyright (C) 2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil, Switzerland
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 /* we need to fake some charon symbols to dlopen() its plugins */
23 void *charon
, *eap_type_names
, *auth_class_names
, *protocol_id_names
,
24 *action_names
, *ipsec_mode_names
, *ike_sa_state_names
, *child_sa_state_names
,
25 *policy_dir_names
, *ipcomp_transform_names
, *debug_names
, *controller_cb_empty
;
27 int main(int argc
, char* argv
[])
30 integrity_checker_t
*integrity
;
32 /* avoid confusing leak reports in build process */
33 setenv("LEAK_DETECTIVE_DISABLE", "1", 0);
35 atexit(library_deinit
);
37 integrity
= integrity_checker_create(NULL
);
40 printf(" * checksums of files and loaded code segments.\n");
41 printf(" * created by %s\n", argv
[0]);
44 printf("#include <library.h>\n");
46 printf("integrity_checksum_t checksums[] = {\n");
47 for (i
= 1; i
< argc
; i
++)
49 char *name
, *path
, *sname
= NULL
;
50 void *handle
, *symbol
;
55 if ((name
= strstr(path
, "libstrongswan-")))
57 name
= strdup(name
+ strlen("libstrongswan-"));
58 name
[strlen(name
) - 3] = '"';
59 name
[strlen(name
) - 2] = ',';
60 name
[strlen(name
) - 1] = '\0';
61 sname
= "plugin_create";
63 else if (strstr(path
, "libstrongswan.so"))
65 name
= strdup("libstrongswan\",");
66 sname
= "library_init";
68 else if (strstr(path
, "charon"))
70 name
= strdup("charon\",");
72 else if (strstr(path
, "pluto"))
74 name
= strdup("pluto\",");
78 fprintf(stderr
, "don't know how to handle '%s', ignored", path
);
82 fsum
= integrity
->build_file(integrity
, path
);
86 handle
= dlopen(path
, RTLD_LAZY
);
89 symbol
= dlsym(handle
, sname
);
92 ssum
= integrity
->build_segment(integrity
, symbol
);
96 fprintf(stderr
, "symbol lookup failed: %s\n", dlerror());
102 fprintf(stderr
, "dlopen failed: %s\n", dlerror());
105 printf("\t{\"%-20s0x%08x, 0x%08x},\n", name
, fsum
, ssum
);
110 printf("int checksum_count = countof(checksums);\n");
112 integrity
->destroy(integrity
);