Browse code

update

git-svn: trunk@595

Tomasz Kojm authored on 2004/06/06 10:50:08
Showing 27 changed files
... ...
@@ -1,3 +1,13 @@
1
+Sun Jun  6 03:38:08 CEST 2004 (tk)
2
+----------------------------------
3
+  * clamscan, freshclam, clamd: make sure privileges are properly dropped
4
+    (problem on system with CAP_SETUID disabled reported by Tuomas Silen
5
+    <tuomas.silen*nodeta.fi>)
6
+  * Makefiles: prevent linking against old libclamav versions (patch (from PLD)
7
+	       submitted by Oden Eriksson <oeriksson*mandrakesoft.com>)
8
+  * configure: support pkg-config and clamav-config (patch by Scott Beck
9
+	       <sbeck*gossamer-threads.com>)
10
+
1 11
 Thu Jun  3 17:53:45 CEST 2004 (tk)
2 12
 ----------------------------------
3 13
   * doc: update
... ...
@@ -16,4 +16,10 @@
16 16
 #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
 
18 18
 SUBDIRS = libclamav clamscan clamd clamdscan freshclam sigtool database docs etc clamav-milter
19
-EXTRA_DIST = FAQ contrib test examples BUGS shared
19
+EXTRA_DIST = FAQ contrib test examples BUGS shared libclamav.pc.in
20
+
21
+bin_SCRIPTS=clamav-config
22
+
23
+pkgconfigdir = $(libdir)/pkgconfig
24
+pkgconfig_DATA = libclamav.pc
25
+
... ...
@@ -118,13 +118,22 @@ am__quote = @am__quote@
118 118
 install_sh = @install_sh@
119 119
 
120 120
 SUBDIRS = libclamav clamscan clamd clamdscan freshclam sigtool database docs etc clamav-milter
121
-EXTRA_DIST = FAQ contrib test examples BUGS shared
121
+EXTRA_DIST = FAQ contrib test examples BUGS shared libclamav.pc.in
122
+
123
+bin_SCRIPTS = clamav-config
124
+
125
+pkgconfigdir = $(libdir)/pkgconfig
126
+pkgconfig_DATA = libclamav.pc
122 127
 subdir = .
123 128
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
124 129
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
125 130
 CONFIG_HEADER = clamav-config.h
126
-CONFIG_CLEAN_FILES =
131
+CONFIG_CLEAN_FILES = clamav-config libclamav.pc
132
+SCRIPTS = $(bin_SCRIPTS)
133
+
127 134
 DIST_SOURCES =
135
+DATA = $(pkgconfig_DATA)
136
+
128 137
 
129 138
 RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \
130 139
 	uninstall-info-recursive all-recursive install-data-recursive \
... ...
@@ -132,8 +141,9 @@ RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \
132 132
 	uninstall-recursive check-recursive installcheck-recursive
133 133
 DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
134 134
 	Makefile.in NEWS TODO acinclude.m4 aclocal.m4 \
135
-	clamav-config.h.in config.guess config.sub configure \
136
-	configure.in depcomp install-sh ltmain.sh missing mkinstalldirs
135
+	clamav-config.h.in clamav-config.in config.guess config.sub \
136
+	configure configure.in depcomp install-sh libclamav.pc.in \
137
+	ltmain.sh missing mkinstalldirs
137 138
 DIST_SUBDIRS = $(SUBDIRS)
138 139
 all: clamav-config.h
139 140
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
... ...
@@ -169,6 +179,31 @@ $(srcdir)/clamav-config.h.in:  $(top_srcdir)/configure.in $(ACLOCAL_M4)
169 169
 
170 170
 distclean-hdr:
171 171
 	-rm -f clamav-config.h
172
+clamav-config: $(top_builddir)/config.status clamav-config.in
173
+	cd $(top_builddir) && $(SHELL) ./config.status $@
174
+libclamav.pc: $(top_builddir)/config.status libclamav.pc.in
175
+	cd $(top_builddir) && $(SHELL) ./config.status $@
176
+install-binSCRIPTS: $(bin_SCRIPTS)
177
+	@$(NORMAL_INSTALL)
178
+	$(mkinstalldirs) $(DESTDIR)$(bindir)
179
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
180
+	  f="`echo $$p|sed '$(transform)'`"; \
181
+	  if test -f $$p; then \
182
+	    echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/$$f"; \
183
+	    $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/$$f; \
184
+	  elif test -f $(srcdir)/$$p; then \
185
+	    echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/$$f"; \
186
+	    $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/$$f; \
187
+	  else :; fi; \
188
+	done
189
+
190
+uninstall-binSCRIPTS:
191
+	@$(NORMAL_UNINSTALL)
192
+	@list='$(bin_SCRIPTS)'; for p in $$list; do \
193
+	  f="`echo $$p|sed '$(transform)'`"; \
194
+	  echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
195
+	  rm -f $(DESTDIR)$(bindir)/$$f; \
196
+	done
172 197
 
