Browse code

bb#508 (Can't run clamscan as root)

git-svn: trunk@3069

Tomasz Kojm authored on 2007/05/28 21:47:33
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon May 28 14:11:44 CEST 2007 (tk)
2
+----------------------------------
3
+  * clamscan/manager.c: bb#508 (Can't run clamscan as root)
4
+
1 5
 Mon May 28 13:39:55 CEST 2007 (tk)
2 6
 ----------------------------------
3 7
   * libclamav: revert r3054, to be replaced with session based limits
... ...
@@ -140,7 +140,7 @@ static int scanstdin(const struct cl_engine *engine, const struct cl_limits *lim
140 140
 int scanmanager(const struct optstruct *opt)
141 141
 {
142 142
 	mode_t fmode;
143
-	int ret = 0, compression = 0, fmodeint, i, x;
143
+	int ret = 0, extunpacker = 0, fmodeint, i, x;
144 144
 	unsigned int options = 0, dboptions = 0;
145 145
 	struct cl_engine *engine = NULL;
146 146
 	struct cl_limits limits;
... ...
@@ -149,22 +149,21 @@ int scanmanager(const struct optstruct *opt)
149 149
 	char *fullpath = NULL, cwd[1024];
150 150
 
151 151
 
152
+    if(opt_check(opt, "unzip") || opt_check(opt, "unrar") || opt_check(opt, "arj") ||
153
+       opt_check(opt, "unzoo") || opt_check(opt, "jar") || opt_check(opt, "lha") ||
154
+       opt_check(opt, "tar") || opt_check(opt, "tgz") || opt_check(opt, "deb"))
155
+	    extunpacker = 1;
156
+
152 157
 /* njh@bandsman.co.uk: BeOS */
153 158
 #if !defined(C_CYGWIN) && !defined(C_OS2) && !defined(C_BEOS) && !defined(C_WINDOWS)
154
-    if(!geteuid()) {
159
+    if(extunpacker && !geteuid()) {
155 160
 	if((user = getpwnam(CLAMAVUSER)) == NULL) {
156
-	    logg("!Can't get information about user "CLAMAVUSER"\n");
161
+	    logg("!Can't get information about user "CLAMAVUSER" (required to run external unpackers)\n");
157 162
 	    exit(60); /* this is critical problem, so we just exit here */
158 163
 	}
159 164
     }
160 165
 #endif
161 166
 
162
-    if(opt_check(opt, "unzip") || opt_check(opt, "unrar") || opt_check(opt, "arj") ||
163
-       opt_check(opt, "unzoo") || opt_check(opt, "jar") || opt_check(opt, "lha") ||
164
-       opt_check(opt, "tar") || opt_check(opt, "tgz") || opt_check(opt, "deb"))
165
-	    compression = 1;
166
-
167
-
168 167
     if(opt_check(opt, "ncore"))
169 168
 	dboptions |= CL_DB_NCORE;
170 169
 
... ...
@@ -342,7 +341,7 @@ int scanmanager(const struct optstruct *opt)
342 342
 
343 343
 		fmode = (mode_t) fmodeint;
344 344
 
345
-		if(compression && (thefilename[0] != '/' && thefilename[0] != '\\' && thefilename[1] != ':')) {
345
+		if(extunpacker && (thefilename[0] != '/' && thefilename[0] != '\\' && thefilename[1] != ':')) {
346 346
 		    /* we need to complete the path */
347 347
 		    if(!getcwd(cwd, sizeof(cwd))) {
348 348
 			logg("!Can't get absolute pathname of current working directory\n");
... ...
@@ -373,7 +372,7 @@ int scanmanager(const struct optstruct *opt)
373 373
 			ret = 52;
374 374
 		}
375 375
 
376
-		if(compression && (thefilename[0] != '/' && thefilename[0] != '\\' && thefilename[1] != ':')) {
376
+		if(extunpacker && (thefilename[0] != '/' && thefilename[0] != '\\' && thefilename[1] != ':')) {
377 377
 		    free(fullpath);
378 378
 		    fullpath = NULL;
379 379
 		}