214
static void print_platform(struct cli_environment *env)
216
printf("\nPlatform information\n--------------------\n");
217
printf("uname: %s %s %s %s\n",
218
env->sysname, env->release, env->version, env->machine);
220
printf("OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE"\n");
223
if (!access("/usr/bin/lsb_release", X_OK)) {
224
fputs("Full OS version: ", stdout);
226
if (system("/usr/bin/lsb_release -d -s") == -1) {
227
perror("failed to determine");
232
if (!access("/etc/release", R_OK)) {
234
FILE *f = fopen("/etc/release", "r");
235
fgets(buf, sizeof(buf), f);
236
printf("Full OS version: %s", buf);
241
printf("zlib version: %s (%s), compile flags: %02lx\n",
242
ZLIB_VERSION, zlibVersion(), zlibCompileFlags());
244
/* old zlib w/o zlibCompileFlags() */
245
printf("zlib version: %s (%s)\n",
246
ZLIB_VERSION, zlibVersion());
249
printf("Triple: %s\n", env->triple);
251
printf("CPU: %s, %s\n", env->cpu, env->big_endian ? "Big-endian" : "Little-endian");
252
printf("platform id: 0x%08x%08x%08x\n",
258
static void print_build(struct cli_environment *env)
261
const char *version = NULL;
262
printf("\nBuild information\n-----------------\n");
263
/* Try to print information about some commonly used compilers */
265
version = __VERSION__;
267
switch (env->compiler) {
278
name = "Intel Compiler";
281
name = "Microsoft Visual C++";
290
printf("%s: %s%s(%u.%u.%u)\n", name,
291
version ? version : "",
293
env->c_version >> 16,
294
(env->c_version >> 8)&0xff,
295
(env->c_version)&0xff);
297
#if defined(BUILD_CPPFLAGS) && defined(BUILD_CFLAGS) && defined(BUILD_CXXFLAGS) && defined(BUILD_LDFLAGS) && defined(BUILD_CONFIGURE_FLAGS)
298
printf("CPPFLAGS: %s\nCFLAGS: %s\nCXXFLAGS: %s\nLDFLAGS: %s\nConfigure: %s\n",
299
BUILD_CPPFLAGS, BUILD_CFLAGS, BUILD_CXXFLAGS, BUILD_LDFLAGS,
300
BUILD_CONFIGURE_FLAGS);
302
printf("sizeof(void*) = %d\n", env->sizeof_ptr);
303
printf("Engine flevel: %d, dconf: %d\n",
304
env->functionality_level,
308
static void print_dbs(const char *dir)
313
unsigned int flevel = cl_retflevel(), cnt, sigs = 0;
316
if((dd = opendir(dir)) == NULL) {
317
printf("print_dbs: Can't open directory %s\n", dir);
321
while((dent = readdir(dd))) {
323
if(CLI_DBEXT(dent->d_name)) {
324
dbfile = (char *) malloc(strlen(dent->d_name) + strlen(dir) + 2);
326
printf("print_dbs: Can't allocate memory for dbfile\n");
329
sprintf(dbfile, "%s"PATHSEP"%s", dir, dent->d_name);
330
if(cli_strbcasestr(dbfile, ".cvd") || cli_strbcasestr(dbfile, ".cld")) {
331
cvd = cl_cvdhead(dbfile);
333
printf("%s: Can't get information about the database\n", dbfile);
335
const time_t t = cvd->stime;
336
printf("%s: version %u, sigs: %u, built on %s", dent->d_name, cvd->version, cvd->sigs, ctime(&t));
339
printf("%s: WARNING: This database requires f-level %u (current f-level: %u)\n", dent->d_name, cvd->fl, flevel);
342
} else if(cli_strbcasestr(dbfile, ".cbc")) {
343
printf("[3rd Party] %s: bytecode\n", dent->d_name);
346
cnt = countlines(dbfile);
347
printf("[3rd Party] %s: %u sig%c\n", dent->d_name, cnt, cnt > 1 ? 's' : ' ');
355
printf("Total number of signatures: %u\n", sigs);
208
358
int main(int argc, char **argv)
211
char path[512], dbdir[512], *pt;
361
char path[512], dbdir[512], clamd_dbdir[512], *pt;
212
362
struct optstruct *opts, *toolopts;
213
363
const struct optstruct *opt;
214
364
unsigned int i, j;
365
struct cli_environment env;
219
368
opts = optparse(NULL, argc, argv, 1, OPT_CLAMCONF, 0, NULL);
311
464
dbdir[sizeof(dbdir) - 1] = 0;
467
printf("\nDatabase information\n--------------------\n");
313
468
printf("Database directory: %s\n", dbdir);
314
flevel = cl_retflevel();
315
for(i = 0; dbnames[i]; i++) {
316
snprintf(path, sizeof(path), "%s"PATHSEP"%s", dbdir, dbnames[i]);
318
if(!access(path, R_OK)) {
319
cvd = cl_cvdhead(path);
321
printf("%s: Can't get information about the database\n", dbnames[i]);
323
const time_t t = cvd->stime;
324
printf("%s: version %u, sigs: %u, built on %s", dbnames[i], cvd->version, cvd->sigs, ctime(&t));
326
printf("%s: WARNING: This database requires f-level %u (current f-level: %u)\n", dbnames[i], cvd->fl, flevel);
469
if(strcmp(dbdir, clamd_dbdir))
470
printf("WARNING: freshclam.conf and clamd.conf point to different database directories\n");
473
cli_detect_environment(&env);
474
print_platform(&env);