| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
#ifndef MOD_QUOTATAB_H |
| 34 |
#define MOD_QUOTATAB_H |
| 35 |
|
| 36 |
#include "conf.h" |
| 37 |
#include "privs.h" |
| 38 |
|
| 39 |
#define MOD_QUOTATAB_VERSION "mod_quotatab/1.3.1" |
| 40 |
|
| 41 |
|
| 42 |
#if PROFTPD_VERSION_NUMBER < 0x0001030001 |
| 43 |
# error "ProFTPD 1.3.0rc1 or later required" |
| 44 |
#endif |
| 45 |
|
| 46 |
|
| 47 |
typedef enum { |
| 48 |
ALL_QUOTA = 10, |
| 49 |
USER_QUOTA = 20, |
| 50 |
GROUP_QUOTA = 30, |
| 51 |
CLASS_QUOTA = 40 |
| 52 |
} quota_type_t; |
| 53 |
|
| 54 |
|
| 55 |
typedef enum { |
| 56 |
HARD_LIMIT = 1, |
| 57 |
SOFT_LIMIT = 2 |
| 58 |
} quota_limit_type_t; |
| 59 |
|
| 60 |
|
| 61 |
typedef struct { |
| 62 |
char name[81]; |
| 63 |
|
| 64 |
|
| 65 |
quota_type_t quota_type; |
| 66 |
|
| 67 |
|
| 68 |
unsigned char quota_per_session; |
| 69 |
|
| 70 |
|
| 71 |
quota_limit_type_t quota_limit_type; |
| 72 |
|
| 73 |
|
| 74 |
double bytes_in_avail; |
| 75 |
double bytes_out_avail; |
| 76 |
double bytes_xfer_avail; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
unsigned int files_in_avail; |
| 82 |
unsigned int files_out_avail; |
| 83 |
unsigned int files_xfer_avail; |
| 84 |
|
| 85 |
} quota_limit_t; |
| 86 |
|
| 87 |
typedef struct { |
| 88 |
char name[81]; |
| 89 |
|
| 90 |
quota_type_t quota_type; |
| 91 |
|
| 92 |
|
| 93 |
double bytes_in_used; |
| 94 |
double bytes_out_used; |
| 95 |
double bytes_xfer_used; |
| 96 |
|
| 97 |
|
| 98 |
unsigned int files_in_used; |
| 99 |
unsigned int files_out_used; |
| 100 |
unsigned int files_xfer_used; |
| 101 |
|
| 102 |
} quota_tally_t; |
| 103 |
|
| 104 |
|
| 105 |
typedef enum { |
| 106 |
TYPE_LIMIT = 100, |
| 107 |
TYPE_TALLY |
| 108 |
|
| 109 |
} quota_tabtype_t; |
| 110 |
|
| 111 |
|
| 112 |
typedef enum { |
| 113 |
BYTE = 10, |
| 114 |
KILO, |
| 115 |
MEGA, |
| 116 |
GIGA |
| 117 |
|
| 118 |
} quota_units_t; |
| 119 |
|
| 120 |
typedef enum { |
| 121 |
IN = 100, |
| 122 |
OUT, |
| 123 |
XFER, |
| 124 |
|
| 125 |
} quota_xfer_t; |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
typedef struct { |
| 132 |
|
| 133 |
|
| 134 |
double bytes_in_delta; |
| 135 |
double bytes_out_delta; |
| 136 |
double bytes_xfer_delta; |
| 137 |
|
| 138 |
|
| 139 |
int files_in_delta; |
| 140 |
int files_out_delta; |
| 141 |
int files_xfer_delta; |
| 142 |
|
| 143 |
} quota_deltas_t; |
| 144 |
|
| 145 |
typedef struct table_obj { |
| 146 |
|
| 147 |
|
| 148 |
pool *tab_pool; |
| 149 |
|
| 150 |
|
| 151 |
quota_tabtype_t tab_type; |
| 152 |
|
| 153 |
|
| 154 |
int tab_handle; |
| 155 |
|
| 156 |
|
| 157 |
unsigned int tab_magic; |
| 158 |
|
| 159 |
|
| 160 |
unsigned int tab_quotalen; |
| 161 |
|
| 162 |
|
| 163 |
void *tab_data; |
| 164 |
|
| 165 |
|
| 166 |
int (*tab_close)(struct table_obj *); |
| 167 |
int (*tab_create)(struct table_obj *, void *); |
| 168 |
unsigned char (*tab_lookup)(struct table_obj *, void *, const char *, |
| 169 |
quota_type_t); |
| 170 |
int (*tab_read)(struct table_obj *, void *); |
| 171 |
unsigned char (*tab_verify)(struct table_obj *); |
| 172 |
int (*tab_write)(struct table_obj *, void *); |
| 173 |
|
| 174 |
|
| 175 |
struct flock tab_lock; |
| 176 |
int tab_lockfd; |
| 177 |
int (*tab_rlock)(struct table_obj *); |
| 178 |
int (*tab_unlock)(struct table_obj *); |
| 179 |
int (*tab_wlock)(struct table_obj *); |
| 180 |
|
| 181 |
|
| 182 |
unsigned int rlock_count; |
| 183 |
unsigned int wlock_count; |
| 184 |
|
| 185 |
} quota_table_t; |
| 186 |
|
| 187 |
#define QUOTATAB_LIMIT_SRC 0x0001 |
| 188 |
#define QUOTATAB_TALLY_SRC 0x0002 |
| 189 |
|
| 190 |
|
| 191 |
extern quota_deltas_t quotatab_deltas; |
| 192 |
|
| 193 |
|
| 194 |
int quotatab_log(const char *, ...) |
| 195 |
#ifdef __GNUC__ |
| 196 |
__attribute__ ((format (printf, 1, 2))); |
| 197 |
#else |
| 198 |
; |
| 199 |
#endif |
| 200 |
|
| 201 |
int quotatab_openlog(void); |
| 202 |
int quotatab_register_backend(const char *, |
| 203 |
quota_table_t *(*tab_open)(pool *, quota_tabtype_t, const char *), |
| 204 |
unsigned int); |
| 205 |
int quotatab_unregister_backend(const char *, unsigned int); |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
unsigned char quotatab_lookup(quota_tabtype_t, void *, const char *, |
| 215 |
quota_type_t); |
| 216 |
|
| 217 |
unsigned char quotatab_lookup_default(quota_tabtype_t, void *, const char *, |
| 218 |
quota_type_t); |
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
int quotatab_read(quota_tally_t *); |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
int quotatab_write(quota_tally_t *, double, double, double, int, int, int); |
| 230 |
|
| 231 |
#endif |