173 198
 mostlyclean-libtool:
174 199
 	-rm -f *.lo
... ...
@@ -179,6 +214,24 @@ clean-libtool:
179 179
 distclean-libtool:
180 180
 	-rm -f libtool
181 181
 uninstall-info-am:
182
+pkgconfigDATA_INSTALL = $(INSTALL_DATA)
183
+install-pkgconfigDATA: $(pkgconfig_DATA)
184
+	@$(NORMAL_INSTALL)
185
+	$(mkinstalldirs) $(DESTDIR)$(pkgconfigdir)
186
+	@list='$(pkgconfig_DATA)'; for p in $$list; do \
187
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
188
+	  f="`echo $$p | sed -e 's|^.*/||'`"; \
189
+	  echo " $(pkgconfigDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgconfigdir)/$$f"; \
190
+	  $(pkgconfigDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgconfigdir)/$$f; \
191
+	done
192
+
193
+uninstall-pkgconfigDATA:
194
+	@$(NORMAL_UNINSTALL)
195
+	@list='$(pkgconfig_DATA)'; for p in $$list; do \
196
+	  f="`echo $$p | sed -e 's|^.*/||'`"; \
197
+	  echo " rm -f $(DESTDIR)$(pkgconfigdir)/$$f"; \
198
+	  rm -f $(DESTDIR)$(pkgconfigdir)/$$f; \
199
+	done
182 200
 
183 201
 # This directory's subdirectories are mostly independent; you can cd
184 202
 # into them and run `make' without going through this Makefile.
... ...
@@ -291,6 +344,7 @@ distcleancheck_listfiles = find . -type f -print
291 291
 distdir: $(DISTFILES)
292 292
 	$(am__remove_distdir)
293 293
 	mkdir $(distdir)
294
+	$(mkinstalldirs) $(distdir)/.
294 295
 	@for file in $(DISTFILES); do \
295 296
 	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
296 297
 	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
... ...
@@ -378,9 +432,10 @@ distcleancheck: distclean
378 378
 	       exit 1; } >&2
379 379
 check-am: all-am
380 380
 check: check-recursive
381
-all-am: Makefile clamav-config.h
381
+all-am: Makefile $(SCRIPTS) $(DATA) clamav-config.h
382 382
 installdirs: installdirs-recursive
383 383
 installdirs-am:
384
+	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(pkgconfigdir)
384 385
 
385 386
 install: install-recursive
386 387
 install-exec: install-exec-recursive
... ...
@@ -423,9 +478,9 @@ info: info-recursive
423 423
 
424 424
 info-am:
425 425
 
426
-install-data-am:
426
+install-data-am: install-pkgconfigDATA
427 427
 
428
-install-exec-am:
428
+install-exec-am: install-binSCRIPTS
429 429
 
430 430
 install-info: install-info-recursive
431 431
 
... ...
@@ -441,7 +496,8 @@ mostlyclean: mostlyclean-recursive
441 441
 
442 442
 mostlyclean-am: mostlyclean-generic mostlyclean-libtool
443 443
 
444
-uninstall-am: uninstall-info-am
444
+uninstall-am: uninstall-binSCRIPTS uninstall-info-am \
445
+	uninstall-pkgconfigDATA
445 446
 
446 447
 uninstall-info: uninstall-info-recursive
447 448
 
... ...
@@ -450,16 +506,18 @@ uninstall-info: uninstall-info-recursive
450 450
 	dist-gzip distcheck distclean distclean-generic distclean-hdr \
451 451
 	distclean-libtool distclean-recursive distclean-tags \
452 452
 	distcleancheck distdir dvi dvi-am dvi-recursive info info-am \
