00001 /* Dazuko Interface. Interace with Dazuko for file access control. 00002 Written by John Ogness <jogness@antivir.de> 00003 00004 Copyright (c) 2002, 2003, 2004 H+BEDV Datentechnik GmbH 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without 00008 modification, are permitted provided that the following conditions 00009 are met: 00010 00011 1. Redistributions of source code must retain the above copyright notice, 00012 this list of conditions and the following disclaimer. 00013 00014 2. Redistributions in binary form must reproduce the above copyright notice, 00015 this list of conditions and the following disclaimer in the documentation 00016 and/or other materials provided with the distribution. 00017 00018 3. Neither the name of Dazuko nor the names of its contributors may be used 00019 to endorse or promote products derived from this software without specific 00020 prior written permission. 00021 00022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00025 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00026 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00027 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00028 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00029 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00030 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00031 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00035 #ifndef DAZUKOIO_H 00036 #define DAZUKOIO_H 00037 00038 /* event types */ 00039 #define DAZUKO_ON_OPEN 1 00040 #define DAZUKO_ON_CLOSE 2 00041 #define DAZUKO_ON_EXEC 4 00042 #define DAZUKO_ON_CLOSE_MODIFIED 8 00043 #define DAZUKO_ON_UNLINK 16 00044 #define DAZUKO_ON_RMDIR 32 00045 00046 struct dazuko_access 00047 { 00048 int deny; 00049 int event; 00050 char set_event; 00051 int flags; 00052 char set_flags; 00053 int mode; 00054 char set_mode; 00055 int uid; 00056 char set_uid; 00057 int pid; 00058 char set_pid; 00059 char *filename; 00060 char set_filename; 00061 unsigned long file_size; 00062 char set_file_size; 00063 int file_uid; 00064 char set_file_uid; 00065 int file_gid; 00066 char set_file_gid; 00067 int file_mode; 00068 char set_file_mode; 00069 int file_device; 00070 char set_file_device; 00071 }; 00072 00073 struct dazuko_id; 00074 typedef struct dazuko_id dazuko_id_t; 00075 00076 /* single-threaded API */ 00077 int dazukoRegister(const char *groupName, const char *mode); 00078 int dazukoSetAccessMask(unsigned long accessMask); 00079 int dazukoAddIncludePath(const char *path); 00080 int dazukoAddExcludePath(const char *path); 00081 int dazukoRemoveAllPaths(void); 00082 int dazukoGetAccess(struct dazuko_access **acc); 00083 int dazukoReturnAccess(struct dazuko_access **acc); 00084 int dazukoUnregister(void); 00085 00086 /* thread-safe API (as long as each thread has its own "dazuko_id_t") */ 00087 int dazukoRegister_TS(dazuko_id_t **dazuko, const char *groupName, const char *mode); 00088 int dazukoSetAccessMask_TS(dazuko_id_t *dazuko, unsigned long accessMask); 00089 int dazukoAddIncludePath_TS(dazuko_id_t *dazuko, const char *path); 00090 int dazukoAddExcludePath_TS(dazuko_id_t *dazuko, const char *path); 00091 int dazukoRemoveAllPaths_TS(dazuko_id_t *dazuko); 00092 int dazukoGetAccess_TS(dazuko_id_t *dazuko, struct dazuko_access **acc); 00093 int dazukoReturnAccess_TS(dazuko_id_t *dazuko, struct dazuko_access **acc); 00094 int dazukoUnregister_TS(dazuko_id_t **dazuko); 00095 00096 #endif