portability fixes

if there is a version.h.static use that instead of output from svnversion
use get_version(), tools outside libclamav shouldn't rely on libclamav version
exception: clamconf itself needs both, and the milter shows both

git-svn: trunk@4076
0.95
Török Edvin 18 years ago
parent 945bb9a349
commit add738d28c
  1. 12
      clamav-milter/clamav-milter.c
  2. 2
      clamconf/Makefile.am
  3. 30
      clamconf/clamconf.c
  4. 4
      clamd/clamd.c
  5. 4
      clamd/session.c
  6. 10
      clamdscan/clamdscan.c
  7. 4
      clamscan/clamscan.c
  8. 4
      freshclam/freshclam.c
  9. 37
      freshclam/manager.c
  10. 18
      libclamav/Makefile.am
  11. 18
      libclamav/Makefile.in
  12. 12
      libclamav/version.c
  13. 26
      shared/misc.c
  14. 2
      shared/misc.h
  15. 2
      sigtool/sigtool.c
  16. 11
      unit_tests/check_clamav.c

@ -33,8 +33,6 @@
*/
static char const rcsid[] = "$Id: clamav-milter.c,v 1.312 2007/02/12 22:24:21 njh Exp $";
#define CM_VERSION "devel-20080219"
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
@ -628,7 +626,7 @@ int safe_res_query(const char *d, int c, int t, u_char *a, int l) {
static void
help(void)
{
printf("\n\tclamav-milter version %s\n", CM_VERSION);
printf("\n\tclamav-milter version %s\n", get_version());
puts("\tCopyright (C) 2007 Nigel Horne <njh@clamav.net>\n");
puts(_("\t--advisory\t\t-A\tFlag viruses rather than deleting them."));
@ -743,7 +741,7 @@ main(int argc, char **argv)
*/
snprintf(version, sizeof(version) - 1,
"ClamAV version %s, clamav-milter version %s",
VERSION, CM_VERSION);
cl_retver(), get_version());
progname = strrchr(argv[0], '/');
if(progname)
@ -2366,7 +2364,7 @@ pingServer(int serverNumber)
*/
snprintf(clamav_version, sizeof(clamav_version) - 1,
"%s\n\tclamav-milter version %s",
buf, CM_VERSION);
buf, get_version());
return 1;
}
@ -5844,7 +5842,7 @@ loadDatabase(void)
char buf[26];
snprintf(clamav_version, VERSION_LENGTH,
"ClamAV %s/%u/%s", VERSION, d->version,
"ClamAV %s/%u/%s", get_version(), d->version,
cli_ctime(&t, buf, sizeof(buf)));
/* Remove ctime's trailing \n */
@ -5855,7 +5853,7 @@ loadDatabase(void)
} else
snprintf(clamav_version, VERSION_LENGTH,
"ClamAV version %s, clamav-milter version %s",
VERSION, CM_VERSION);
cl_retver(), get_version());
free(daily);

@ -31,5 +31,3 @@ DEFS = @DEFS@ -DCL_NOTHREADS
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
LIBS = $(top_builddir)/libclamav/libclamav.la @THREAD_LIBS@
# it supports only --help
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=clamconf