453
-	info-recursive install install-am install-data install-data-am \
454
-	install-data-recursive install-exec install-exec-am \
455
-	install-exec-recursive install-info install-info-am \
456
-	install-info-recursive install-man install-recursive \
457
-	install-strip installcheck installcheck-am installdirs \
458
-	installdirs-am installdirs-recursive maintainer-clean \
459
-	maintainer-clean-generic maintainer-clean-recursive mostlyclean \
460
-	mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \
461
-	tags tags-recursive uninstall uninstall-am uninstall-info-am \
462
-	uninstall-info-recursive uninstall-recursive
453
+	info-recursive install install-am install-binSCRIPTS \
454
+	install-data install-data-am install-data-recursive \
455
+	install-exec install-exec-am install-exec-recursive \
456
+	install-info install-info-am install-info-recursive install-man \
457
+	install-pkgconfigDATA install-recursive install-strip \
458
+	installcheck installcheck-am installdirs installdirs-am \
459
+	installdirs-recursive maintainer-clean maintainer-clean-generic \
460
+	maintainer-clean-recursive mostlyclean mostlyclean-generic \
461
+	mostlyclean-libtool mostlyclean-recursive tags tags-recursive \
462
+	uninstall uninstall-am uninstall-binSCRIPTS uninstall-info-am \
463
+	uninstall-info-recursive uninstall-pkgconfigDATA \
464
+	uninstall-recursive
463 465
 
464 466
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
465 467
 # Otherwise a system limit (for SysV at least) may be exceeded.
... ...
@@ -81,7 +81,7 @@ dnl there is now a CREATE_PREFIX_TARGET_H in this file as a shorthand for
81 81
 dnl PREFIX_CONFIG_H from a target.h file, however w/o the target.h ever created
82 82
 dnl (the prefix is a bit different, since we add an extra -target- and -host-)
83 83
 dnl 
84
-dnl @version: $Id: aclocal.m4,v 1.39 2004/06/02 00:36:04 kojm Exp $
84
+dnl @version: $Id: aclocal.m4,v 1.40 2004/06/06 01:50:08 kojm Exp $
85 85
 dnl @author Guido Draheim <guidod@gmx.de>                 STATUS: used often
86 86
 
