Browse code

fix compilation problem on Windows SFU 3.5

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@604 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2004/06/13 00:50:35
Showing 10 changed files
... ...
@@ -1,3 +1,8 @@
1
+Sat Jun 12 17:32:31 CEST 2004 (tk)
2
+----------------------------------
3
+  * libclamav: fix problem with {set,init}groups on Windows SFU 3.5 (reported
4
+	       by Brian A. Reiter" <breiter*wolfereiter.com>)
5
+
1 6
 Sat Jun 12 15:29:37 CEST 2004 (tk)
2 7
 ----------------------------------
3 8
   * libclamav: ole2_extract: fix segfault when mmap() fails (problem reported
... ...
@@ -1,4 +1,4 @@
1
-# aclocal.m4t generated automatically by aclocal 1.6.1 -*- Autoconf -*-
1
+# aclocal.m4 generated automatically by aclocal 1.6.1 -*- Autoconf -*-
2 2
 
3 3
 # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 4
 # Free Software Foundation, Inc.
... ...
@@ -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.41 2004/06/11 20:17:18 kojm Exp $
84
+dnl @version: $Id: aclocal.m4,v 1.42 2004/06/12 15:50:35 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.41 2004/06/11 20:17:18 kojm Exp $
4044
+dnl @version $Id: aclocal.m4,v 1.42 2004/06/12 15:50:35 kojm Exp $
4045 4045
 dnl
4046 4046
 AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
4047 4047
 [changequote(<<, >>)dnl
... ...
@@ -90,6 +90,9 @@
90 90
 /* Define to 1 if you have the `inet_ntop' function. */
91 91
 #undef HAVE_INET_NTOP
92 92
 
93
+/* Define to 1 if you have the `initgroups' function. */
94
+#undef HAVE_INITGROUPS
95
+
93 96
 /* Define to 1 if you have the <inttypes.h> header file. */
94 97
 #undef HAVE_INTTYPES_H
95 98
 
... ...
@@ -126,6 +129,9 @@
126 126
 /* Define to 1 if you have the <regex.h> header file. */
127 127
 #undef HAVE_REGEX_H
128 128
 
129
+/* Define to 1 if you have the `setgroups' function. */
130
+#undef HAVE_SETGROUPS
131
+
129 132
 /* Define to 1 if you have the `setsid' function. */
130 133
 #undef HAVE_SETSID
131 134
 
... ...
@@ -204,17 +204,23 @@ void clamd(struct optstruct *opt)
204 204
 	}
205 205
 
206 206
 	if(cfgopt(copt, "AllowSupplementaryGroups")) {
207
+#ifdef HAVE_INITGROUPS
207 208
 	    if(initgroups(cpt->strarg, user->pw_gid)) {
208 209
 		fprintf(stderr, "ERROR: initgroups() failed.\n");
209 210
 		logg("!initgroups() failed.\n");
210 211
 		exit(1);
211 212
 	    }
213
+#else
214
+	    logg("AllowSupplementaryGroups: initgroups() not supported.\n");
215
+#endif
212 216
 	} else {
217
+#ifdef HAVE_SETGROUPS
213 218
 	    if(setgroups(1, &user->pw_gid)) {
214 219
 		fprintf(stderr, "ERROR: setgroups() failed.\n");
215 220
 		logg("!setgroups() failed.\n");
216 221
 		exit(1);
217 222
 	    }
223
+#endif
218 224
 	}
219 225
 
220 226
 	if(setgid(user->pw_gid)) {
... ...
@@ -912,10 +912,13 @@ 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
+
916
+#ifdef HAVE_SETGROUPS
915 917
 		if(setgroups(1, &user->pw_gid)) {
916 918
 		    fprintf(stderr, "ERROR: setgroups() failed.\n");
917 919
 		    exit(1);
918 920
 		}
921
+#endif
919 922
 
920 923
 		if(setgid(user->pw_gid)) {
921 924
 		    fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid);
... ...
@@ -160,10 +160,12 @@ int clamav_rmdirs(const char *dir)
160 160
 		if((user = getpwnam(UNPUSER)) == NULL)
161 161
 		    return -3;
162 162
 
163
+#ifdef HAVE_SETGROUPS
163 164
 		if(setgroups(1, &user->pw_gid)) {
164 165
 		    fprintf(stderr, "ERROR: setgroups() failed.\n");
165 166
 		    return -3;
166 167
 		}
168
+#endif
167 169
 
168 170
 		if(setgid(user->pw_gid)) {
169 171
 		    fprintf(stderr, "ERROR: setgid(%d) failed.\n", (int) user->pw_gid);
... ...
@@ -8232,7 +8232,9 @@ _ACEOF
8232 8232
 
8233 8233
 
8234 8234
 
8235
-for ac_func in poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat inet_ntop
8235
+
8236
+
8237
+for ac_func in poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat inet_ntop setgroups initgroups
8236 8238
 do
8237 8239
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
8238 8240
 echo "$as_me:$LINENO: checking for $ac_func" >&5
... ...
@@ -42,7 +42,7 @@ AC_TYPE_OFF_T
42 42
 AC_COMPILE_CHECK_SIZEOF(short)
43 43
 AC_COMPILE_CHECK_SIZEOF(int)
44 44
 AC_COMPILE_CHECK_SIZEOF(long)
45
-AC_CHECK_FUNCS(poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat inet_ntop)
45
+AC_CHECK_FUNCS(poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat inet_ntop setgroups initgroups)
46 46
 AC_FUNC_MMAP
47 47
 AC_FUNC_FSEEKO
48 48
 
... ...
@@ -152,10 +152,12 @@ int freshclam(struct optstruct *opt)
152 152
 	    exit(60); /* this is critical problem, so we just exit here */
153 153
 	}
154 154
 
155
+#ifdef HAVE_SETGROUPS
155 156
 	if(setgroups(1, &user->pw_gid)) {
156 157
 	    mprintf("@setgroups() failed.\n");
157 158
 	    exit(61);
158 159
 	}
160
+#endif
159 161
 
160 162
 	if(setgid(user->pw_gid)) {
161 163
 	    mprintf("@setgid(%d) failed.\n", (int) user->pw_gid);
... ...
@@ -109,7 +109,7 @@ struct cfgstruct *parsecfg(const char *cfgfile)
109 109
 	    {"MaxAttempts", OPT_NUM}, /* freshclam */
110 110
 	    {"HTTPProxyServer", OPT_STR}, /* freshclam */
111 111
 	    {"HTTPProxyPort", OPT_NUM}, /* freshclam */
112
-	    {"HTTPProxyUsername", OPT_FULLSTR}, /* freshclam */
112
+	    {"HTTPProxyUsername", OPT_STR}, /* freshclam */
113 113
 	    {"HTTPProxyPassword", OPT_STR}, /* freshclam */
114 114
 	    {"NotifyClamd", OPT_OPTARG}, /* freshclam */
115 115
 	    {"OnUpdateExecute", OPT_FULLSTR}, /* freshclam */