--list-sigs

git-svn: trunk@194
remotes/push_mirror/metadata
Tomasz Kojm 22 years ago
parent 8113138143
commit 0a2ad257a3
  1. 6
      clamav-devel/ChangeLog
  2. 2
      clamav-devel/clamd/cfgfile.c
  3. 2
      clamav-devel/clamd/localserver.c
  4. 9
      clamav-devel/clamd/server-th.c
  5. 2
      clamav-devel/clamd/tcpserver.c
  6. 2
      clamav-devel/etc/clamav.conf
  7. 2
      clamav-devel/libclamav/readdb.c
  8. 3
      clamav-devel/sigtool/options.c
  9. 196
      clamav-devel/sigtool/sigtool.c

@ -1,3 +1,9 @@
Wed Jan 21 09:38:01 CET 2004 (tk)
---------------------------------
* sigtool: --list-sigs: list virus signature names from all databases.
Optionally it can list signatures from selected database
(--list-sigs=/path/to/database)
Tue Jan 20 11:34:38 CET 2004 (tk)
---------------------------------
* clamd: new commands: SESSION, END: SESSION starts a clamd session and

@ -61,7 +61,7 @@ struct cfgstruct *parsecfg(const char *cfgfile)
{"MaxConnectionQueueLength", OPT_NUM},
{"StreamSaveToDisk", OPT_NOARG},
{"StreamMaxLength", OPT_COMPSIZE},
{"UseProcessess", OPT_NOARG},
{"UseProcesses", OPT_NOARG},
{"MaxThreads", OPT_NUM},
{"ThreadTimeout", OPT_NUM},
{"MaxDirectoryRecursion", OPT_NUM},

@ -96,7 +96,7 @@ int localserver(const struct optstruct *opt, const struct cfgstruct *copt, struc
exit(1);
}
if(cfgopt(copt, "UseProcessess"))
if(cfgopt(copt, "UseProcesses"))
acceptloop_proc(sockfd, root, copt);
else
acceptloop_th(sockfd, root, copt);