87 87
 AC_DEFUN([AC_CREATE_TARGET_H],
... ...
@@ -4041,7 +4041,7 @@ dnl      AC_COMPILE_CHECK_SIZEOF(ptrdiff_t, $headers)
4041 4041
 dnl      AC_COMPILE_CHECK_SIZEOF(off_t, $headers)
4042 4042
 dnl
4043 4043
 dnl @author Kaveh Ghazi <ghazi@caip.rutgers.edu>
4044
-dnl @version $Id: aclocal.m4,v 1.39 2004/06/02 00:36:04 kojm Exp $
4044
+dnl @version $Id: aclocal.m4,v 1.40 2004/06/06 01:50:08 kojm Exp $
4045 4045
 dnl
4046 4046
 AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
4047 4047
 [changequote(<<, >>)dnl
4048 4048
new file mode 100755
... ...
@@ -0,0 +1,74 @@
0
+#! /bin/sh
1
+# Originally from libxml, Copyright (C) Daniel Veillard
2
+
3
+prefix=/usr/local
4
+exec_prefix=${prefix}
5
+includedir=${prefix}/include
6
+libdir=${exec_prefix}/lib
7
+
8
+usage()
9
+{
10
+    cat <<EOF
11
+Usage: clamav-config [OPTION]
12
+
13
+Known values for OPTION are:
14
+
15
+  --prefix=DIR		change libclamav prefix [default $prefix]
16
+  --libs		print library linking information
17
+  --cflags		print pre-processor and compiler flags
18
+  --help		display this help and exit
19
+  --version		output version information
20
+EOF
21
+
22
+    exit $1
23
+}
24
+
25
+if test $# -eq 0; then
26
+    usage 1
27
+fi
28
+
29
+cflags=false
30
+libs=false
31
+
32
+while test $# -gt 0; do
33
+    case "$1" in
34
+    -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
35
+    *) optarg= ;;
36
+    esac
37
+
38
+    case "$1" in
39
+    --prefix=*)
40
+	prefix=$optarg
41
+	;;
42
+
43
+    --prefix)
44
+	echo $prefix
45
+	;;
46
+
47
+    --version)
48
+	echo devel-20040606
49
+	exit 0
50
+	;;
51
+
52
+    --help)
53
+	usage 0
54
+	;;
55
+
56
+    --cflags)
57
+       	echo -I${prefix}/include -g -O2
58
+       	;;
59
+
60
+    --libs)
61
+       	echo -L${exec_prefix}/lib  -lz -lbz2 -lgmp -lpthread
62
+       	;;
63
+
64
+    *)
65
+	usage
66
+	exit 1
67
+	;;
68
+    esac
69
+    shift
70
+done
71
+
72
+exit 0
73
+
0 74
new file mode 100644
... ...
@@ -0,0 +1,74 @@
0
+#! /bin/sh
1
+# Originally from libxml, Copyright (C) Daniel Veillard
2
+
3
+prefix=@prefix@
4
+exec_prefix=@exec_prefix@
5
+includedir=@includedir@
6
+libdir=@libdir@
7
+
8
+usage()
9
+{
10
+    cat <<EOF
11
+Usage: clamav-config [OPTION]
12
+
13
+Known values for OPTION are:
14
+
15
+  --prefix=DIR		change libclamav prefix [default $prefix]
16
+  --libs		print library linking information
17
+  --cflags		print pre-processor and compiler flags
18
+  --help		display this help and exit
19
+  --version		output version information
20
+EOF
21
+
22
+    exit $1
23
+}
24
+
25
+if test $# -eq 0; then
26
+    usage 1
27
+fi
28
+
29
+cflags=false
30
+libs=false
31
+
32
+while test $# -gt 0; do
33
+    case "$1" in
34
+    -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
35
+    *) optarg= ;;
36
+    esac
37
+
38
+    case "$1" in
39
+    --prefix=*)
40
+	prefix=$optarg
41
+	;;
42
+
43
+    --prefix)
44
+	echo $prefix
45
+	;;
46
+
47
+    --version)
48
+	echo @VERSION@
49
+	exit 0
50
+	;;
51
+
52
+    --help)
53
+	usage 0
54
+	;;
55
+
56
+    --cflags)
57
+       	echo -I@includedir@ @CFLAGS@
58
+       	;;
59
+
60
+    --libs)
61
+       	echo -L@libdir@ @LIBCLAMAV_LIBS@
62
+       	;;
63
+
64
+    *)
65
+	usage
66
+	exit 1
67
+	;;
68
+    esac
69
+    shift
70
+done
71
+
72
+exit 0
73
+
... ...
@@ -35,8 +35,7 @@ man_MANS = $(top_srcdir)/docs/man/clamav-milter.8
35 35
 endif
36 36
 endif
37 37
 
38
-DEFS = @DEFS@ -DSENDMAIL_BIN=\"@SENDMAIL@\"
39
-# CLAMD_LIBS is used, because clamav-milter requires the same libraries as clamd
40
-LIBS = -L$(top_builddir)/libclamav -lclamav -L/usr/lib/libmilter -lmilter @CLAMAV_MILTER_LIBS@
38
+AM_CFLAGS = -DSENDMAIL_BIN=\"$(SENDMAIL)\"
39
+LIBS = $(top_builddir)/libclamav/libclamav.la -L/usr/lib/libmilter -lmilter @CLAMAV_MILTER_LIBS@
41 40
 INCLUDES = -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_srcdir)/shared
42 41
 EXTRA_DIST = clamav-milter.c INSTALL
... ...
@@ -133,9 +133,8 @@ install_sh = @install_sh@
133 133
 
134 134
 @BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@man_MANS = $(top_srcdir)/docs/man/clamav-milter.8
135 135
 
136
-DEFS = @DEFS@ -DSENDMAIL_BIN=\"@SENDMAIL@\"
137
-# CLAMD_LIBS is used, because clamav-milter requires the same libraries as clamd
138
-LIBS = -L$(top_builddir)/libclamav -lclamav -L/usr/lib/libmilter -lmilter @CLAMAV_MILTER_LIBS@
136
+AM_CFLAGS = -DSENDMAIL_BIN=\"$(SENDMAIL)\"
137
+LIBS = $(top_builddir)/libclamav/libclamav.la -L/usr/lib/libmilter -lmilter @CLAMAV_MILTER_LIBS@
139 138
 INCLUDES = -I$(top_srcdir)/clamd -I$(top_srcdir)/libclamav -I$(top_srcdir)/shared