@ -34,6 +34,7 @@
#include "shared/misc.h"
#include "libclamav/clamav.h"
#include "libclamav/version.h"
#include "cfgparser.h"
#define _GNU_SOURCE
@ -199,26 +200,38 @@ static void printdb(const char *dir, const char *db)
}
}
static void version(void)
{
printf("Clam AntiVirus Configuration Tool %s\n", get_version());
}
static void help(void)
{
printf("\n");
printf(" Clam AntiVirus: Configuration Tool "VERSION"\n");
printf(" Clam AntiVirus: Configuration Tool %s\n", get_version());
printf(" (C) 2006 - 2007 ClamAV Team - http://www.clamav.net/team\n\n");
printf(" --help -h show help\n");
printf(" --version -v show version\n");
printf(" --config-dir DIR -c DIR search for config files in DIR\n");
printf(" --non-default -n only print non-default settings\n");
printf("\n");
}
#ifndef REPO_VERSION
#define REPO_VERSION VERSION
#endif
int main(int argc, char **argv)
{
char path[1024];
struct stat sb;
int ret, opt_index, nondef = 0;
const char *getopt_parameters = "hc:n";
const char *getopt_parameters = "hVc:n";
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"version", 0, 0, 'V'},
{"config-dir", 1, 0, 'c'},
{"non-default", 0, 0, 'n'},
{0, 0, 0, 0}
@ -252,6 +265,11 @@ int main(int argc, char **argv)
nondef = 1;
break;
case 'V':
version();
free(confdir);
exit(0);
default:
printf("ERROR: Unknown option passed\n");
free(confdir);
@ -283,13 +301,13 @@ int main(int argc, char **argv)
printf("------------------------------\n");
#ifdef CL_EXPERIMENTAL
printf("Engine version: "VERSION" (with experimental code)\n");
printf("Engine version: %s (with experimental code)\n", get_version());
#else
printf("Engine version: "VERSION"\n");
printf("Engine version: %s\n", get_version());
#endif
if(strcmp(VERSION, cl_retver()))
printf("WARNING: Version mismatch: clamconf: "VERSION", libclamav: %s\n", cl_retver());
if(strcmp(REPO_VERSION, cl_retver()))
printf("WARNING: Version mismatch: clamconf: "REPO_VERSION", libclamav: %s\n", cl_retver());
printf("Database directory: ");
dbdir = freshdbdir();