@ -75,16 +75,19 @@ void *threadscanner(void *arg)
void *threadwatcher(void *arg)
{
struct thrwarg *thwarg = (struct thrwarg *) arg;
struct thrarg *tharg;
pthread_attr_t thattr;
struct cfgstruct *cpt;
sigset_t sigset;
int i, j, ret, maxwait, virnum;
int i, j, ret, virnum;
unsigned long int timer = 0;
unsigned int timeout, threads, selfchk;
short int need_wait = 0, do_loop = 0, db_problem = 0;
const char *dbdir;
struct cl_stat dbstat;
#ifdef CLAMUKO
struct thrarg *tharg;
pthread_attr_t thattr;
int maxwait;
#endif
/* ignore all signals (except for SIGSEGV) */

@ -95,7 +95,7 @@ int tcpserver(const struct optstruct *opt, const struct cfgstruct *copt, struct
exit(1);
}
if(cfgopt(copt, "UseProcessess"))
if(cfgopt(copt, "UseProcesses"))
acceptloop_proc(sockfd, root, copt);
else
acceptloop_th(sockfd, root, copt);

@ -76,7 +76,7 @@ LocalSocket /tmp/clamd
#StreamMaxLength 10M
# Use processes instead of threads (thread directives apply to processes too)
#UseProcessess
#UseProcesses
# Maximal number of a threads running at the same time.
# Default is 5, and it should be sufficient for a typical workstation.

@ -94,7 +94,7 @@ int cl_loaddb(const char *filename, struct cl_node **root, int *virnum)
return CL_EMEM;
memset(buffer, 0, FILEBUFF);
/* check for CVD file */
/* test for CVD file */
fgets(buffer, 12, fd);
rewind(fd);

@ -38,7 +38,7 @@ int main(int argc, char **argv)
int ret, opt_index, i, len;
struct optstruct *opt;
const char *getopt_parameters = "hvVc:s:f:b:i:u:";
const char *getopt_parameters = "hvVc:s:f:b:i:u:l";
static struct option long_options[] = {
{"help", 0, 0, 'h'},
@ -57,6 +57,7 @@ int main(int argc, char **argv)
{"unpack", 1, 0, 'u'},
{"unpack-current", 1, 0, 0},
{"info", 1, 0, 'i'},
{"list-sigs", 2, 0, 0},
{0, 0, 0, 0}
};

@ -32,6 +32,7 @@
#include <arpa/inet.h>
#include <clamav.h>
#include <sys/wait.h>
#include <dirent.h>
#include "options.h"
#include "others.h"
@ -51,6 +52,10 @@ char *getdsig(const char *host, const char *user, const char *data);
void cvdinfo(struct optstruct *opt);
int build(struct optstruct *opt);
int unpack(struct optstruct *opt);
int listdb(const char *filename);
int listdir(const char *dirname);
void listsigs(struct optstruct *opt);
int cli_rmdirs(const char *dirname); /* libclamav's internal */
int scanfile(const char *cmd, const char *str, const char *file)
{
@ -215,10 +220,14 @@ void sigtool(struct optstruct *opt)
cvdinfo(opt);
} else if(optl(opt, "list-sigs")) {
listsigs(opt);
} else {
int jmp, lastjmp, end, found = 0, exec = 0, pos, filesize,
int jmp, lastjmp = 0, end, found = 0, exec = 0, pos, filesize,
maxsize = 0, ret;
char *c, *s, *f, *tmp, *signame, *bsigname, *f2;
char *c, *s, *f, *tmp, *signame, *bsigname, *f2 = NULL;
FILE *fd, *wd;
if(!optc(opt, 'c')) {
@ -608,7 +617,7 @@ int build(struct optstruct *opt)
/* builder - question */
fflush(stdin);
mprintf("Builder id: ");
fscanf(stdin, "%s", &smbuff);
fscanf(stdin, "%s", smbuff);
/* digital signature */
fd = fopen(gzfile, "rb");
@ -705,7 +714,7 @@ void help(void)
{
mprintf("\n");
mprintf(" Clam AntiVirus: Signature Tool (sigtool) "VERSION"\n");
mprintf(" (c) 2002, 2003 Tomasz Kojm <tkojm@clamav.net>\n\n");
mprintf(" (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>\n\n");
mprintf(" --help -h show help\n");
mprintf(" --version -V print version number and exit\n");
@ -723,6 +732,7 @@ void help(void)
mprintf(" --server=ADDR ClamAV Signing Service address\n");
mprintf(" --unpack=FILE -u FILE Unpack a CVD file\n");
mprintf(" --unpack-current=NAME Unpack local CVD\n");
mprintf(" --list-sigs[=FILE] List virus signatures\n");
mprintf("\n");
exit(0);
@ -821,3 +831,181 @@ int unpack(struct optstruct *opt)
fclose(fd);
exit(0);
}
int listdb(const char *filename)
{
FILE *fd, *tmpd;
char *buffer, *pt, *start, *dir, *tmp;
int line = 0, bytes;
const char *tmpdir;
if((fd = fopen(filename, "rb")) == NULL) {
mprintf("!listdb(): Can't open file %s\n", filename);
return -1;
}
if(!(buffer = (char *) mmalloc(FILEBUFF))) {
mprintf("!listdb(): Can't allocate memory.\n");
return -1;
}
memset(buffer, 0, FILEBUFF);
/* check for CVD file */
fgets(buffer, 12, fd);
rewind(fd);
if(!strncmp(buffer, "ClamAV-VDB:", 11)) {
fseek(fd, 512, SEEK_SET);
tmpdir = getenv("TMPDIR");
if(tmpdir == NULL)
#ifdef P_tmpdir
tmpdir = P_tmpdir;
#else
tmpdir = "/tmp";
#endif
dir = cl_gentemp(tmpdir);
if(mkdir(dir, 0700)) {
mprintf("!listdb(): Can't create temporary directory %s\n", dir);
free(buffer);
fclose(fd);
return -1;
}
/* FIXME: it seems there is some problem with current position indicator
* after gzdopen() call in cli_untgz(). Temporarily we need this wrapper:
*/
/* start */
tmp = cl_gentemp(tmpdir);
if((tmpd = fopen(tmp, "wb+")) == NULL) {
mprintf("!listdb(): Can't create temporary file %s\n", tmp);
free(dir);
free(tmp);
free(buffer);
fclose(fd);
return -1;
}
while((bytes = fread(buffer, 1, FILEBUFF, fd)) > 0)
fwrite(buffer, 1, bytes, tmpd);
free(buffer);
fclose(fd);
fflush(tmpd);
fseek(tmpd, 0L, SEEK_SET);
if(cli_untgz(fileno(tmpd), dir)) {
mprintf("!listdb(): Can't unpack CVD file.\n");
cli_rmdirs(dir);
free(dir);
unlink(tmp);
free(tmp);
free(buffer);
return -1;
}
fclose(tmpd);
unlink(tmp);
free(tmp);
/* wrapper end */
/* list extracted directory */
listdir(dir);
cli_rmdirs(dir);
free(dir);
return 0;
}
/* old style database */
while(fgets(buffer, FILEBUFF, fd)) {
line++;
pt = strchr(buffer, '=');
if(!pt) {
mprintf("!listdb(): Malformed pattern line %d (file %s).\n", line, filename);
fclose(fd);
free(buffer);
return -1;
}
start = buffer;
*pt = 0;
if((pt = strstr(start, " (Clam)")))
*pt = 0;
mprintf("%s\n", start);
}
fclose(fd);
free(buffer);
return 0;
}
int listdir(const char *dirname)
{
DIR *dd;
struct dirent *dent;
char *dbfile;
if((dd = opendir(dirname)) == NULL) {
mprintf("!Can't open directory %s\n", dirname);
return -1;
}
while((dent = readdir(dd))) {
if(dent->d_ino) {
if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..") &&
(cli_strbcasestr(dent->d_name, ".db") ||
cli_strbcasestr(dent->d_name, ".db2") ||
cli_strbcasestr(dent->d_name, ".cvd"))) {
dbfile = (char *) mcalloc(strlen(dent->d_name) + strlen(dirname) + 2, sizeof(char));
if(!dbfile) {
mprintf("!listdir(): Can't allocate memory.\n");
closedir(dd);
return -1;
}
sprintf(dbfile, "%s/%s", dirname, dent->d_name);
if(listdb(dbfile)) {
mprintf("!listdb(): error listing database %s\n", dbfile);
free(dbfile);
closedir(dd);
return -1;
}
free(dbfile);
}
}
}
closedir(dd);
return 0;
}
void listsigs(struct optstruct *opt)
{
int ret;
const char *name;
mprintf_stdout = 1;
if((name = getargl(opt, "list-sigs")))
ret = listdb(name);
else
ret = listdir(cl_retdbdir());
return ret ? exit(1) : exit(0);
}

Loading…
Cancel
Save