140 139
 EXTRA_DIST = clamav-milter.c INSTALL
141 140
 subdir = clamav-milter
... ...
@@ -158,6 +157,8 @@ clamav_milter_OBJECTS = $(am_clamav_milter_OBJECTS)
158 158
 clamav_milter_LDADD = $(LDADD)
159 159
 clamav_milter_DEPENDENCIES =
160 160
 clamav_milter_LDFLAGS =
161
+
162
+DEFS = @DEFS@
161 163
 DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
162 164
 CPPFLAGS = @CPPFLAGS@
163 165
 LDFLAGS = @LDFLAGS@
... ...
@@ -60,6 +60,5 @@ clamd_SOURCES = \
60 60
 
61 61
 endif
62 62
 
63
-DEFS = @DEFS@
64
-LIBS = -L$(top_builddir)/libclamav -lclamav @CLAMD_LIBS@ @ADDITIONAL_LIBS@
63
+LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMD_LIBS@ @ADDITIONAL_LIBS@
65 64
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
... ...
@@ -159,8 +159,7 @@ install_sh = @install_sh@
159 159
 @BUILD_CLAMD_TRUE@    shared.h
160 160
 
161 161
 
162
-DEFS = @DEFS@
163
-LIBS = -L$(top_builddir)/libclamav -lclamav @CLAMD_LIBS@ @ADDITIONAL_LIBS@
162
+LIBS = $(top_builddir)/libclamav/libclamav.la @CLAMD_LIBS@ @ADDITIONAL_LIBS@
164 163
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
165 164
 subdir = clamd
166 165
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
... ...
@@ -183,6 +182,8 @@ clamd_OBJECTS = $(am_clamd_OBJECTS)
183 183
 clamd_LDADD = $(LDADD)
184 184
 clamd_DEPENDENCIES =
185 185
 clamd_LDFLAGS =
186
+
187
+DEFS = @DEFS@
186 188
 DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
187 189
 CPPFLAGS = @CPPFLAGS@
188 190
 LDFLAGS = @LDFLAGS@
... ...
@@ -204,12 +204,31 @@ void clamd(struct optstruct *opt)
204 204
 	}
205 205
 
206 206
 	if(cfgopt(copt, "AllowSupplementaryGroups")) {
207
-	    initgroups(cpt->strarg, user->pw_gid);
208
-	} else
209
-	    setgroups(1, &user->pw_gid);
207
+	    if(initgroups(cpt->strarg, user->pw_gid)) {
208
+		fprintf(stderr, "ERROR: initgroups() failed.\n");
209
+		logg("!initgroups() failed.\n");
210
+		exit(1);
211
+	    }
212
+	} else {
213
+	    if(setgroups(1, &user->pw_gid)) {
214
+		fprintf(stderr, "ERROR: setgroups() failed.\n");
215
+		logg("!setgroups() failed.\n");
216
+		exit(1);
217
+	    }
218
+	}
219
+
220
+	if(setgid(user->pw_gid)) {
221
+	    fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid);
222
+	    logg("!setgid(%d) failed.\n", (int) user->pw_gid);
223
+	    exit(1);
224
+	}
225
+
226
+	if(setuid(user->pw_uid)) {
227
+	    fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid);
228
+	    logg("!setuid(%d) failed.\n", (int) user->pw_uid);
229
+	    exit(1);
230
+	}
210 231
 
211
-	setgid(user->pw_gid);
212
-	setuid(user->pw_uid);
213 232
 	logg("Running as user %s (UID %d, GID %d)\n", cpt->strarg, user->pw_uid, user->pw_gid);
214 233
     }
215 234
 
... ...
@@ -37,4 +37,4 @@ endif
37 37
 
38 38
 DEFS = @DEFS@ -DCL_NOTHREADS
39 39
 INCLUDES = -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
40
-LIBS = -L$(top_builddir)/libclamav -lclamav @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
40
+LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
... ...
@@ -136,7 +136,7 @@ install_sh = @install_sh@
136 136
 
137 137
 DEFS = @DEFS@ -DCL_NOTHREADS
138 138
 INCLUDES = -I$(top_srcdir)/clamscan -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
139
-LIBS = -L$(top_builddir)/libclamav -lclamav @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
139
+LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
140 140
 subdir = clamdscan
141 141
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
142 142
 CONFIG_HEADER = $(top_builddir)/clamav-config.h
