s3:pylibsmb: Make .list() work for SMBv2
[samba.git] / source3 / modules / vfs_virusfilter_common.h
1 /*
2    Samba-VirusFilter VFS modules
3    Copyright (C) 2010-2016 SATOH Fumiyasu @ OSS Technology Corp., Japan
4
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.
9
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.
14
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/>.
17 */
18
19 #ifndef _VIRUSFILTER_COMMON_H
20 #define _VIRUSFILTER_COMMON_H
21
22 #include <stdint.h>
23 #include <time.h>
24
25 /* Samba common include file */
26 #include "includes.h"
27
28 #include "smbd/smbd.h"
29 #include "smbd/globals.h"
30 #include "system/filesys.h"
31 #include "transfer_file.h"
32 #include "auth.h"
33 #include "passdb.h"
34 #include "../librpc/gen_ndr/ndr_netlogon.h"
35 #include "../lib/tsocket/tsocket.h"
36
37 /* Samba debug class for VIRUSFILTER */
38 #undef DBGC_CLASS
39 #define DBGC_CLASS virusfilter_debug_class
40 extern int virusfilter_debug_class;
41
42 /* Samba's global variable */
43 extern userdom_struct current_user_info;
44
45 #define VIRUSFILTER_VERSION "0.1.5"
46
47 /* ====================================================================== */
48
49 typedef enum {
50         VIRUSFILTER_ACTION_DO_NOTHING,
51         VIRUSFILTER_ACTION_QUARANTINE,
52         VIRUSFILTER_ACTION_RENAME,
53         VIRUSFILTER_ACTION_DELETE,
54 } virusfilter_action;
55
56 typedef enum {
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, */
63 } virusfilter_result;
64
65 struct virusfilter_config {
66         int                             scan_request_count;
67         int                             scan_request_limit;
68
69         /* Scan on file operations */
70         bool                            scan_on_open;
71         bool                            scan_on_close;
72
73         /* Special scan options */
74         bool                            scan_archive;
75         int                             max_nested_scan_archive;
76         bool                            scan_mime;
77         bool                            block_suspected_file;
78
79         /* Size limit */
80         size_t                          max_file_size;
81         size_t                          min_file_size;
82
83         /* Exclude files */
84         name_compare_entry              *exclude_files;
85
86         /* Scan result cache */
87         struct virusfilter_cache        *cache;
88         int                             cache_entry_limit;
89         int                             cache_time_limit;
90
91         /* Infected file options */
92         virusfilter_action              infected_file_action;
93         const char *                    infected_file_command;
94         int                             infected_open_errno;
95         int                             infected_close_errno;
96
97         /* Scan error options */
98         const char *                    scan_error_command;
99         int                             scan_error_open_errno;
100         int                             scan_error_close_errno;
101         bool                            block_access_on_error;
102
103         /* Quarantine infected files */
104         const char *                    quarantine_dir;
105         const char *                    quarantine_prefix;
106         const char *                    quarantine_suffix;
107         bool                            quarantine_keep_tree;
108         bool                            quarantine_keep_name;
109         mode_t                          quarantine_dir_mode;
110
111         /* Rename infected files */
112         const char *                    rename_prefix;
113         const char *                    rename_suffix;
114
115         /* Network options */
116         const char *                    socket_path;
117         struct virusfilter_io_handle    *io_h;
118
119         /* The backend AV engine */
120         struct virusfilter_backend      *backend;
121 };
122
123 struct virusfilter_backend_fns {
124         int (*connect)(
125                 struct vfs_handle_struct *handle,
126                 struct virusfilter_config *config,
127                 const char *svc,
128                 const char *user);
129         void (*disconnect)(
130                 struct vfs_handle_struct *handle);
131         virusfilter_result (*scan_init)(
132                 struct virusfilter_config *config);
133         virusfilter_result (*scan)(
134                 struct vfs_handle_struct *handle,
135                 struct virusfilter_config *config,
136                 const struct files_struct *fsp,
137                 char **reportp);
138         void (*scan_end)(
139                 struct virusfilter_config *config);
140 };
141
142 struct virusfilter_backend {
143         unsigned version;
144         const char *name;
145         const struct virusfilter_backend_fns *fns;
146         void *backend_private;
147 };
148
149 int virusfilter_sophos_init(struct virusfilter_config *config);
150 int virusfilter_fsav_init(struct virusfilter_config *config);
151 int virusfilter_clamav_init(struct virusfilter_config *config);
152
153 #endif /* _VIRUSFILTER_COMMON_H */