samba-vscan/nai vscan-mcdaemon.c,1.1.2.3,1.1.2.4 vscan-mcdaemon_core.c,1.1.2.4,1.1.2.5
Rainer Link <[email protected]> Sat, 25 Sep 2004 12:27:09 +0000
| Newsgroups | gmane.comp.security.virus.openantivirus.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/openantivirus/samba-vscan/nai
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6692/nai
Modified Files:
Tag: VSCAN_0_3
vscan-mcdaemon.c vscan-mcdaemon_core.c
Log Message:
make the code a little bit more read-able (esp. the check for return values)
Index: vscan-mcdaemon_core.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/nai/Attic/vscan-mcdaemon_core.c,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -d -r1.1.2.4 -r1.1.2.5
--- vscan-mcdaemon_core.c 2 May 2004 19:45:32 -0000 1.1.2.4
+++ vscan-mcdaemon_core.c 25 Sep 2004 12:27:06 -0000 1.1.2.5
@@ -4,7 +4,9 @@
* Core Interface for McAfee Virus Scanner via McDaemon
*
* Copyleft (C) Arturo 'Buanzo' Busleiman, 2003
- * Arturo 'Buanzo' Busleiman <[email protected]>
+ * Arturo 'Buanzo' Busleiman <[email protected]>
+ * Rainer Link, 2003-2004
+ * Rainer Link <rainer-pBPPa8WU5k41Tgt60Rntydi2O/[email protected]>
*
* This software is licensed under the GNU General Public License (GPL)
* See: http://www.gnu.org/copyleft/gpl.html
@@ -76,7 +78,7 @@
fpin = fdopen(sockfd, "r");
if ( fpin == NULL ) {
vscan_syslog("ERROR: can not open stream for reading - %s", strerror(errno));
- return -1;
+ return VSCAN_SCAN_ERROR;
}
fpout = fdopen(sockfd, "w");
@@ -84,7 +86,7 @@
/* closing fpin */
fclose(fpin);
vscan_syslog("ERROR: can not open stream for writing - %s", strerror(errno));
- return -1;
+ return VSCAN_SCAN_ERROR;
}
if ( verbose_file_logging )
@@ -104,7 +106,7 @@
/* closing streams */
fclose(fpin);
fclose(fpout);
- return -1;
+ return VSCAN_SCAN_ERROR;
}
/* hum, instead of flush()ing, use setvbuf to set line-based buffering? */
@@ -119,7 +121,7 @@
/* closing streams */
fclose(fpin);
fclose(fpout);
- return -1;
+ return VSCAN_SCAN_ERROR;
}
/* closing streams */
@@ -134,12 +136,12 @@
if ( strncmp("FOUND", recvline, 5) == 0 ) {
/* virus found */
vscan_mcdaemon_log_virus(scan_file, recvline, client_ip);
- return 1;
+ return VSCAN_SCAN_VIRUS_FOUND;
} else if ( strncmp("ERROR", recvline, 5) == 0 ) {
/* ERROR */
if ( verbose_file_logging )
vscan_syslog("ERROR: file %s not found, not readable or an error occured", scan_file);
- return -2;
+ return VSCAN_SCAN_MINOR_ERROR;
} else if ( strncmp("OK", recvline, 2) == 0 ) {
/* OK */
if ( verbose_file_logging )
@@ -148,10 +150,10 @@
/* unknown response */
vscan_syslog("ERROR: unknown response from McDaemon while scanning %s!", scan_file);
/* FIXME: should we really mark this as a minor error? */
- return -2;
+ return VSCAN_SCAN_MINOR_ERROR;
}
- return 0;
+ return VSCAN_SCAN_OK;
}
Index: vscan-mcdaemon.c
===================================================================
RCS file: /cvsroot/openantivirus/samba-vscan/nai/Attic/vscan-mcdaemon.c,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- vscan-mcdaemon.c 3 Apr 2004 11:57:21 -0000 1.1.2.3
+++ vscan-mcdaemon.c 25 Sep 2004 12:27:06 -0000 1.1.2.4
@@ -348,7 +348,7 @@
#else
return default_vfs_ops.open(conn, fname, flags, mode);
#endif
- else if ( filetype_skipscan(filepath) == 1 ) {
+ else if ( filetype_skipscan(filepath) == VSCAN_FT_SKIP_SCAN ) {
if ( verbose_file_logging )
vscan_syslog("File '%s' not scanned as file type is on exclude list", filepath);
#if (SMB_VFS_INTERFACE_VERSION >= 6)
@@ -372,7 +372,7 @@
safe_strcpy(client_ip, conn->client_address, CLIENT_IP_SIZE -1);
/* must file actually be scanned? */
must_be_checked = lrufiles_must_be_checked(filepath, stat_buf.st_mtime);
- if ( must_be_checked == -1 ) {
+ if ( must_be_checked == VSCAN_LRU_DENY_ACCESS ) {
/* file has already been checked and marked as infected */
/* deny access */
if ( verbose_file_logging )
@@ -384,7 +384,7 @@
/* deny access */
errno = EACCES;
return -1;
- } else if ( must_be_checked == 0 ) {
+ } else if ( must_be_checked == VSCAN_LRU_GRANT_ACCESS ) {
/* file has already been checked, not marked as infected and not modified */
if ( verbose_file_logging )
vscan_syslog("File '%s' has already been scanned, not marked as infected and not modified. Not scanned anymore. Access granted", filepath);
@@ -403,7 +403,7 @@
/* scan file */
retval = vscan_mcdaemon_scanfile(sockfd, filepath, client_ip);
- if ( retval == -2 && deny_access_on_minor_error ) {
+ if ( retval == VSCAN_SCAN_MINOR_ERROR && deny_access_on_minor_error ) {
/* a minor error occured - deny access */
vscan_syslog("ERROR: daemon failed with a minor error - access to file %s denied", fname);
vscan_mcdaemon_end(sockfd);
@@ -414,7 +414,7 @@
/* deny access */
errno = EACCES;
return -1;
- } else if ( retval == -1 && deny_access_on_error ) {
+ } else if ( retval == VSCAN_SCAN_ERROR && deny_access_on_error ) {
/* an error occured - can not communicate to daemon - deny access */
vscan_syslog("ERROR: can not communicate to daemon - access to file %s denied", fname);
vscan_mcdaemon_end(sockfd);
@@ -426,7 +426,7 @@
errno = EACCES;
return -1;
- } else if ( retval == 1 ) {
+ } else if ( retval == VSCAN_SCAN_VIRUS_FOUND ) {
/* close socket */
vscan_mcdaemon_end(sockfd);
/* do action ... */
@@ -443,7 +443,7 @@
/* virus found, deny acces */
errno = EACCES;
return -1;
- } else if ( retval == 0 ) {
+ } else if ( retval == VSCAN_SCAN_OK ) {
/* file is clean, add to lrufiles */
lrufiles_add(filepath, stat_buf.st_mtime, False);
}
@@ -505,7 +505,7 @@
}
/* don't scan files which are in the list of exclude file types */
- if ( filetype_skipscan(filepath) == 1 ) {
+ if ( filetype_skipscan(filepath) == VSCAN_FT_SKIP_SCAN ) {
if ( verbose_file_logging )
vscan_syslog("File '%s' not scanned as file type is on exclude list", filepath);
return retval;
@@ -519,7 +519,7 @@
safe_strcpy(client_ip, fsp->conn->client_address, CLIENT_IP_SIZE -1);
rv = vscan_mcdaemon_scanfile(sockfd, filepath, client_ip);
vscan_mcdaemon_end(sockfd);
- if ( rv == 1 ) {
+ if ( rv == VSCAN_SCAN_VIRUS_FOUND ) {
/* virus was found */
#if (SMB_VFS_INTERFACE_VERSION >= 6)
rc = vscan_do_infected_file_action(handle, fsp->conn, filepath, quarantine_dir, quarantine_prefix, infected_file_action);
-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php