... ...
@@ -40,5 +40,5 @@ clamscan_SOURCES = \
40 40
     defaults.h
41 41
 
42 42
 DEFS = @DEFS@ -DCL_NOTHREADS
43
-LIBS = -L$(top_builddir)/libclamav -lclamav @ADDITIONAL_LIBS@
43
+LIBS = $(top_builddir)/libclamav/libclamav.la @ADDITIONAL_LIBS@
44 44
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
... ...
@@ -143,7 +143,7 @@ clamscan_SOURCES = \
143 143
 
144 144
 
145 145
 DEFS = @DEFS@ -DCL_NOTHREADS
146
-LIBS = -L$(top_builddir)/libclamav -lclamav @ADDITIONAL_LIBS@
146
+LIBS = $(top_builddir)/libclamav/libclamav.la @ADDITIONAL_LIBS@
147 147
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
148 148
 subdir = clamscan
149 149
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
... ...
@@ -912,9 +912,20 @@ int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struc
912 912
 	case 0:
913 913
 #ifndef C_CYGWIN
914 914
 	    if(!getuid() && user) {
915
-		setgroups(1, &user->pw_gid);
916
-		setgid(user->pw_gid);
917
-		setuid(user->pw_uid);
915
+		if(setgroups(1, &user->pw_gid)) {
916
+		    fprintf(stderr, "ERROR: setgroups() failed.\n");
917
+		    exit(1);
918
+		}
919
+
920
+		if(setgid(user->pw_gid)) {
921
+		    fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid);
922
+		    exit(1);
923
+		}
924
+
925
+		if(setuid(user->pw_uid)) {
926
+		    fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid);
927
+		    exit(1);
928
+		}
918 929
 	    }
919 930
 #endif
920 931
 	    chdir(tmpdir);
... ...
@@ -84,8 +84,16 @@ int checkaccess(const char *path, const char *username, int mode)
84 84
 		return -2;
85 85
 
86 86
 	    case 0:
87
-		setuid(user->pw_uid);
88
-		setgid(user->pw_gid);
87
+		if(setgid(user->pw_gid)) {
88
+		    fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid);
89
+		    exit(0);
90
+		}
91
+
92
+		if(setuid(user->pw_uid)) {
93
+		    fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid);
94
+		    exit(0);
95
+		}
96
+
89 97
 		if(access(path, mode))
90 98
 		    exit(0);
91 99
 		else
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2002, 2003 Tomasz Kojm <zolw@konarski.edu.pl>
2
+ *  Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net>
3 3
  *
4 4
  *  This program is free software; you can redistribute it and/or modify
5 5
  *  it under the terms of the GNU General Public License as published by
... ...
@@ -160,9 +160,20 @@ int clamav_rmdirs(const char *dir)
160 160
 		if((user = getpwnam(UNPUSER)) == NULL)
161 161
 		    return -3;
162 162
 
163
-		setgroups(1, &user->pw_gid);
164
-		setgid(user->pw_gid);
165
-		setuid(user->pw_uid);
163
+		if(setgroups(1, &user->pw_gid)) {
164
+		    fprintf(stderr, "ERROR: setgroups() failed.\n");
165
+		    return -3;
166
+		}
167
+
168
+		if(setgid(user->pw_gid)) {
169
+		    fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid);
170
+		    return -3;
171
+		}
172
+
173
+		if(setuid(user->pw_uid)) {
174
+		    fprintf(stderr, "ERROR: setuid(%d) failed.\n", (int) user->pw_uid);
175
+		    return -3;
176
+		}
166 177
 	    }
167 178
 #endif
168 179
 	    rmdirs(dir);
... ...
@@ -11335,7 +11335,7 @@ cat >>confdefs.h <<_ACEOF
11335 11335
 _ACEOF
11336 11336
 
11337 11337
 
11338
-ac_config_files="$ac_config_files libclamav/Makefile clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile etc/Makefile Makefile"
11338
+ac_config_files="$ac_config_files libclamav/Makefile clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile etc/Makefile Makefile clamav-config libclamav.pc"
11339 11339
 cat >confcache <<\_ACEOF
11340 11340
 # This file is a shell script that caches the results of configure
11341 11341
 # tests run on this system so they can be shared between configure
