2
#include "clamav-config.h"
6
/* DazukoXP. Allow cross platform file access control for 3rd-party applications.
7
Written by John Ogness <jogness@antivir.de>
9
Copyright (c) 2002, 2003, 2004 H+BEDV Datentechnik GmbH
12
Redistribution and use in source and binary forms, with or without
13
modification, are permitted provided that the following conditions
16
1. Redistributions of source code must retain the above copyright notice,
17
this list of conditions and the following disclaimer.
19
2. Redistributions in binary form must reproduce the above copyright notice,
20
this list of conditions and the following disclaimer in the documentation
21
and/or other materials provided with the distribution.
23
3. Neither the name of Dazuko nor the names of its contributors may be used
24
to endorse or promote products derived from this software without specific
25
prior written permission.
27
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
POSSIBILITY OF SUCH DAMAGE.
43
#define VERSION "2.0.4-pre3"
45
#include "dazukoio_xp.h"
47
/* various requests */
48
#define SET_ACCESS_MASK 0
49
#define ADD_INCLUDE_PATH 1
50
#define ADD_EXCLUDE_PATH 2
52
#define REMOVE_ALL_PATHS 4
54
#define GET_AN_ACCESS 6
55
#define RETURN_AN_ACCESS 7
58
#define DAZUKO_FREE 0 /* the daemon is not ready */
59
#define DAZUKO_READY 1 /* a daemon waits for something to do */
60
#define DAZUKO_WAITING 2 /* a request is waiting to be served */
61
#define DAZUKO_WORKING 3 /* daemon is currently in action */
62
#define DAZUKO_DONE 4 /* daemon response is available */
63
#define DAZUKO_BROKEN 5 /* invalid state (interrupt from ready,waiting) */
67
#define DAZUKO_REGULAR 1
68
#define DAZUKO_DIRECTORY 2
72
/*********************************************************
73
* structures that MUST be implemented by platform-layer *
74
*********************************************************/
80
struct xp_file_struct;
87
/******************************************
88
* structures available to platform-layer *
89
******************************************/
91
struct event_properties
105
struct file_properties
116
char set_device_type;
121
struct dazuko_file_listnode
125
struct dazuko_file_listnode *next;
128
struct dazuko_file_struct
130
/* A structure designed for simple and
131
* intelligent memory management when
132
* doing filename lookups in the kernel. */
134
int should_scan; /* already know we need to scan? */
135
char *filename; /* filename to report (pointer in alias list) */
136
int filename_length; /* length of filename reported */
137
struct dazuko_file_listnode *aliases; /* list of file names (alias names) */
138
struct file_properties file_p; /* properties of file */
139
struct xp_file_struct *extra_data; /* extra platform-dependant data */
143
/********************************************************
144
* functions that MUST be implemented by platform-layer *
145
********************************************************/
148
int xp_init_mutex(struct xp_mutex *mutex);
149
int xp_down(struct xp_mutex *mutex);
150
int xp_up(struct xp_mutex *mutex);
151
int xp_destroy_mutex(struct xp_mutex *mutex);
153
/* read-write lock */
154
int xp_init_rwlock(struct xp_rwlock *rwlock);
155
int xp_write_lock(struct xp_rwlock *rwlock);
156
int xp_write_unlock(struct xp_rwlock *rwlock);
157
int xp_read_lock(struct xp_rwlock *rlock);
158
int xp_read_unlock(struct xp_rwlock *rlock);
159
int xp_destroy_rwlock(struct xp_rwlock *rwlock);
161
/* wait-notify queue */
162
int xp_init_queue(struct xp_queue *queue);
163
int xp_wait_until_condition(struct xp_queue *queue, int (*cfunction)(void *), void *cparam, int allow_interrupt);
164
int xp_notify(struct xp_queue *queue);
165
int xp_destroy_queue(struct xp_queue *queue);
168
void* xp_malloc(size_t size);
169
int xp_free(void *ptr);
170
int xp_copyin(const void *user_src, void *kernel_dest, size_t size);
171
int xp_copyout(const void *kernel_src, void *user_dest, size_t size);
172
int xp_verify_user_writable(const void *user_ptr, size_t size);
173
int xp_verify_user_readable(const void *user_ptr, size_t size);
176
int xp_is_absolute_path(const char *path);
179
int xp_atomic_set(struct xp_atomic *atomic, int value);
180
int xp_atomic_inc(struct xp_atomic *atomic);
181
int xp_atomic_dec(struct xp_atomic *atomic);
182
int xp_atomic_read(struct xp_atomic *atomic);
184
/* file descriptor */
185
int xp_copy_file(struct xp_file *dest, struct xp_file *src);
186
int xp_compare_file(struct xp_file *file1, struct xp_file *file2);
189
int xp_sys_hook(void);
190
int xp_sys_unhook(void);
193
int xp_file_struct_check(struct dazuko_file_struct *dfs);
194
int xp_file_struct_check_cleanup(struct dazuko_file_struct *dfs);
197
int xp_id_compare(struct xp_daemon_id *id1, struct xp_daemon_id *id2);
198
int xp_id_free(struct xp_daemon_id *id);
199
struct xp_daemon_id* xp_id_copy(struct xp_daemon_id *id);
202
int xp_print(const char *fmt, ...);
206
#define DPRINT(fmt) xp_print fmt
212
/*****************************************
213
* functions available to platform-layer *
214
*****************************************/
216
int dazuko_vsnprintf(char *str, size_t size, const char *format, va_list ap);
217
int dazuko_snprintf(char *str, size_t size, const char *format, ...);
218
int dazuko_is_our_daemon(struct xp_daemon_id *xp_id);
219
int dazuko_get_value(const char *key, const char *string, char **value);
220
int dazuko_unregister_daemon(struct xp_daemon_id *xp_id);
221
int dazuko_handle_user_request(struct dazuko_request *user_request, struct xp_daemon_id *xp_id);
222
int dazuko_handle_user_request_compat12(void *ptr, int cmd, struct xp_daemon_id *xp_id);
223
int dazuko_get_filename_length(char *filename);
224
void dazuko_bzero(void *p, int len);
225
int dazuko_sys_check(unsigned long event, int daemon_is_allowed, struct xp_daemon_id *xp_id);
226
int dazuko_sys_pre(unsigned long event, struct dazuko_file_struct *kfs, struct xp_file *file, struct event_properties *event_p);
227
int dazuko_sys_post(unsigned long event, struct dazuko_file_struct *kfs, struct xp_file *file, struct event_properties *event_p);
228
int dazuko_init(void);
229
int dazuko_exit(void);