~ubuntu-branches/ubuntu/utopic/clamav/utopic-security

« back to all changes in this revision

Viewing changes to clamd/dazuko_xp.h

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-02-01 11:06:17 UTC
  • mfrom: (0.35.37 sid)
  • Revision ID: package-import@ubuntu.com-20140201110617-33h2xxk09dep0ui4
Tags: 0.98.1+dfsg-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Drop build-dep on electric-fence (in Universe)
  - Add apparmor profiles for clamd and freshclam along with maintainer
    script changes
  - Add autopkgtest

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#if HAVE_CONFIG_H
2
 
#include "clamav-config.h"
3
 
#endif
4
 
 
5
 
#ifdef CLAMUKO
6
 
/* DazukoXP. Allow cross platform file access control for 3rd-party applications.
7
 
   Written by John Ogness <jogness@antivir.de>
8
 
 
9
 
   Copyright (c) 2002, 2003, 2004 H+BEDV Datentechnik GmbH
10
 
   All rights reserved.
11
 
 
12
 
   Redistribution and use in source and binary forms, with or without
13
 
   modification, are permitted provided that the following conditions
14
 
   are met:
15
 
 
16
 
   1. Redistributions of source code must retain the above copyright notice,
17
 
   this list of conditions and the following disclaimer.
18
 
 
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.
22
 
 
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.
26
 
 
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.
38
 
*/
39
 
 
40
 
#ifndef DAZUKO_XP_H
41
 
#define DAZUKO_XP_H
42
 
 
43
 
#define VERSION "2.0.4-pre3"
44
 
 
45
 
#include "dazukoio_xp.h"
46
 
 
47
 
/* various requests */
48
 
#define SET_ACCESS_MASK         0
49
 
#define ADD_INCLUDE_PATH        1
50
 
#define ADD_EXCLUDE_PATH        2
51
 
#define REGISTER                3
52
 
#define REMOVE_ALL_PATHS        4
53
 
#define UNREGISTER              5
54
 
#define GET_AN_ACCESS           6
55
 
#define RETURN_AN_ACCESS        7
56
 
 
57
 
/* slot states */
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) */
64
 
 
65
 
/* file types */
66
 
#define DAZUKO_NONE             0
67
 
#define DAZUKO_REGULAR          1
68
 
#define DAZUKO_DIRECTORY        2
69
 
#define DAZUKO_LINK             3
70
 
 
71
 
 
72
 
/*********************************************************
73
 
 * structures that MUST be implemented by platform-layer *
74
 
 *********************************************************/
75
 
 
76
 
/*
77
 
struct xp_file;
78
 
struct xp_mutex;
79
 
struct xp_atomic;
80
 
struct xp_file_struct;
81
 
struct xp_queue;
82
 
struct xp_rwlock;
83
 
struct xp_daemon_id;
84
 
*/
85
 
 
86
 
 
87
 
/******************************************
88
 
 * structures available to platform-layer *
89
 
 ******************************************/
90
 
 
91
 
struct event_properties
92
 
{
93
 
        int     thrown;
94
 
 
95
 
        int     flags;
96
 
        char    set_flags;
97
 
        int     mode;
98
 
        char    set_mode;
99
 
        int     uid;
100
 
        char    set_uid;
101
 
        int     pid;
102
 
        char    set_pid;
103
 
};
104
 
 
105
 
struct file_properties
106
 
{
107
 
        unsigned long   size;
108
 
        char            set_size;
109
 
        int             uid;
110
 
        char            set_uid;
111
 
        int             gid;
112
 
        char            set_gid;
113
 
        int             mode;
114
 
        char            set_mode;
115
 
        int             device_type;
116
 
        char            set_device_type;
117
 
        int             type;
118
 
        char            set_type;
119
 
};
120
 
 
121
 
struct dazuko_file_listnode
122
 
{
123
 
        char                            *filename;
124
 
        int                             filename_length;
125
 
        struct dazuko_file_listnode     *next;
126
 
};
127
 
 
128
 
struct dazuko_file_struct
129
 
{
130
 
        /* A structure designed for simple and
131
 
         * intelligent memory management when
132
 
         * doing filename lookups in the kernel. */
133
 
 
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 */
140
 
};
141
 
 
142
 
 
143
 
/********************************************************
144
 
 * functions that MUST be implemented by platform-layer *
145
 
 ********************************************************/
146
 
 
147
 
/* mutex */
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);
152
 
 
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);
160
 
 
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);
166
 
 
167
 
/* memory */
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);
174
 
 
175
 
/* path attribute */
176
 
int xp_is_absolute_path(const char *path);
177
 
 
178
 
/* atomic */
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);
183
 
 
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);
187
 
 
188
 
/* system hook */
189
 
int xp_sys_hook(void);
190
 
int xp_sys_unhook(void);
191
 
 
192
 
/* file structure */
193
 
int xp_file_struct_check(struct dazuko_file_struct *dfs);
194
 
int xp_file_struct_check_cleanup(struct dazuko_file_struct *dfs);
195
 
 
196
 
/* daemon id */
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);
200
 
 
201
 
/* output */
202
 
int xp_print(const char *fmt, ...);
203
 
 
204
 
/* debug */
205
 
#ifdef DEBUG
206
 
#define DPRINT(fmt) xp_print fmt
207
 
#else
208
 
#define DPRINT(fmt)
209
 
#endif
210
 
 
211
 
 
212
 
/*****************************************
213
 
 * functions available to platform-layer *
214
 
 *****************************************/
215
 
 
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);
230
 
 
231
 
#endif
232
 
#endif