... ...
@@ -11863,6 +11863,8 @@ do
11863 11863
   "sigtool/Makefile" ) CONFIG_FILES="$CONFIG_FILES sigtool/Makefile" ;;
11864 11864
   "etc/Makefile" ) CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;;
11865 11865
   "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
11866
+  "clamav-config" ) CONFIG_FILES="$CONFIG_FILES clamav-config" ;;
11867
+  "libclamav.pc" ) CONFIG_FILES="$CONFIG_FILES libclamav.pc" ;;
11866 11868
   "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
11867 11869
   "clamav-config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS clamav-config.h" ;;
11868 11870
   *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
... ...
@@ -572,4 +572,6 @@ freshclam/Makefile
572 572
 sigtool/Makefile
573 573
 etc/Makefile
574 574
 Makefile
575
+clamav-config
576
+libclamav.pc
575 577
 ])
... ...
@@ -96,6 +96,8 @@ Execute COMMAND after succesful update.
96 96
 59: Mirrors are not fully synchronized (try again later).
97 97
 .TP 
98 98
 60: Can't get information about clamav user from /etc/passwd.
99
+.TP 
100
+61: Can't drop privileges.
99 101
 .SH "CREDITS"
100 102
 Please check the full documentation for credits.
101 103
 .SH "AUTHOR"
... ...
@@ -40,4 +40,4 @@ freshclam_SOURCES = \
40 40
 
41 41
 DEFS = @DEFS@ -DCL_NOTHREADS
42 42
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
43
-LIBS = -L$(top_builddir)/libclamav -lclamav @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
43
+LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
... ...
@@ -142,7 +142,7 @@ freshclam_SOURCES = \
142 142
 
143 143
 DEFS = @DEFS@ -DCL_NOTHREADS
144 144
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
145
-LIBS = -L$(top_builddir)/libclamav -lclamav @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
145
+LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
146 146
 subdir = freshclam
147 147
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
148 148
 CONFIG_HEADER = $(top_builddir)/clamav-config.h
... ...
@@ -152,9 +152,20 @@ int freshclam(struct optstruct *opt)
152 152
 	    exit(60); /* this is critical problem, so we just exit here */
153 153
 	}
154 154
 
155
-	setgroups(1, &user->pw_gid);
156
-	setgid(user->pw_gid);
157
-	setuid(user->pw_uid);
155
+	if(setgroups(1, &user->pw_gid)) {
156
+	    mprintf("@setgroups() failed.\n");
157
+	    exit(61);
158
+	}
159
+
160
+	if(setgid(user->pw_gid)) {
161
+	    mprintf("@setgid(%d) failed.\n", (int) user->pw_gid);
162
+	    exit(61);
163
+	}
164
+
165
+	if(setuid(user->pw_uid)) {
166
+	    mprintf("@setuid(%d) failed.\n", (int) user->pw_uid);
167
+	    exit(61);
168
+	}
158 169
     }
159 170
 #endif
160 171
 
161 172
new file mode 100644
... ...
@@ -0,0 +1,11 @@
0
+prefix=@prefix@
1
+exec_prefix=@exec_prefix@
2
+libdir=@libdir@
3
+includedir=@includedir@
4
+
5
+Name: libclamav
6
+Description: A GPL virus scanner
7
+Version: @LIBCLAMAV_VERSION@
8
+Libs: -L${libdir} @LIBCLAMAV_LIBS@
9
+Cflags: -I${includedir} @CFLAGS@
10
+
... ...
@@ -34,4 +34,4 @@ sigtool_LDADD = $(top_builddir)/clamscan/others.o
34 34
 
35 35
 DEFS = @DEFS@ -DCL_NOTHREADS
36 36
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
37
-LIBS = -L$(top_builddir)/libclamav -lclamav @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
37
+LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
... ...
@@ -137,7 +137,7 @@ sigtool_LDADD = $(top_builddir)/clamscan/others.o
137 137
 
138 138
 DEFS = @DEFS@ -DCL_NOTHREADS
139 139
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/shared -I$(top_srcdir)/libclamav
140
-LIBS = -L$(top_builddir)/libclamav -lclamav @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
140
+LIBS = $(top_builddir)/libclamav/libclamav.la @FRESHCLAM_LIBS@ @ADDITIONAL_LIBS@
141 141
 subdir = sigtool
142 142
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
143 143
 CONFIG_HEADER = $(top_builddir)/clamav-config.h