2 Samba-VirusFilter VFS modules
3 Copyright (C) 2010-2016 SATOH Fumiyasu @ OSS Technology Corp., Japan
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _VIRUSFILTER_COMMON_H
20 #define _VIRUSFILTER_COMMON_H
25 /* Samba common include file */
28 #include "smbd/smbd.h"
29 #include "smbd/globals.h"
30 #include "system/filesys.h"
31 #include "transfer_file.h"
34 #include "../librpc/gen_ndr/ndr_netlogon.h"
35 #include "../lib/tsocket/tsocket.h"
37 /* Samba debug class for VIRUSFILTER */
39 #define DBGC_CLASS virusfilter_debug_class
40 extern int virusfilter_debug_class
;
42 /* Samba's global variable */
43 extern userdom_struct current_user_info
;
45 #define VIRUSFILTER_VERSION "0.1.5"
47 /* ====================================================================== */
50 VIRUSFILTER_ACTION_DO_NOTHING
,
51 VIRUSFILTER_ACTION_QUARANTINE
,
52 VIRUSFILTER_ACTION_RENAME
,
53 VIRUSFILTER_ACTION_DELETE
,
57 VIRUSFILTER_RESULT_OK
,
58 VIRUSFILTER_RESULT_CLEAN
,
59 VIRUSFILTER_RESULT_ERROR
,
60 VIRUSFILTER_RESULT_INFECTED
,
61 VIRUSFILTER_RESULT_SUSPECTED
,
62 /* FIXME: VIRUSFILTER_RESULT_RISKWARE, */
65 struct virusfilter_config
{
66 int scan_request_count
;
67 int scan_request_limit
;
69 /* Scan on file operations */
73 /* Special scan options */
75 int max_nested_scan_archive
;
77 bool block_suspected_file
;
84 name_compare_entry
*exclude_files
;
87 name_compare_entry
*infected_files
;
89 /* Scan result cache */
90 struct virusfilter_cache
*cache
;
91 int cache_entry_limit
;
94 /* Infected file options */
95 virusfilter_action infected_file_action
;
96 const char * infected_file_command
;
97 int infected_open_errno
;
98 int infected_close_errno
;
100 /* Scan error options */
101 const char * scan_error_command
;
102 int scan_error_open_errno
;
103 int scan_error_close_errno
;
104 bool block_access_on_error
;
106 /* Quarantine infected files */
107 const char * quarantine_dir
;
108 const char * quarantine_prefix
;
109 const char * quarantine_suffix
;
110 bool quarantine_keep_tree
;
111 bool quarantine_keep_name
;
112 mode_t quarantine_dir_mode
;
114 /* Rename infected files */
115 const char * rename_prefix
;
116 const char * rename_suffix
;
118 /* Network options */
119 const char * socket_path
;
120 struct virusfilter_io_handle
*io_h
;
122 /* The backend AV engine */
123 struct virusfilter_backend
*backend
;
126 struct virusfilter_backend_fns
{
128 struct vfs_handle_struct
*handle
,
129 struct virusfilter_config
*config
,
133 struct vfs_handle_struct
*handle
);
134 virusfilter_result (*scan_init
)(
135 struct virusfilter_config
*config
);
136 virusfilter_result (*scan
)(
137 struct vfs_handle_struct
*handle
,
138 struct virusfilter_config
*config
,
139 const struct files_struct
*fsp
,
142 struct virusfilter_config
*config
);
145 struct virusfilter_backend
{
148 const struct virusfilter_backend_fns
*fns
;
149 void *backend_private
;
152 int virusfilter_sophos_init(struct virusfilter_config
*config
);
153 int virusfilter_fsav_init(struct virusfilter_config
*config
);
154 int virusfilter_clamav_init(struct virusfilter_config
*config
);
155 int virusfilter_dummy_init(struct virusfilter_config
*config
);
157 #endif /* _VIRUSFILTER_COMMON_H */