1911106dfSjm199354 /* 2911106dfSjm199354 * CDDL HEADER START 3911106dfSjm199354 * 4911106dfSjm199354 * The contents of this file are subject to the terms of the 5911106dfSjm199354 * Common Development and Distribution License (the "License"). 6911106dfSjm199354 * You may not use this file except in compliance with the License. 7911106dfSjm199354 * 8911106dfSjm199354 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9911106dfSjm199354 * or http://www.opensolaris.org/os/licensing. 10911106dfSjm199354 * See the License for the specific language governing permissions 11911106dfSjm199354 * and limitations under the License. 12911106dfSjm199354 * 13911106dfSjm199354 * When distributing Covered Code, include this CDDL HEADER in each 14911106dfSjm199354 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15911106dfSjm199354 * If applicable, add the following below this CDDL HEADER, with the 16911106dfSjm199354 * fields enclosed by brackets "[]" replaced with your own identifying 17911106dfSjm199354 * information: Portions Copyright [yyyy] [name of copyright owner] 18911106dfSjm199354 * 19911106dfSjm199354 * CDDL HEADER END 20911106dfSjm199354 */ 21911106dfSjm199354 /* 22*53c11029Sjm199354 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23911106dfSjm199354 * Use is subject to license terms. 24911106dfSjm199354 */ 25911106dfSjm199354 26911106dfSjm199354 #ifndef _VSCAN_H 27911106dfSjm199354 #define _VSCAN_H 28911106dfSjm199354 29911106dfSjm199354 #pragma ident "%Z%%M% %I% %E% SMI" 30911106dfSjm199354 31911106dfSjm199354 #ifdef __cplusplus 32911106dfSjm199354 extern "C" { 33911106dfSjm199354 #endif 34911106dfSjm199354 35911106dfSjm199354 #include <sys/param.h> 36911106dfSjm199354 #include <sys/vnode.h> 37911106dfSjm199354 38911106dfSjm199354 /* 39911106dfSjm199354 * vscan.h provides definitions for vscan kernel module 40911106dfSjm199354 */ 41911106dfSjm199354 42911106dfSjm199354 #define VS_DRV_MAX_FILES 1024 /* max concurent file scans */ 43911106dfSjm199354 #define VS_DRV_PATH "/devices/pseudo/vscan@0:vscan" 44911106dfSjm199354 #define VS_DRV_IOCTL_ENABLE 0x0001 /* door rendezvous */ 45911106dfSjm199354 #define VS_DRV_IOCTL_DISABLE 0x0002 /* vscand shutting down */ 46911106dfSjm199354 #define VS_DRV_IOCTL_CONFIG 0x0004 /* vscand config data update */ 47911106dfSjm199354 48*53c11029Sjm199354 /* Scan Result - vsr_result */ 49*53c11029Sjm199354 #define VS_STATUS_UNDEFINED 0 50*53c11029Sjm199354 #define VS_STATUS_NO_SCAN 1 /* scan not required */ 51*53c11029Sjm199354 #define VS_STATUS_ERROR 2 /* scan failed */ 52*53c11029Sjm199354 #define VS_STATUS_CLEAN 3 /* scan successful, file clean */ 53*53c11029Sjm199354 #define VS_STATUS_INFECTED 4 /* scan successful, file infected */ 54911106dfSjm199354 55911106dfSjm199354 #define VS_TYPES_LEN 4096 /* vs_config_t - types buffer */ 56911106dfSjm199354 57911106dfSjm199354 /* 58911106dfSjm199354 * AV_SCANSTAMP_SZ is the size of the scanstamp stored in the 59911106dfSjm199354 * filesystem. vs_scanstamp_t is 1 character longer to allow 60911106dfSjm199354 * a null terminated string to be used within vscan 61911106dfSjm199354 */ 62911106dfSjm199354 typedef char vs_scanstamp_t[AV_SCANSTAMP_SZ + 1]; 63911106dfSjm199354 64911106dfSjm199354 /* used for both request to and response from vscand */ 65911106dfSjm199354 typedef struct vs_scan_req { 66911106dfSjm199354 uint32_t vsr_id; 67911106dfSjm199354 uint32_t vsr_flags; 68911106dfSjm199354 uint64_t vsr_size; 69911106dfSjm199354 uint8_t vsr_modified; 70911106dfSjm199354 uint8_t vsr_quarantined; 71911106dfSjm199354 char vsr_path[MAXPATHLEN]; 72911106dfSjm199354 vs_scanstamp_t vsr_scanstamp; 73*53c11029Sjm199354 uint32_t vsr_result; 74911106dfSjm199354 } vs_scan_req_t; 75911106dfSjm199354 76911106dfSjm199354 77911106dfSjm199354 /* passed in VS_DRV_IOCTL_CONFIG */ 78911106dfSjm199354 typedef struct vs_config { 79911106dfSjm199354 char vsc_types[VS_TYPES_LEN]; 80911106dfSjm199354 uint64_t vsc_types_len; 81911106dfSjm199354 uint64_t vsc_max_size; /* files > max size (bytes) not scan */ 82911106dfSjm199354 uint64_t vsc_allow; /* allow access to file exceeding max_size? */ 83911106dfSjm199354 } vs_config_t; 84911106dfSjm199354 85911106dfSjm199354 86911106dfSjm199354 #ifdef _KERNEL 87911106dfSjm199354 88911106dfSjm199354 /* 89911106dfSjm199354 * max no of types in vs_config_t.vsc_types 90911106dfSjm199354 * used as dimention for array of pointers to types 91911106dfSjm199354 */ 92911106dfSjm199354 #define VS_TYPES_MAX VS_TYPES_LEN / 2 93911106dfSjm199354 94*53c11029Sjm199354 /* 95*53c11029Sjm199354 * seconds to wait for daemon to reconnect before unregistering from VFS 96*53c11029Sjm199354 * during this time, the kernel will: 97*53c11029Sjm199354 * - allow access to files that have not been modified since last scanned 98*53c11029Sjm199354 * - deny access to files which have been modified since last scanned 99*53c11029Sjm199354 */ 100*53c11029Sjm199354 #define VS_DAEMON_WAIT_SEC 60 101*53c11029Sjm199354 102*53c11029Sjm199354 /* access derived from scan result (VS_STATUS_XXX) and file attributes */ 103*53c11029Sjm199354 #define VS_ACCESS_UNDEFINED 0 104*53c11029Sjm199354 #define VS_ACCESS_ALLOW 1 105*53c11029Sjm199354 #define VS_ACCESS_DENY 2 106*53c11029Sjm199354 107911106dfSjm199354 int vscan_svc_init(void); 108911106dfSjm199354 void vscan_svc_fini(void); 109*53c11029Sjm199354 void vscan_svc_enable(void); 110*53c11029Sjm199354 void vscan_svc_disable(void); 111911106dfSjm199354 int vscan_svc_configure(vs_config_t *); 112*53c11029Sjm199354 boolean_t vscan_svc_is_enabled(void); 113911106dfSjm199354 boolean_t vscan_svc_in_use(void); 114911106dfSjm199354 vnode_t *vscan_svc_get_vnode(int); 115911106dfSjm199354 116911106dfSjm199354 int vscan_door_init(void); 117911106dfSjm199354 void vscan_door_fini(void); 118911106dfSjm199354 int vscan_door_open(int); 119911106dfSjm199354 void vscan_door_close(void); 120911106dfSjm199354 int vscan_door_scan_file(vs_scan_req_t *); 121911106dfSjm199354 122*53c11029Sjm199354 boolean_t vscan_drv_create_node(int); 123*53c11029Sjm199354 124911106dfSjm199354 #endif /* _KERNEL */ 125911106dfSjm199354 126911106dfSjm199354 #ifdef __cplusplus 127911106dfSjm199354 } 128911106dfSjm199354 #endif 129911106dfSjm199354 130911106dfSjm199354 131911106dfSjm199354 #endif /* _VSCAN_H */ 132