@ -78,7 +78,7 @@ short foreground = 0;
static void help(void)
{
printf("\n");
printf(" Clam AntiVirus Daemon %s\n", cl_retver());
printf(" Clam AntiVirus Daemon %s\n", get_version());
printf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n");
printf(" --help -h Show this help.\n");
@ -288,7 +288,7 @@ int main(int argc, char **argv)
if(cfgopt(copt, "LeaveTemporaryFiles")->enabled)
cl_settempdir(NULL, 1);
logg("#clamd daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", cl_retver());
logg("#clamd daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", get_version());
#ifndef C_WINDOWS
if(user)

@ -171,10 +171,10 @@ int command(int desc, const struct cl_engine *engine, const struct cl_limits *li
char timestr[32];
time_t t = (time_t) daily->stime;
mdprintf(desc, "ClamAV %s/%d/%s", cl_retver(), daily->version, cli_ctime(&t, timestr, sizeof(timestr)));
mdprintf(desc, "ClamAV %s/%d/%s", get_version(), daily->version, cli_ctime(&t, timestr, sizeof(timestr)));
cl_cvdfree(daily);
} else {
mdprintf(desc, "ClamAV %s\n", cl_retver());
mdprintf(desc, "ClamAV %s\n", get_version());
}
free(path);

@ -43,17 +43,11 @@ short printinfected = 0;
extern int notremoved, notmoved;
#ifdef CL_EXPERIMENTAL
#define VERSION_EXP VERSION"-exp"
#else
#define VERSION_EXP VERSION
#endif
static void print_server_version(const struct optstruct *opt)
{
if(get_clamd_version(opt)) {
/* can't get version from server, fallback */
printf("ClamAV "VERSION_EXP"\n");
printf("ClamAV %s\n", get_version());
}
}
@ -149,7 +143,7 @@ void help(void)
mprintf_stdout = 1;
mprintf("\n");
mprintf(" ClamAV Daemon Client "VERSION"\n");
mprintf(" ClamAV Daemon Client %s\n", get_version());
mprintf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n");
mprintf(" --help -h Show help\n");

@ -246,7 +246,7 @@ int main(int argc, char **argv)
dms += (dms < 0) ? (1000000):(0);
logg("\n----------- SCAN SUMMARY -----------\n");
logg("Known viruses: %u\n", info.sigs);
logg("Engine version: %s\n", cl_retver());
logg("Engine version: %s\n", get_version());
logg("Scanned directories: %u\n", info.dirs);
logg("Scanned files: %u\n", info.files);
logg("Infected files: %u\n", info.ifiles);
@ -279,7 +279,7 @@ void help(void)
mprintf_stdout = 1;
mprintf("\n");
mprintf(" Clam AntiVirus Scanner "VERSION"\n");
mprintf(" Clam AntiVirus Scanner %s\n", get_version());
mprintf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n");
mprintf(" --help -h Print this help screen\n");

@ -117,7 +117,7 @@ static void help(void)
mprintf_stdout = 1;
mprintf("\n");
mprintf(" Clam AntiVirus: freshclam "VERSION"\n");
mprintf(" Clam AntiVirus: freshclam %s\n", get_version());
mprintf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n");
mprintf(" --help -h show help\n");
@ -511,7 +511,7 @@ int main(int argc, char **argv)
active_children = 0;
logg("#freshclam daemon "VERSION" (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n");
logg("#freshclam daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", get_version());
#ifdef C_WINDOWS
signal(SIGINT, daemon_sighandler);

@ -473,7 +473,6 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha
int bread, cnt, sd;
unsigned int i, j;
char *remotename = NULL, *authorization = NULL;
const char *agent;
struct cl_cvd *cvd;
char last_modified[36];
struct stat sb;
@ -507,23 +506,15 @@ static struct cl_cvd *remote_cvdhead(const char *file, const char *hostname, cha
logg("Reading CVD header (%s): ", file);
if(uas)
agent = uas;
else
#ifdef CL_EXPERIMENTAL
agent = PACKAGE"/"VERSION"-exp";
#else
agent = PACKAGE"/"VERSION;
#endif
snprintf(cmd, sizeof(cmd),
"GET %s/%s HTTP/1.0\r\n"
"Host: %s\r\n%s"
"User-Agent: %s\r\n"
"User-Agent: %s%s\r\n"
"Connection: close\r\n"
"Range: bytes=0-511\r\n"
"If-Modified-Since: %s\r\n"
"\r\n", (remotename != NULL) ? remotename : "", file, hostname, (authorization != NULL) ? authorization : "", agent, last_modified);
"\r\n", (remotename != NULL) ? remotename : "", file, hostname, (authorization != NULL) ? authorization : "",
uas ? uas : PACKAGE"/",uas ? "" : get_version(), last_modified);
free(remotename);
free(authorization);
@ -641,7 +632,7 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna
percentage = 0, sd;
unsigned int i;
char *remotename = NULL, *authorization = NULL, *headerline, ipaddr[16];
const char *rotation = "|/-\\", *agent;
const char *rotation = "|/-\\";
if(proxy) {
@ -659,24 +650,16 @@ static int getfile(const char *srcfile, const char *destfile, const char *hostna
}
}
if(uas)
agent = uas;
else
#ifdef CL_EXPERIMENTAL
agent = PACKAGE"/"VERSION"-exp";
#else
agent = PACKAGE"/"VERSION;
#endif
snprintf(cmd, sizeof(cmd),
"GET %s/%s HTTP/1.0\r\n"
"Host: %s\r\n%s"
"User-Agent: %s\r\n"
"User-Agent: %s%s\r\n"
#ifdef FRESHCLAM_NO_CACHE
"Cache-Control: no-cache\r\n"
#endif
"Connection: close\r\n"
"\r\n", (remotename != NULL) ? remotename : "", srcfile, hostname, (authorization != NULL) ? authorization : "", agent);
"\r\n", (remotename != NULL) ? remotename : "", srcfile, hostname, (authorization != NULL) ? authorization : "",
uas ? uas : PACKAGE"/", uas ? "" : get_version());
memset(ipaddr, 0, sizeof(ipaddr));
@ -1412,10 +1395,10 @@ int downloadmanager(const struct cfgstruct *copt, const struct optstruct *opt, c
logg("*Software version from DNS: %s\n", newver);
if(vwarning && !strstr(cl_retver(), "devel") && !strstr(cl_retver(), "rc")) {
if(strcmp(cl_retver(), newver)) {
if(vwarning && !strstr(get_version(), "devel") && !strstr(get_version(), "rc")) {
if(strcmp(get_version(), newver)) {
logg("^Your ClamAV installation is OUTDATED!\n");
logg("^Local version: %s Recommended version: %s\n", cl_retver(), newver);
logg("^Local version: %s Recommended version: %s\n", get_version(), newver);
logg("DON'T PANIC! Read http://www.clamav.net/support/faq\n");
outdated = 1;
}

@ -207,8 +207,10 @@ libclamav_la_SOURCES = \
.PHONY: version.h.tmp
version.lo: version.h
version.h: version.h.tmp
@if ! diff $@ $< >/dev/null 2>/dev/null; then\
cp $< $@;\
@if test -f version.h.static; then\
cp version.h.static version.h;\
elif ! diff $@ version.h.tmp >/dev/null 2>/dev/null; then\
cp version.h.tmp $@;\
fi
version.h.tmp:
@ -216,12 +218,16 @@ version.h.tmp:
rm -f $@;\
REVISION="$$(LANG=C svnversion "$(top_srcdir)" 2>/dev/null || echo exported)";\
if test $$REVISION = "exported"; then\
REVISION="$$(LANG=C cd "$(top_srcdir)"; git-svn info configure | awk '/Revision:/ { print $$2 }' || echo exported)";\
if test ! $$REVISION = "exported"; then\
REVISION="$$REVISION-$$(LANG=C cd "$(top_srcdir)"; git-describe --always)";\
REVISION="$$(LANG=C cd "$(top_srcdir)"; git-svn info configure 2>/dev/null| awk '/Revision:/ { print $$2 }' || echo)";\
if test -n "$$REVISION"; then\
REVISION="$$REVISION-$$(LANG=C cd "$(top_srcdir)"; git-describe --always 2>/dev/null)";\
fi;\
fi;\
echo "#define REPO_VERSION \"devel-r$$REVISION\"" >> $@
if test -n "$$REVISION"; then\
echo "#define REPO_VERSION \"devel-r$$REVISION\"" >> $@;\
else\
touch version.h.tmp;\
fi
libclamav_internal_utils_la_SOURCES=str.c \
str.h \

@ -1036,8 +1036,10 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
.PHONY: version.h.tmp
version.lo: version.h
version.h: version.h.tmp
@if ! diff $@ $< >/dev/null 2>/dev/null; then\
cp $< $@;\
@if test -f version.h.static; then\
cp version.h.static version.h;\
elif ! diff $@ version.h.tmp >/dev/null 2>/dev/null; then\
cp version.h.tmp $@;\
fi
version.h.tmp:
@ -1045,12 +1047,16 @@ version.h.tmp:
rm -f $@;\
REVISION="$$(LANG=C svnversion "$(top_srcdir)" 2>/dev/null || echo exported)";\
if test $$REVISION = "exported"; then\
REVISION="$$(LANG=C cd "$(top_srcdir)"; git-svn info configure | awk '/Revision:/ { print $$2 }' || echo exported)";\
if test ! $$REVISION = "exported"; then\
REVISION="$$REVISION-$$(LANG=C cd "$(top_srcdir)"; git-describe --always)";\
REVISION="$$(LANG=C cd "$(top_srcdir)"; git-svn info configure 2>/dev/null| awk '/Revision:/ { print $$2 }' || echo)";\
if test -n "$$REVISION"; then\
REVISION="$$REVISION-$$(LANG=C cd "$(top_srcdir)"; git-describe --always 2>/dev/null)";\
fi;\
fi;\
echo "#define REPO_VERSION \"devel-r$$REVISION\"" >> $@
if test -n "$$REVISION"; then\
echo "#define REPO_VERSION \"devel-r$$REVISION\"" >> $@;\
else\
touch version.h.tmp;\
fi
@MAINTAINER_MODE_TRUE@jsparse-keywords.gperf: jsparse/keywords.list jsparse/future_reserved_words.list jsparse/special_keywords.list
@MAINTAINER_MODE_TRUE@ echo -e "struct keyword { const char *name; int val; };\n%%" >keywords-g-tmp

@ -2,12 +2,14 @@
#include "clamav-config.h"
#endif
#include "version.h"
#include <string.h>
#ifndef REPO_VERSION
#define REPO_VERSION VERSION
#endif
/* libclamav's version is always the SVN revision (if available) */
const char *cl_retver(void)
{
if(!strncmp("devel-",VERSION,6) && strcmp("exported",REPO_VERSION)) {
return REPO_VERSION;
}
/* it is a release, or we have nothing better */
return VERSION;
return REPO_VERSION;
}

@ -43,6 +43,7 @@
#include "libclamav/cvd.h"
#include "libclamav/others.h" /* for cli_rmdirs() */
#include "libclamav/regex/regex.h"
#include "libclamav/version.h"
#include "shared/misc.h"
#ifndef O_BINARY
@ -55,6 +56,24 @@
#define EXP ""
#endif
#ifndef REPO_VERSION
#define REPO_VERSION "exported"
#endif
#ifdef CL_EXPERIMENTAL
#define EXP_VER "-exp"
#else
#define EXP_VER
#endif
const char *get_version(void)
{
if(!strncmp("devel-",VERSION,6) && strcmp("exported",REPO_VERSION)) {
return REPO_VERSION""EXP_VER;
}
/* it is a release, or we have nothing better */
return VERSION""EXP_VER;
}
/* CL_NOLIBCLAMAV means to omit functions that depends on libclamav */
#ifndef CL_NOLIBCLAMAV
char *freshdbdir(void)
@ -106,6 +125,7 @@ char *freshdbdir(void)
return retdir;
}
void print_version(const char *dbdir)
{
char *fdbdir, *path;
@ -119,7 +139,7 @@ void print_version(const char *dbdir)
pt = fdbdir = freshdbdir();
if(!pt) {
printf("ClamAV %s"EXP"\n",cl_retver());
printf("ClamAV %s"EXP"\n",get_version());
return;
}
@ -139,10 +159,10 @@ void print_version(const char *dbdir)
if(!access(path, R_OK) && (daily = cl_cvdhead(path))) {
time_t t = (time_t) daily->stime;
printf("ClamAV %s"EXP"/%d/%s", cl_retver(), daily->version, ctime(&t));
printf("ClamAV %s"EXP"/%d/%s", get_version(), daily->version, ctime(&t));
cl_cvdfree(daily);
} else {
printf("ClamAV %s"EXP"\n",cl_retver());
printf("ClamAV %s"EXP"\n",get_version());
}
free(path);

@ -38,5 +38,5 @@ int filecopy(const char *src, const char *dest);
int dircopy(const char *src, const char *dest);
int cvd_unpack(const char *cvd, const char *destdir);
int daemonize(void);
const char *get_version(void);
#endif

@ -1696,7 +1696,7 @@ static int makediff(struct optstruct *opt)
static void help(void)
{
mprintf("\n");
mprintf(" Clam AntiVirus: Signature Tool (sigtool) "VERSION"\n");
mprintf(" Clam AntiVirus: Signature Tool (sigtool) %s\n", get_version());
mprintf(" (C) 2002 - 2007 ClamAV Team - http://www.clamav.net/team\n\n");
mprintf(" --help -h show help\n");

@ -70,13 +70,16 @@ START_TEST (test_cl_retdbdir)
fail_unless(!strcmp(DATADIR, cl_retdbdir()), "cl_retdbdir");
END_TEST
#ifndef REPO_VERSION
#define REPO_VERSION VERSION
#endif
/* extern const char *cl_retver(void); */
START_TEST (test_cl_retver)
const char *ver = cl_retver();
if(strstr(VERSION,"devel"))
fail_unless(!strcmp(REPO_VERSION, ver),"cl_retver");
else
fail_unless(!strcmp(VERSION, ver),"cl_retver");
fail_unless(!strcmp(REPO_VERSION, ver),"cl_retver");
fail_unless(strcspn(ver,"012345789") < strlen(ver),
"cl_retver must have a number");
END_TEST
/* extern void cl_cvdfree(struct cl_cvd *cvd); */

Loading…
Cancel
Save