| 1 | Index: vuurmuur/libvuurmuur/plugins/textdir/textdir_ask.c |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- vuurmuur.orig/libvuurmuur/plugins/textdir/textdir_ask.c 2009-06-02 21:35:19.000000000 +0200 |
|---|
| 4 | +++ vuurmuur/libvuurmuur/plugins/textdir/textdir_ask.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 5 | @@ -96,7 +96,7 @@ |
|---|
| 6 | /* now open and read the file, but only if it is not already open */ |
|---|
| 7 | if(ptr->file == NULL) |
|---|
| 8 | { |
|---|
| 9 | - if(!(ptr->file = vuurmuur_fopen(debuglvl, file_location, "r"))) |
|---|
| 10 | + if(!(ptr->file = vuurmuur_fopen(debuglvl, ptr->vuurmuur_config, file_location, "r"))) |
|---|
| 11 | { |
|---|
| 12 | (void)vrprint.error(-1, "Error", "Unable to open file '%s'.", file_location); |
|---|
| 13 | |
|---|
| 14 | Index: vuurmuur/libvuurmuur/plugins/textdir/textdir_list.c |
|---|
| 15 | =================================================================== |
|---|
| 16 | --- vuurmuur.orig/libvuurmuur/plugins/textdir/textdir_list.c 2009-06-02 21:35:19.000000000 +0200 |
|---|
| 17 | +++ vuurmuur/libvuurmuur/plugins/textdir/textdir_list.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 18 | @@ -78,7 +78,7 @@ |
|---|
| 19 | if(!ptr->service_p) |
|---|
| 20 | { |
|---|
| 21 | /* open the dir */ |
|---|
| 22 | - if(!(ptr->service_p = vuurmuur_opendir(debuglvl, dir_location))) |
|---|
| 23 | + if(!(ptr->service_p = vuurmuur_opendir(debuglvl, ptr->vuurmuur_config, dir_location))) |
|---|
| 24 | { |
|---|
| 25 | (void)vrprint.error(-1, "Error", "unable to open '%s', %s (in: list_textdir, opendir).", dir_location, strerror(errno)); |
|---|
| 26 | return(NULL); |
|---|
| 27 | @@ -108,7 +108,7 @@ |
|---|
| 28 | (void)vrprint.debug(__FUNC__, "service '%s', file: '%s'.", name, file_location); |
|---|
| 29 | |
|---|
| 30 | /* now stat it */ |
|---|
| 31 | - if(stat_ok(debuglvl, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 32 | + if(stat_ok(debuglvl, ptr->vuurmuur_config, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 33 | { |
|---|
| 34 | free(file_location); |
|---|
| 35 | |
|---|
| 36 | @@ -142,7 +142,7 @@ |
|---|
| 37 | if(!ptr->interface_p) |
|---|
| 38 | { |
|---|
| 39 | // open the dir |
|---|
| 40 | - if(!(ptr->interface_p = vuurmuur_opendir(debuglvl, dir_location))) |
|---|
| 41 | + if(!(ptr->interface_p = vuurmuur_opendir(debuglvl, ptr->vuurmuur_config, dir_location))) |
|---|
| 42 | { |
|---|
| 43 | (void)vrprint.error(-1, "Error", "Unable to open '%s', %s.", dir_location, strerror(errno)); |
|---|
| 44 | return(NULL); |
|---|
| 45 | @@ -185,7 +185,7 @@ |
|---|
| 46 | (void)vrprint.debug(__FUNC__, "interface '%s', file: '%s'.", name, file_location); |
|---|
| 47 | |
|---|
| 48 | /* now stat it */ |
|---|
| 49 | - if(stat_ok(debuglvl, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 50 | + if(stat_ok(debuglvl, ptr->vuurmuur_config, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 51 | { |
|---|
| 52 | free(file_location); |
|---|
| 53 | |
|---|
| 54 | @@ -227,7 +227,7 @@ |
|---|
| 55 | if(!ptr->rule_p) |
|---|
| 56 | { |
|---|
| 57 | /* open the dir */ |
|---|
| 58 | - if(!(ptr->rule_p = vuurmuur_opendir(debuglvl, dir_location))) |
|---|
| 59 | + if(!(ptr->rule_p = vuurmuur_opendir(debuglvl, ptr->vuurmuur_config, dir_location))) |
|---|
| 60 | { |
|---|
| 61 | (void)vrprint.error(-1, "Error", "unable to open '%s': %s.", |
|---|
| 62 | dir_location, strerror(errno)); |
|---|
| 63 | @@ -269,7 +269,7 @@ |
|---|
| 64 | (void)vrprint.debug(__FUNC__, "rule '%s', file: '%s'.", name, file_location); |
|---|
| 65 | |
|---|
| 66 | /* now stat it */ |
|---|
| 67 | - if(stat_ok(debuglvl, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 68 | + if(stat_ok(debuglvl, ptr->vuurmuur_config, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 69 | { |
|---|
| 70 | free(file_location); |
|---|
| 71 | |
|---|
| 72 | @@ -336,7 +336,7 @@ |
|---|
| 73 | (void)vrprint.debug(__FUNC__, "host '%s', file: '%s'.", cur_zonename, file_location); |
|---|
| 74 | |
|---|
| 75 | // now stat it |
|---|
| 76 | - if(stat_ok(debuglvl, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 77 | + if(stat_ok(debuglvl, ptr->vuurmuur_config, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 78 | { |
|---|
| 79 | free(file_location); |
|---|
| 80 | |
|---|
| 81 | @@ -392,7 +392,7 @@ |
|---|
| 82 | (void)vrprint.debug(__FUNC__, "group '%s', file: '%s'.", cur_zonename, file_location); |
|---|
| 83 | |
|---|
| 84 | // now stat it |
|---|
| 85 | - if(stat_ok(debuglvl, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 86 | + if(stat_ok(debuglvl, ptr->vuurmuur_config, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 87 | { |
|---|
| 88 | free(file_location); |
|---|
| 89 | |
|---|
| 90 | @@ -440,7 +440,7 @@ |
|---|
| 91 | (void)vrprint.debug(__FUNC__, "opening host dir: %s.", hostdir_location); |
|---|
| 92 | |
|---|
| 93 | /* this is allowed to fail, if it does, is will be NULL, and will be detected above */ |
|---|
| 94 | - ptr->host_p = vuurmuur_opendir(debuglvl, hostdir_location); |
|---|
| 95 | + ptr->host_p = vuurmuur_opendir(debuglvl, ptr->vuurmuur_config, hostdir_location); |
|---|
| 96 | |
|---|
| 97 | /* open the groupdir */ |
|---|
| 98 | snprintf(groupdir_location, sizeof(groupdir_location), "%s/%s/groups", netdir_location, dir_entry_p->d_name); |
|---|
| 99 | @@ -448,7 +448,7 @@ |
|---|
| 100 | (void)vrprint.debug(__FUNC__, "opening group dir: %s.", groupdir_location); |
|---|
| 101 | |
|---|
| 102 | /* this is allowed to fail, if it does, is will be NULL, and will be detected above */ |
|---|
| 103 | - ptr->group_p = vuurmuur_opendir(debuglvl, groupdir_location); |
|---|
| 104 | + ptr->group_p = vuurmuur_opendir(debuglvl, ptr->vuurmuur_config, groupdir_location); |
|---|
| 105 | |
|---|
| 106 | snprintf(cur_zonename, sizeof(cur_zonename), "%s.%s", ptr->cur_network, ptr->cur_zone); |
|---|
| 107 | |
|---|
| 108 | @@ -463,7 +463,7 @@ |
|---|
| 109 | (void)vrprint.debug(__FUNC__, "list_textdir: network '%s', file: '%s'.", cur_zonename, file_location); |
|---|
| 110 | |
|---|
| 111 | // now stat it |
|---|
| 112 | - if(stat_ok(debuglvl, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 113 | + if(stat_ok(debuglvl, ptr->vuurmuur_config, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 114 | { |
|---|
| 115 | free(file_location); |
|---|
| 116 | |
|---|
| 117 | @@ -512,7 +512,7 @@ |
|---|
| 118 | (void)vrprint.debug(__FUNC__, "opening: %s.", netdir_location); |
|---|
| 119 | |
|---|
| 120 | /* this is allowed to fail, if it does, is will be NULL, and will be detected above */ |
|---|
| 121 | - ptr->network_p = vuurmuur_opendir(debuglvl, netdir_location); |
|---|
| 122 | + ptr->network_p = vuurmuur_opendir(debuglvl, ptr->vuurmuur_config, netdir_location); |
|---|
| 123 | |
|---|
| 124 | // lets check against regex |
|---|
| 125 | if(validate_zonename(debuglvl, dir_entry_p->d_name, 1, NULL, NULL, NULL, ptr->zonename_reg, VALNAME_QUIET) == 0) |
|---|
| 126 | @@ -525,7 +525,7 @@ |
|---|
| 127 | (void)vrprint.debug(__FUNC__, "zone '%s', file: '%s'.", ptr->cur_zone, file_location); |
|---|
| 128 | |
|---|
| 129 | // now stat it |
|---|
| 130 | - if(stat_ok(debuglvl, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 131 | + if(stat_ok(debuglvl, ptr->vuurmuur_config, file_location, STATOK_WANT_FILE, STATOK_QUIET, STATOK_MUST_EXIST)) |
|---|
| 132 | { |
|---|
| 133 | free(file_location); |
|---|
| 134 | |
|---|
| 135 | @@ -560,7 +560,7 @@ |
|---|
| 136 | (void)vrprint.debug(__FUNC__, "opening the zonesdir."); |
|---|
| 137 | |
|---|
| 138 | // open the dir |
|---|
| 139 | - if(!(ptr->zone_p = vuurmuur_opendir(debuglvl, dir_location))) |
|---|
| 140 | + if(!(ptr->zone_p = vuurmuur_opendir(debuglvl, ptr->vuurmuur_config, dir_location))) |
|---|
| 141 | { |
|---|
| 142 | (void)vrprint.error(-1, "Error", "unable to open directory: %s: %s.", dir_location, strerror(errno)); |
|---|
| 143 | return(NULL); |
|---|
| 144 | Index: vuurmuur/libvuurmuur/plugins/textdir/textdir_plugin.c |
|---|
| 145 | =================================================================== |
|---|
| 146 | --- vuurmuur.orig/libvuurmuur/plugins/textdir/textdir_plugin.c 2009-06-02 21:35:18.000000000 +0200 |
|---|
| 147 | +++ vuurmuur/libvuurmuur/plugins/textdir/textdir_plugin.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 148 | @@ -285,7 +285,7 @@ |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | /* see if we like the permissions of the textdirroot */ |
|---|
| 152 | - if(!(stat_ok(debuglvl, ptr->textdirlocation, STATOK_WANT_DIR, STATOK_QUIET, STATOK_MUST_EXIST))) |
|---|
| 153 | + if(!(stat_ok(debuglvl, ptr->vuurmuur_config, ptr->textdirlocation, STATOK_WANT_DIR, STATOK_QUIET, STATOK_MUST_EXIST))) |
|---|
| 154 | return(-1); |
|---|
| 155 | |
|---|
| 156 | if(ptr->backend_open == 1) |
|---|
| 157 | @@ -440,7 +440,7 @@ |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | /* now stat it */ |
|---|
| 161 | - if(stat_ok(debuglvl, dir_location, STATOK_WANT_DIR, STATOK_VERBOSE, STATOK_MUST_EXIST) != 1) |
|---|
| 162 | + if(stat_ok(debuglvl, ptr->vuurmuur_config, dir_location, STATOK_WANT_DIR, STATOK_VERBOSE, STATOK_MUST_EXIST) != 1) |
|---|
| 163 | { |
|---|
| 164 | (void)vrprint.error(-1, "Error", "checking '%s' failed. Please check if the directory exists and that the permissions are ok.", |
|---|
| 165 | dir_location); |
|---|
| 166 | @@ -865,7 +865,7 @@ |
|---|
| 167 | return(-1); |
|---|
| 168 | |
|---|
| 169 | /* see if we like the file permissions */ |
|---|
| 170 | - if(!(stat_ok(debuglvl, file_location, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 171 | + if(!(stat_ok(debuglvl, ptr->vuurmuur_config, file_location, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 172 | return(-1); |
|---|
| 173 | |
|---|
| 174 | /* name splitting only needed for network and zone, as host and group just use the file_location |
|---|
| 175 | @@ -1299,7 +1299,7 @@ |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | /* now get the backend location from the configfile */ |
|---|
| 179 | - result = ask_configfile(debuglvl, "LOCATION", ptr->textdirlocation, configfile_location, sizeof(ptr->textdirlocation)); |
|---|
| 180 | + result = ask_configfile(debuglvl, ptr->vuurmuur_config, "LOCATION", ptr->textdirlocation, configfile_location, sizeof(ptr->textdirlocation)); |
|---|
| 181 | if(result < 0) |
|---|
| 182 | { |
|---|
| 183 | (void)vrprint.error(-1, "Error", "failed to get the textdir-root from: %s. Please make sure LOCATION is set (in: %s).", configfile_location, __FUNC__); |
|---|
| 184 | @@ -1322,7 +1322,7 @@ |
|---|
| 185 | |
|---|
| 186 | |
|---|
| 187 | int |
|---|
| 188 | -setup_textdir(int debuglvl, void **backend) |
|---|
| 189 | +setup_textdir(int debuglvl, const struct vuurmuur_config *vuurmuur_config, void **backend) |
|---|
| 190 | { |
|---|
| 191 | struct TextdirBackend_ *ptr = NULL; |
|---|
| 192 | |
|---|
| 193 | @@ -1352,6 +1352,8 @@ |
|---|
| 194 | ptr->servicename_reg = NULL; |
|---|
| 195 | ptr->interfacename_reg = NULL; |
|---|
| 196 | |
|---|
| 197 | + ptr->vuurmuur_config = vuurmuur_config; |
|---|
| 198 | + |
|---|
| 199 | /* return the backend pointer to the caller */ |
|---|
| 200 | *backend = (void *)ptr; |
|---|
| 201 | |
|---|
| 202 | Index: vuurmuur/libvuurmuur/plugins/textdir/textdir_plugin.h |
|---|
| 203 | =================================================================== |
|---|
| 204 | --- vuurmuur.orig/libvuurmuur/plugins/textdir/textdir_plugin.h 2009-06-02 21:35:19.000000000 +0200 |
|---|
| 205 | +++ vuurmuur/libvuurmuur/plugins/textdir/textdir_plugin.h 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 206 | @@ -67,6 +67,10 @@ |
|---|
| 207 | regex_t *zonename_reg; |
|---|
| 208 | regex_t *servicename_reg; |
|---|
| 209 | regex_t *interfacename_reg; |
|---|
| 210 | + |
|---|
| 211 | + /* Vuurmuur configuration. Some libvuurmuur functions need this to |
|---|
| 212 | + * do their work, but we shouldn't be accessing it ourselves. */ |
|---|
| 213 | + const struct vuurmuur_config *vuurmuur_config; |
|---|
| 214 | }; |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | @@ -81,6 +85,6 @@ |
|---|
| 218 | int del_textdir(const int debuglvl, void *backend, char *name, int type, int recurs); |
|---|
| 219 | int rename_textdir(const int debuglvl, void *backend, char *name, char *newname, int type); |
|---|
| 220 | int conf_textdir(const int debuglvl, void *backend); |
|---|
| 221 | -int setup_textdir(int debuglvl, void **backend); |
|---|
| 222 | +int setup_textdir(int debuglvl, const struct vuurmuur_config *vuurmuur_config, void **backend); |
|---|
| 223 | |
|---|
| 224 | #endif |
|---|
| 225 | Index: vuurmuur/libvuurmuur/plugins/textdir/textdir_tell.c |
|---|
| 226 | =================================================================== |
|---|
| 227 | --- vuurmuur.orig/libvuurmuur/plugins/textdir/textdir_tell.c 2009-06-02 21:35:19.000000000 +0200 |
|---|
| 228 | +++ vuurmuur/libvuurmuur/plugins/textdir/textdir_tell.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 229 | @@ -85,7 +85,7 @@ |
|---|
| 230 | /* |
|---|
| 231 | first open the file for reading |
|---|
| 232 | */ |
|---|
| 233 | - if(!(fp = vuurmuur_fopen(debuglvl, file_location, "r"))) |
|---|
| 234 | + if(!(fp = vuurmuur_fopen(debuglvl, ptr->vuurmuur_config, file_location, "r"))) |
|---|
| 235 | { |
|---|
| 236 | (void)vrprint.error(-1, "Error", "unable to open file '%s' for reading: %s.", file_location, strerror(errno)); |
|---|
| 237 | |
|---|
| 238 | @@ -321,7 +321,7 @@ |
|---|
| 239 | /* |
|---|
| 240 | now open the file for writing |
|---|
| 241 | */ |
|---|
| 242 | - if(!(fp = vuurmuur_fopen(debuglvl, file_location, "w+"))) |
|---|
| 243 | + if(!(fp = vuurmuur_fopen(debuglvl, ptr->vuurmuur_config, file_location, "w+"))) |
|---|
| 244 | { |
|---|
| 245 | (void)vrprint.error(-1, "Error", "unable to open file '%s' for writing: %s (in: %s).", file_location, strerror(errno), __FUNC__); |
|---|
| 246 | |
|---|
| 247 | Index: vuurmuur/libvuurmuur/src/blocklist.c |
|---|
| 248 | =================================================================== |
|---|
| 249 | --- vuurmuur.orig/libvuurmuur/src/blocklist.c 2009-06-02 21:35:18.000000000 +0200 |
|---|
| 250 | +++ vuurmuur/libvuurmuur/src/blocklist.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 251 | @@ -393,7 +393,7 @@ |
|---|
| 252 | (void)vrprint.debug(__FUNC__, "load_ips: %c, no_refcnt: %c.", load_ips, no_refcnt); |
|---|
| 253 | |
|---|
| 254 | /* open the blocklist-file */ |
|---|
| 255 | - if(!(fp = vuurmuur_fopen(debuglvl, conf.blocklist_location, "r"))) |
|---|
| 256 | + if(!(fp = vuurmuur_fopen(debuglvl, &conf, conf.blocklist_location, "r"))) |
|---|
| 257 | { |
|---|
| 258 | (void)vrprint.error(-1, "Error", "opening blockfile '%s' failed: %s (in: %s:%d).", |
|---|
| 259 | conf.blocklist_location, |
|---|
| 260 | Index: vuurmuur/libvuurmuur/src/config.c |
|---|
| 261 | =================================================================== |
|---|
| 262 | --- vuurmuur.orig/libvuurmuur/src/config.c 2009-06-02 21:36:17.000000000 +0200 |
|---|
| 263 | +++ vuurmuur/libvuurmuur/src/config.c 2009-06-02 21:40:50.000000000 +0200 |
|---|
| 264 | @@ -130,7 +130,7 @@ |
|---|
| 265 | this functions uses vuurmuur_opendir which repairs permissions if needed. |
|---|
| 266 | */ |
|---|
| 267 | int |
|---|
| 268 | -config_check_vuurmuurdir(const int debuglvl, const char *logdir) |
|---|
| 269 | +config_check_vuurmuurdir(const int debuglvl, const struct vuurmuur_config *cnf, const char *logdir) |
|---|
| 270 | { |
|---|
| 271 | DIR *dir_p = NULL; |
|---|
| 272 | |
|---|
| 273 | @@ -175,7 +175,7 @@ |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | /* try to open, error reporting is done by others */ |
|---|
| 277 | - if(!(dir_p = vuurmuur_opendir(debuglvl, logdir))) |
|---|
| 278 | + if(!(dir_p = vuurmuur_opendir(debuglvl, cnf, logdir))) |
|---|
| 279 | { |
|---|
| 280 | return(-1); |
|---|
| 281 | } |
|---|
| 282 | @@ -398,7 +398,7 @@ |
|---|
| 283 | * load the MAX_PERMISSION value. init_pre_config sets max_permission to |
|---|
| 284 | * ANY_PERMISSION, so no permission checks occur before here. |
|---|
| 285 | */ |
|---|
| 286 | - result = ask_configfile(askconfig_debuglvl, "MAX_PERMISSION", answer, cnf->configfile, sizeof(answer)); |
|---|
| 287 | + result = ask_configfile(askconfig_debuglvl, cnf, "MAX_PERMISSION", answer, cnf->configfile, sizeof(answer)); |
|---|
| 288 | if(result == 1) |
|---|
| 289 | { |
|---|
| 290 | char *endptr; |
|---|
| 291 | @@ -425,11 +425,11 @@ |
|---|
| 292 | |
|---|
| 293 | /* Now that we know the maximum permission a config file can have, |
|---|
| 294 | * check if we like the configfile */ |
|---|
| 295 | - if(!(stat_ok(debuglvl, cnf->configfile, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 296 | + if(!(stat_ok(debuglvl, cnf, cnf->configfile, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 297 | return(VR_CNF_E_FILE_PERMISSION); |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | - result = ask_configfile(askconfig_debuglvl, "SERVICES_BACKEND", cnf->serv_backend_name, cnf->configfile, sizeof(cnf->serv_backend_name)); |
|---|
| 301 | + result = ask_configfile(askconfig_debuglvl, cnf, "SERVICES_BACKEND", cnf->serv_backend_name, cnf->configfile, sizeof(cnf->serv_backend_name)); |
|---|
| 302 | if(result == 1) |
|---|
| 303 | { |
|---|
| 304 | /* ok */ |
|---|
| 305 | @@ -454,7 +454,7 @@ |
|---|
| 306 | return(VR_CNF_E_UNKNOWN_ERR); |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | - result = ask_configfile(askconfig_debuglvl, "ZONES_BACKEND", cnf->zone_backend_name, cnf->configfile, sizeof(cnf->zone_backend_name)); |
|---|
| 310 | + result = ask_configfile(askconfig_debuglvl, cnf, "ZONES_BACKEND", cnf->zone_backend_name, cnf->configfile, sizeof(cnf->zone_backend_name)); |
|---|
| 311 | if(result == 1) |
|---|
| 312 | { |
|---|
| 313 | /* ok */ |
|---|
| 314 | @@ -479,7 +479,7 @@ |
|---|
| 315 | return(VR_CNF_E_UNKNOWN_ERR); |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | - result = ask_configfile(askconfig_debuglvl, "INTERFACES_BACKEND", cnf->ifac_backend_name, cnf->configfile, sizeof(cnf->ifac_backend_name)); |
|---|
| 319 | + result = ask_configfile(askconfig_debuglvl, cnf, "INTERFACES_BACKEND", cnf->ifac_backend_name, cnf->configfile, sizeof(cnf->ifac_backend_name)); |
|---|
| 320 | if(result == 1) |
|---|
| 321 | { |
|---|
| 322 | /* ok */ |
|---|
| 323 | @@ -504,7 +504,7 @@ |
|---|
| 324 | return(VR_CNF_E_UNKNOWN_ERR); |
|---|
| 325 | |
|---|
| 326 | |
|---|
| 327 | - result = ask_configfile(askconfig_debuglvl, "RULES_BACKEND", cnf->rule_backend_name, cnf->configfile, sizeof(cnf->rule_backend_name)); |
|---|
| 328 | + result = ask_configfile(askconfig_debuglvl, cnf, "RULES_BACKEND", cnf->rule_backend_name, cnf->configfile, sizeof(cnf->rule_backend_name)); |
|---|
| 329 | if(result == 1) |
|---|
| 330 | { |
|---|
| 331 | /* ok */ |
|---|
| 332 | @@ -529,7 +529,7 @@ |
|---|
| 333 | return(VR_CNF_E_UNKNOWN_ERR); |
|---|
| 334 | |
|---|
| 335 | |
|---|
| 336 | - result = ask_configfile(askconfig_debuglvl, "RULESFILE", cnf->rules_location, cnf->configfile, sizeof(cnf->rules_location)); |
|---|
| 337 | + result = ask_configfile(askconfig_debuglvl, cnf, "RULESFILE", cnf->rules_location, cnf->configfile, sizeof(cnf->rules_location)); |
|---|
| 338 | if(result == 1) |
|---|
| 339 | { |
|---|
| 340 | if(cnf->rules_location[0] == '\0') |
|---|
| 341 | @@ -577,7 +577,7 @@ |
|---|
| 342 | |
|---|
| 343 | sanitize_path(debuglvl, cnf->rules_location, sizeof(cnf->rules_location)); |
|---|
| 344 | |
|---|
| 345 | - result = ask_configfile(askconfig_debuglvl, "BLOCKLISTFILE", cnf->blocklist_location, cnf->configfile, sizeof(cnf->blocklist_location)); |
|---|
| 346 | + result = ask_configfile(askconfig_debuglvl, cnf, "BLOCKLISTFILE", cnf->blocklist_location, cnf->configfile, sizeof(cnf->blocklist_location)); |
|---|
| 347 | if(result == 1) |
|---|
| 348 | { |
|---|
| 349 | /* ok, found */ |
|---|
| 350 | @@ -630,7 +630,7 @@ |
|---|
| 351 | cnf->old_rulecreation_method = FALSE; |
|---|
| 352 | |
|---|
| 353 | /* DYN_INT_CHECK */ |
|---|
| 354 | - result = ask_configfile(askconfig_debuglvl, "DYN_INT_CHECK", answer, cnf->configfile, sizeof(answer)); |
|---|
| 355 | + result = ask_configfile(askconfig_debuglvl, cnf, "DYN_INT_CHECK", answer, cnf->configfile, sizeof(answer)); |
|---|
| 356 | if(result == 1) |
|---|
| 357 | { |
|---|
| 358 | /* ok, found */ |
|---|
| 359 | @@ -659,7 +659,7 @@ |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | /* LOG_POLICY_LIMIT */ |
|---|
| 363 | - result = ask_configfile(askconfig_debuglvl, "DYN_INT_INTERVAL", answer, cnf->configfile, sizeof(answer)); |
|---|
| 364 | + result = ask_configfile(askconfig_debuglvl, cnf, "DYN_INT_INTERVAL", answer, cnf->configfile, sizeof(answer)); |
|---|
| 365 | if(result == 1) |
|---|
| 366 | { |
|---|
| 367 | /* ok, found */ |
|---|
| 368 | @@ -685,7 +685,7 @@ |
|---|
| 369 | |
|---|
| 370 | |
|---|
| 371 | /* LOG_BLOCKLIST */ |
|---|
| 372 | - result = ask_configfile(askconfig_debuglvl, "LOG_BLOCKLIST", answer, cnf->configfile, sizeof(answer)); |
|---|
| 373 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOG_BLOCKLIST", answer, cnf->configfile, sizeof(answer)); |
|---|
| 374 | if(result == 1) |
|---|
| 375 | { |
|---|
| 376 | /* ok, found */ |
|---|
| 377 | @@ -715,7 +715,7 @@ |
|---|
| 378 | |
|---|
| 379 | |
|---|
| 380 | /* LOG_INVALID */ |
|---|
| 381 | - result = ask_configfile(askconfig_debuglvl, "LOG_INVALID", answer, cnf->configfile, sizeof(answer)); |
|---|
| 382 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOG_INVALID", answer, cnf->configfile, sizeof(answer)); |
|---|
| 383 | if(result == 1) |
|---|
| 384 | { |
|---|
| 385 | /* ok, found */ |
|---|
| 386 | @@ -745,7 +745,7 @@ |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | /* LOG_NO_SYN */ |
|---|
| 390 | - result = ask_configfile(askconfig_debuglvl, "LOG_NO_SYN", answer, cnf->configfile, sizeof(answer)); |
|---|
| 391 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOG_NO_SYN", answer, cnf->configfile, sizeof(answer)); |
|---|
| 392 | if(result == 1) |
|---|
| 393 | { |
|---|
| 394 | /* ok, found */ |
|---|
| 395 | @@ -775,7 +775,7 @@ |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | /* LOG_PROBES */ |
|---|
| 399 | - result = ask_configfile(askconfig_debuglvl, "LOG_PROBES", answer, cnf->configfile, sizeof(answer)); |
|---|
| 400 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOG_PROBES", answer, cnf->configfile, sizeof(answer)); |
|---|
| 401 | if(result == 1) |
|---|
| 402 | { |
|---|
| 403 | /* ok, found */ |
|---|
| 404 | @@ -805,7 +805,7 @@ |
|---|
| 405 | |
|---|
| 406 | |
|---|
| 407 | /* LOG_FRAG */ |
|---|
| 408 | - result = ask_configfile(askconfig_debuglvl, "LOG_FRAG", answer, cnf->configfile, sizeof(answer)); |
|---|
| 409 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOG_FRAG", answer, cnf->configfile, sizeof(answer)); |
|---|
| 410 | if(result == 1) |
|---|
| 411 | { |
|---|
| 412 | /* ok, found */ |
|---|
| 413 | @@ -835,7 +835,7 @@ |
|---|
| 414 | |
|---|
| 415 | |
|---|
| 416 | /* USE_SYN_LIMIT */ |
|---|
| 417 | - result = ask_configfile(askconfig_debuglvl, "USE_SYN_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 418 | + result = ask_configfile(askconfig_debuglvl, cnf, "USE_SYN_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 419 | if(result == 1) |
|---|
| 420 | { |
|---|
| 421 | /* ok, found */ |
|---|
| 422 | @@ -864,7 +864,7 @@ |
|---|
| 423 | return(VR_CNF_E_UNKNOWN_ERR); |
|---|
| 424 | |
|---|
| 425 | /* SYN_LIMIT */ |
|---|
| 426 | - result = ask_configfile(askconfig_debuglvl, "SYN_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 427 | + result = ask_configfile(askconfig_debuglvl, cnf, "SYN_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 428 | if(result == 1) |
|---|
| 429 | { |
|---|
| 430 | /* ok, found */ |
|---|
| 431 | @@ -900,7 +900,7 @@ |
|---|
| 432 | |
|---|
| 433 | |
|---|
| 434 | /* SYN_LIMIT_BURST */ |
|---|
| 435 | - result = ask_configfile(askconfig_debuglvl, "SYN_LIMIT_BURST", answer, cnf->configfile, sizeof(answer)); |
|---|
| 436 | + result = ask_configfile(askconfig_debuglvl, cnf, "SYN_LIMIT_BURST", answer, cnf->configfile, sizeof(answer)); |
|---|
| 437 | if(result == 1) |
|---|
| 438 | { |
|---|
| 439 | /* ok, found */ |
|---|
| 440 | @@ -936,7 +936,7 @@ |
|---|
| 441 | |
|---|
| 442 | |
|---|
| 443 | /* USE_UDP_LIMIT */ |
|---|
| 444 | - result = ask_configfile(askconfig_debuglvl, "USE_UDP_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 445 | + result = ask_configfile(askconfig_debuglvl, cnf, "USE_UDP_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 446 | if(result == 1) |
|---|
| 447 | { |
|---|
| 448 | /* ok, found */ |
|---|
| 449 | @@ -965,7 +965,7 @@ |
|---|
| 450 | return(VR_CNF_E_UNKNOWN_ERR); |
|---|
| 451 | |
|---|
| 452 | /* UDP_LIMIT */ |
|---|
| 453 | - result = ask_configfile(askconfig_debuglvl, "UDP_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 454 | + result = ask_configfile(askconfig_debuglvl, cnf, "UDP_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 455 | if(result == 1) |
|---|
| 456 | { |
|---|
| 457 | /* ok, found */ |
|---|
| 458 | @@ -1001,7 +1001,7 @@ |
|---|
| 459 | |
|---|
| 460 | |
|---|
| 461 | /* UDP_LIMIT_BURST */ |
|---|
| 462 | - result = ask_configfile(askconfig_debuglvl, "UDP_LIMIT_BURST", answer, cnf->configfile, sizeof(answer)); |
|---|
| 463 | + result = ask_configfile(askconfig_debuglvl, cnf, "UDP_LIMIT_BURST", answer, cnf->configfile, sizeof(answer)); |
|---|
| 464 | if(result == 1) |
|---|
| 465 | { |
|---|
| 466 | /* ok, found */ |
|---|
| 467 | @@ -1037,7 +1037,7 @@ |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | /* LOG_POLICY */ |
|---|
| 471 | - result = ask_configfile(askconfig_debuglvl, "LOG_POLICY", answer, cnf->configfile, sizeof(answer)); |
|---|
| 472 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOG_POLICY", answer, cnf->configfile, sizeof(answer)); |
|---|
| 473 | if(result == 1) |
|---|
| 474 | { |
|---|
| 475 | /* ok, found */ |
|---|
| 476 | @@ -1069,7 +1069,7 @@ |
|---|
| 477 | |
|---|
| 478 | |
|---|
| 479 | /* LOG_POLICY_LIMIT */ |
|---|
| 480 | - result = ask_configfile(askconfig_debuglvl, "LOG_POLICY_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 481 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOG_POLICY_LIMIT", answer, cnf->configfile, sizeof(answer)); |
|---|
| 482 | if(result == 1) |
|---|
| 483 | { |
|---|
| 484 | /* ok, found */ |
|---|
| 485 | @@ -1102,7 +1102,7 @@ |
|---|
| 486 | |
|---|
| 487 | |
|---|
| 488 | /* LOG_TCP_OPTIONS */ |
|---|
| 489 | - result = ask_configfile(askconfig_debuglvl, "LOG_TCP_OPTIONS", answer, cnf->configfile, sizeof(answer)); |
|---|
| 490 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOG_TCP_OPTIONS", answer, cnf->configfile, sizeof(answer)); |
|---|
| 491 | if(result == 1) |
|---|
| 492 | { |
|---|
| 493 | /* ok, found */ |
|---|
| 494 | @@ -1132,7 +1132,7 @@ |
|---|
| 495 | |
|---|
| 496 | |
|---|
| 497 | /* PROTECT_SYNCOOKIES */ |
|---|
| 498 | - result = ask_configfile(askconfig_debuglvl, "PROTECT_SYNCOOKIE", answer, cnf->configfile, sizeof(answer)); |
|---|
| 499 | + result = ask_configfile(askconfig_debuglvl, cnf, "PROTECT_SYNCOOKIE", answer, cnf->configfile, sizeof(answer)); |
|---|
| 500 | if(result == 1) |
|---|
| 501 | { |
|---|
| 502 | /* ok, found */ |
|---|
| 503 | @@ -1164,7 +1164,7 @@ |
|---|
| 504 | |
|---|
| 505 | |
|---|
| 506 | /* PROTECT_ECHOBROADCAST */ |
|---|
| 507 | - result = ask_configfile(askconfig_debuglvl, "PROTECT_ECHOBROADCAST", answer, cnf->configfile, sizeof(answer)); |
|---|
| 508 | + result = ask_configfile(askconfig_debuglvl, cnf, "PROTECT_ECHOBROADCAST", answer, cnf->configfile, sizeof(answer)); |
|---|
| 509 | if(result == 1) |
|---|
| 510 | { |
|---|
| 511 | /* ok, found */ |
|---|
| 512 | @@ -1195,7 +1195,7 @@ |
|---|
| 513 | return(VR_CNF_E_UNKNOWN_ERR); |
|---|
| 514 | |
|---|
| 515 | |
|---|
| 516 | - result = ask_configfile(askconfig_debuglvl, "IPTABLES", cnf->iptables_location, cnf->configfile, sizeof(cnf->iptables_location)); |
|---|
| 517 | + result = ask_configfile(askconfig_debuglvl, cnf, "IPTABLES", cnf->iptables_location, cnf->configfile, sizeof(cnf->iptables_location)); |
|---|
| 518 | if(result == 1) |
|---|
| 519 | { |
|---|
| 520 | /* ok */ |
|---|
| 521 | @@ -1219,7 +1219,7 @@ |
|---|
| 522 | sanitize_path(debuglvl, cnf->iptables_location, sizeof(cnf->iptables_location)); |
|---|
| 523 | |
|---|
| 524 | |
|---|
| 525 | - result = ask_configfile(askconfig_debuglvl, "IPTABLES_RESTORE", cnf->iptablesrestore_location, cnf->configfile, sizeof(cnf->iptablesrestore_location)); |
|---|
| 526 | + result = ask_configfile(askconfig_debuglvl, cnf, "IPTABLES_RESTORE", cnf->iptablesrestore_location, cnf->configfile, sizeof(cnf->iptablesrestore_location)); |
|---|
| 527 | if(result == 1) |
|---|
| 528 | { |
|---|
| 529 | /* ok */ |
|---|
| 530 | @@ -1243,7 +1243,7 @@ |
|---|
| 531 | sanitize_path(debuglvl, cnf->iptablesrestore_location, sizeof(cnf->iptablesrestore_location)); |
|---|
| 532 | |
|---|
| 533 | |
|---|
| 534 | - result = ask_configfile(askconfig_debuglvl, "CONNTRACK", cnf->conntrack_location, cnf->configfile, sizeof(cnf->conntrack_location)); |
|---|
| 535 | + result = ask_configfile(askconfig_debuglvl, cnf, "CONNTRACK", cnf->conntrack_location, cnf->configfile, sizeof(cnf->conntrack_location)); |
|---|
| 536 | if(result == 1) |
|---|
| 537 | { |
|---|
| 538 | /* ok */ |
|---|
| 539 | @@ -1268,7 +1268,7 @@ |
|---|
| 540 | sanitize_path(debuglvl, cnf->conntrack_location, sizeof(cnf->conntrack_location)); |
|---|
| 541 | |
|---|
| 542 | |
|---|
| 543 | - result = ask_configfile(askconfig_debuglvl, "TC", cnf->tc_location, cnf->configfile, sizeof(cnf->tc_location)); |
|---|
| 544 | + result = ask_configfile(askconfig_debuglvl, cnf, "TC", cnf->tc_location, cnf->configfile, sizeof(cnf->tc_location)); |
|---|
| 545 | if(result == 1) |
|---|
| 546 | { |
|---|
| 547 | /* ok */ |
|---|
| 548 | @@ -1293,7 +1293,7 @@ |
|---|
| 549 | sanitize_path(debuglvl, cnf->tc_location, sizeof(cnf->tc_location)); |
|---|
| 550 | |
|---|
| 551 | |
|---|
| 552 | - result = ask_configfile(askconfig_debuglvl, "MODPROBE", cnf->modprobe_location, cnf->configfile, sizeof(cnf->modprobe_location)); |
|---|
| 553 | + result = ask_configfile(askconfig_debuglvl, cnf, "MODPROBE", cnf->modprobe_location, cnf->configfile, sizeof(cnf->modprobe_location)); |
|---|
| 554 | if(result == 1) |
|---|
| 555 | { |
|---|
| 556 | /* ok */ |
|---|
| 557 | @@ -1315,7 +1315,7 @@ |
|---|
| 558 | |
|---|
| 559 | |
|---|
| 560 | /* LOAD_MODULES */ |
|---|
| 561 | - result = ask_configfile(askconfig_debuglvl, "LOAD_MODULES", answer, cnf->configfile, sizeof(answer)); |
|---|
| 562 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOAD_MODULES", answer, cnf->configfile, sizeof(answer)); |
|---|
| 563 | if(result == 1) |
|---|
| 564 | { |
|---|
| 565 | /* ok, found */ |
|---|
| 566 | @@ -1343,7 +1343,7 @@ |
|---|
| 567 | |
|---|
| 568 | |
|---|
| 569 | /* MODULES_WAIT_TIME */ |
|---|
| 570 | - result = ask_configfile(askconfig_debuglvl, "MODULES_WAIT_TIME", answer, cnf->configfile, sizeof(answer)); |
|---|
| 571 | + result = ask_configfile(askconfig_debuglvl, cnf, "MODULES_WAIT_TIME", answer, cnf->configfile, sizeof(answer)); |
|---|
| 572 | if(result == 1) |
|---|
| 573 | { |
|---|
| 574 | /* ok, found */ |
|---|
| 575 | @@ -1373,7 +1373,7 @@ |
|---|
| 576 | /* check if the configfile value is overridden by the commandline */ |
|---|
| 577 | if(cnf->loglevel_cmdline == FALSE) |
|---|
| 578 | { |
|---|
| 579 | - result = ask_configfile(askconfig_debuglvl, "LOGLEVEL", cnf->loglevel, cnf->configfile, sizeof(cnf->loglevel)); |
|---|
| 580 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOGLEVEL", cnf->loglevel, cnf->configfile, sizeof(cnf->loglevel)); |
|---|
| 581 | if(result == 1) |
|---|
| 582 | { |
|---|
| 583 | // ok |
|---|
| 584 | @@ -1392,7 +1392,7 @@ |
|---|
| 585 | |
|---|
| 586 | |
|---|
| 587 | /* systemlog */ |
|---|
| 588 | - result = ask_configfile(askconfig_debuglvl, "SYSTEMLOG", cnf->systemlog_location, cnf->configfile, sizeof(cnf->systemlog_location)); |
|---|
| 589 | + result = ask_configfile(askconfig_debuglvl, cnf, "SYSTEMLOG", cnf->systemlog_location, cnf->configfile, sizeof(cnf->systemlog_location)); |
|---|
| 590 | if (result == 1 ) |
|---|
| 591 | { |
|---|
| 592 | /* ok */ |
|---|
| 593 | @@ -1420,7 +1420,7 @@ |
|---|
| 594 | |
|---|
| 595 | |
|---|
| 596 | /* get the logfile dir */ |
|---|
| 597 | - result = ask_configfile(askconfig_debuglvl, "LOGDIR", cnf->vuurmuur_logdir_location, cnf->configfile, sizeof(cnf->vuurmuur_logdir_location)); |
|---|
| 598 | + result = ask_configfile(askconfig_debuglvl, cnf, "LOGDIR", cnf->vuurmuur_logdir_location, cnf->configfile, sizeof(cnf->vuurmuur_logdir_location)); |
|---|
| 599 | if(result == 1) |
|---|
| 600 | { |
|---|
| 601 | if(cnf->verbose_out == TRUE && askconfig_debuglvl >= LOW) |
|---|
| 602 | @@ -1574,7 +1574,7 @@ |
|---|
| 603 | -1: error |
|---|
| 604 | */ |
|---|
| 605 | int |
|---|
| 606 | -ask_configfile(const int debuglvl, char *question, char *answer_ptr, char *file_location, size_t size) |
|---|
| 607 | +ask_configfile(const int debuglvl, const struct vuurmuur_config *cnf, char *question, char *answer_ptr, char *file_location, size_t size) |
|---|
| 608 | { |
|---|
| 609 | int retval = 0; |
|---|
| 610 | size_t i = 0, |
|---|
| 611 | @@ -1589,7 +1589,7 @@ |
|---|
| 612 | if(!question || !file_location || size == 0) |
|---|
| 613 | return(-1); |
|---|
| 614 | |
|---|
| 615 | - if(!(fp = vuurmuur_fopen(debuglvl, file_location,"r"))) |
|---|
| 616 | + if(!(fp = vuurmuur_fopen(debuglvl, cnf, file_location,"r"))) |
|---|
| 617 | { |
|---|
| 618 | (void)vrprint.error(-1, "Error", "unable to open configfile '%s': %s (in: ask_configfile).", file_location, strerror(errno)); |
|---|
| 619 | return(-1); |
|---|
| 620 | Index: vuurmuur/libvuurmuur/src/io.c |
|---|
| 621 | =================================================================== |
|---|
| 622 | --- vuurmuur.orig/libvuurmuur/src/io.c 2009-06-02 21:35:18.000000000 +0200 |
|---|
| 623 | +++ vuurmuur/libvuurmuur/src/io.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 624 | @@ -34,12 +34,12 @@ |
|---|
| 625 | The path and mode parameters are identical to the fopen(3) libc function. |
|---|
| 626 | */ |
|---|
| 627 | FILE * |
|---|
| 628 | -vuurmuur_fopen(const int debuglvl, const char *path, const char *mode) |
|---|
| 629 | +vuurmuur_fopen(const int debuglvl, const struct vuurmuur_config *cnf, const char *path, const char *mode) |
|---|
| 630 | { |
|---|
| 631 | FILE *fp=NULL; |
|---|
| 632 | |
|---|
| 633 | // Stat the file |
|---|
| 634 | - if (!stat_ok(debuglvl, path, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_ALLOW_NOTFOUND)) |
|---|
| 635 | + if (!stat_ok(debuglvl, cnf, path, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_ALLOW_NOTFOUND)) |
|---|
| 636 | // File not OK? Don't open it. stat_ok will have printed an error message already. |
|---|
| 637 | return NULL; |
|---|
| 638 | |
|---|
| 639 | @@ -57,11 +57,11 @@ |
|---|
| 640 | |
|---|
| 641 | |
|---|
| 642 | DIR * |
|---|
| 643 | -vuurmuur_opendir(const int debuglvl, const char *name) |
|---|
| 644 | +vuurmuur_opendir(const int debuglvl, const struct vuurmuur_config *cnf, const char *name) |
|---|
| 645 | { |
|---|
| 646 | DIR *dir_p = NULL; |
|---|
| 647 | |
|---|
| 648 | - if(!(stat_ok(debuglvl, name, STATOK_WANT_DIR, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 649 | + if(!(stat_ok(debuglvl, cnf, name, STATOK_WANT_DIR, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 650 | return(NULL); |
|---|
| 651 | |
|---|
| 652 | /* finally try to open */ |
|---|
| 653 | @@ -101,7 +101,7 @@ |
|---|
| 654 | 0: file not ok |
|---|
| 655 | */ |
|---|
| 656 | int |
|---|
| 657 | -stat_ok(const int debuglvl, const char *file_loc, char type, char output, char must_exist) |
|---|
| 658 | +stat_ok(const int debuglvl, const struct vuurmuur_config *cnf, const char *file_loc, char type, char output, char must_exist) |
|---|
| 659 | { |
|---|
| 660 | struct stat stat_buf; |
|---|
| 661 | mode_t max, perm; |
|---|
| 662 | @@ -169,12 +169,12 @@ |
|---|
| 663 | return(0); |
|---|
| 664 | } |
|---|
| 665 | |
|---|
| 666 | - if (conf.max_permission != ANY_PERMISSION) |
|---|
| 667 | + if (cnf->max_permission != ANY_PERMISSION) |
|---|
| 668 | { |
|---|
| 669 | /* Extract the permission bits from the mode */ |
|---|
| 670 | perm = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); |
|---|
| 671 | /* Maximum permissions. Remove +x for files */ |
|---|
| 672 | - max = conf.max_permission; |
|---|
| 673 | + max = cnf->max_permission; |
|---|
| 674 | if (S_ISREG(stat_buf.st_mode) == 1) |
|---|
| 675 | max &= ~(S_IXUSR|S_IXGRP|S_IXOTH); |
|---|
| 676 | |
|---|
| 677 | @@ -296,7 +296,7 @@ |
|---|
| 678 | Returns the pointer to the file, or NULL if failed. |
|---|
| 679 | */ |
|---|
| 680 | FILE * |
|---|
| 681 | -rules_file_open(const int debuglvl, const char *path, const char *mode, int caller) |
|---|
| 682 | +rules_file_open(const int debuglvl, const struct vuurmuur_config *cnf, const char *path, const char *mode, int caller) |
|---|
| 683 | { |
|---|
| 684 | FILE *lock_fp = NULL, |
|---|
| 685 | *fp = NULL; |
|---|
| 686 | @@ -387,7 +387,7 @@ |
|---|
| 687 | free(lock_path); |
|---|
| 688 | } |
|---|
| 689 | |
|---|
| 690 | - fp = vuurmuur_fopen(debuglvl, path, mode); |
|---|
| 691 | + fp = vuurmuur_fopen(debuglvl, cnf, path, mode); |
|---|
| 692 | return(fp); |
|---|
| 693 | } |
|---|
| 694 | |
|---|
| 695 | Index: vuurmuur/libvuurmuur/src/rules.c |
|---|
| 696 | =================================================================== |
|---|
| 697 | --- vuurmuur.orig/libvuurmuur/src/rules.c 2009-06-02 21:35:18.000000000 +0200 |
|---|
| 698 | +++ vuurmuur/libvuurmuur/src/rules.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 699 | @@ -1354,7 +1354,7 @@ |
|---|
| 700 | TODO: mask! it should we only read/write for owner root, and nothing to the others |
|---|
| 701 | */ |
|---|
| 702 | static int |
|---|
| 703 | -rules_write_file(const int debuglvl, Rules *rules, const char *rulesfile_location) |
|---|
| 704 | +rules_write_file(const int debuglvl, const struct vuurmuur_config *cnf, Rules *rules, const char *rulesfile_location) |
|---|
| 705 | { |
|---|
| 706 | FILE *fp = NULL; |
|---|
| 707 | int retval = 0; |
|---|
| 708 | @@ -1371,7 +1371,7 @@ |
|---|
| 709 | } |
|---|
| 710 | |
|---|
| 711 | /* open the rulesfile */ |
|---|
| 712 | - if(!(fp = rules_file_open(debuglvl, rulesfile_location, "w+", 0))) |
|---|
| 713 | + if(!(fp = rules_file_open(debuglvl, cnf, rulesfile_location, "w+", 0))) |
|---|
| 714 | { |
|---|
| 715 | (void)vrprint.error(-1, "Error", "opening rulesfile '%s' failed: %s (in: %s).", |
|---|
| 716 | rulesfile_location, strerror(errno), __FUNC__); |
|---|
| 717 | @@ -1441,7 +1441,7 @@ |
|---|
| 718 | |
|---|
| 719 | if(rules->old_rulesfile_used == TRUE) |
|---|
| 720 | { |
|---|
| 721 | - result = rules_write_file(debuglvl, rules, cnf->rules_location); |
|---|
| 722 | + result = rules_write_file(debuglvl, cnf, rules, cnf->rules_location); |
|---|
| 723 | if(result < 0) |
|---|
| 724 | return(-1); |
|---|
| 725 | } |
|---|
| 726 | Index: vuurmuur/libvuurmuur/src/vuurmuur.h |
|---|
| 727 | =================================================================== |
|---|
| 728 | --- vuurmuur.orig/libvuurmuur/src/vuurmuur.h 2009-06-02 21:35:18.000000000 +0200 |
|---|
| 729 | +++ vuurmuur/libvuurmuur/src/vuurmuur.h 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 730 | @@ -1413,13 +1413,13 @@ |
|---|
| 731 | /* |
|---|
| 732 | io.c |
|---|
| 733 | */ |
|---|
| 734 | -FILE *vuurmuur_fopen(const int, const char *path, const char *mode); |
|---|
| 735 | -DIR *vuurmuur_opendir(const int, const char *); |
|---|
| 736 | -int stat_ok(const int, const char *, char, char, char); |
|---|
| 737 | +FILE *vuurmuur_fopen(const int, const struct vuurmuur_config *, const char *path, const char *mode); |
|---|
| 738 | +DIR *vuurmuur_opendir(const int, const struct vuurmuur_config *, const char *); |
|---|
| 739 | +int stat_ok(const int, const struct vuurmuur_config *, const char *, char, char, char); |
|---|
| 740 | int check_pidfile(char *pidfile_location); |
|---|
| 741 | int create_pidfile(char *pidfile_location, int shm_id); |
|---|
| 742 | int remove_pidfile(char *pidfile_location); |
|---|
| 743 | -FILE * rules_file_open(const int, const char *path, const char *mode, int caller); |
|---|
| 744 | +FILE * rules_file_open(const int, const struct vuurmuur_config *cnf, const char *path, const char *mode, int caller); |
|---|
| 745 | int rules_file_close(FILE *file, const char *path); |
|---|
| 746 | int pipe_command(const int, struct vuurmuur_config *, char *, char); |
|---|
| 747 | int libvuurmuur_exec_command(const int, struct vuurmuur_config *, char *, char **, char *); |
|---|
| 748 | @@ -1433,13 +1433,13 @@ |
|---|
| 749 | */ |
|---|
| 750 | int config_set_log_names(const int debuglvl, struct vuurmuur_config *cnf); |
|---|
| 751 | int config_check_logdir(const int debuglvl, const char *logdir); |
|---|
| 752 | -int config_check_vuurmuurdir(const int debuglvl, const char *logdir); |
|---|
| 753 | +int config_check_vuurmuurdir(const int debuglvl, const struct vuurmuur_config *, const char *logdir); |
|---|
| 754 | int check_iptables_command(const int, struct vuurmuur_config *, char *, char); |
|---|
| 755 | int check_iptablesrestore_command(const int, struct vuurmuur_config *, char *, char); |
|---|
| 756 | int check_tc_command(const int, struct vuurmuur_config *, char *, char); |
|---|
| 757 | int init_config(const int, struct vuurmuur_config *cnf); |
|---|
| 758 | int reload_config(const int, struct vuurmuur_config *); |
|---|
| 759 | -int ask_configfile(const int debuglvl, char *question, char *answer_ptr, char *file_location, size_t size); |
|---|
| 760 | +int ask_configfile(const int debuglvl, const struct vuurmuur_config *, char *question, char *answer_ptr, char *file_location, size_t size); |
|---|
| 761 | int write_configfile(const int debuglvl, char *file_location); |
|---|
| 762 | int pre_init_config(struct vuurmuur_config *); |
|---|
| 763 | |
|---|
| 764 | @@ -1610,7 +1610,7 @@ |
|---|
| 765 | int (*conf)(int debuglvl, void *backend); |
|---|
| 766 | |
|---|
| 767 | /* setup: alloc memory and set defaults */ |
|---|
| 768 | - int (*setup)(int debuglvl, void **backend); |
|---|
| 769 | + int (*setup)(int debuglvl, const struct vuurmuur_config *cnf, void **backend); |
|---|
| 770 | |
|---|
| 771 | /* version */ |
|---|
| 772 | char *version; |
|---|
| 773 | Index: vuurmuur/vuurmuur-conf/src/config.c |
|---|
| 774 | =================================================================== |
|---|
| 775 | --- vuurmuur.orig/vuurmuur-conf/src/config.c 2009-06-02 21:35:19.000000000 +0200 |
|---|
| 776 | +++ vuurmuur/vuurmuur-conf/src/config.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 777 | @@ -114,12 +114,12 @@ |
|---|
| 778 | |
|---|
| 779 | |
|---|
| 780 | /* check if we like the configfile */ |
|---|
| 781 | - if(!(stat_ok(debuglvl, configfile_location, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 782 | + if(!(stat_ok(debuglvl, &conf, configfile_location, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 783 | return(VR_CNF_E_FILE_PERMISSION); |
|---|
| 784 | |
|---|
| 785 | |
|---|
| 786 | /* ADVANCED_MODE */ |
|---|
| 787 | - result = ask_configfile(debuglvl, "ADVANCED_MODE", answer, configfile_location, sizeof(answer)); |
|---|
| 788 | + result = ask_configfile(debuglvl, &conf, "ADVANCED_MODE", answer, configfile_location, sizeof(answer)); |
|---|
| 789 | if(result == 1) |
|---|
| 790 | { |
|---|
| 791 | /* ok, found */ |
|---|
| 792 | @@ -153,7 +153,7 @@ |
|---|
| 793 | |
|---|
| 794 | |
|---|
| 795 | /* MAINMENU_STATUS */ |
|---|
| 796 | - result = ask_configfile(debuglvl, "MAINMENU_STATUS", answer, configfile_location, sizeof(answer)); |
|---|
| 797 | + result = ask_configfile(debuglvl, &conf, "MAINMENU_STATUS", answer, configfile_location, sizeof(answer)); |
|---|
| 798 | if(result == 1) |
|---|
| 799 | { |
|---|
| 800 | /* ok, found */ |
|---|
| 801 | @@ -187,7 +187,7 @@ |
|---|
| 802 | |
|---|
| 803 | |
|---|
| 804 | /* IPTRAFVOL */ |
|---|
| 805 | - result = ask_configfile(debuglvl, "IPTRAFVOL", cnf->iptrafvol_location, configfile_location, sizeof(cnf->iptrafvol_location)); |
|---|
| 806 | + result = ask_configfile(debuglvl, &conf, "IPTRAFVOL", cnf->iptrafvol_location, configfile_location, sizeof(cnf->iptrafvol_location)); |
|---|
| 807 | if(result == 1) |
|---|
| 808 | { |
|---|
| 809 | /* ok */ |
|---|
| 810 | @@ -215,7 +215,7 @@ |
|---|
| 811 | |
|---|
| 812 | |
|---|
| 813 | /* NEWRULE_LOG */ |
|---|
| 814 | - result = ask_configfile(debuglvl, "NEWRULE_LOG", answer, configfile_location, sizeof(answer)); |
|---|
| 815 | + result = ask_configfile(debuglvl, &conf, "NEWRULE_LOG", answer, configfile_location, sizeof(answer)); |
|---|
| 816 | if(result == 1) |
|---|
| 817 | { |
|---|
| 818 | /* ok, found */ |
|---|
| 819 | @@ -249,7 +249,7 @@ |
|---|
| 820 | |
|---|
| 821 | |
|---|
| 822 | /* NEWRULE_LOGLIMIT */ |
|---|
| 823 | - result = ask_configfile(debuglvl, "NEWRULE_LOGLIMIT", answer, configfile_location, sizeof(answer)); |
|---|
| 824 | + result = ask_configfile(debuglvl, &conf, "NEWRULE_LOGLIMIT", answer, configfile_location, sizeof(answer)); |
|---|
| 825 | if(result == 1) |
|---|
| 826 | { |
|---|
| 827 | /* ok, found */ |
|---|
| 828 | @@ -283,7 +283,7 @@ |
|---|
| 829 | |
|---|
| 830 | |
|---|
| 831 | /* LOGVIEW_BUFSIZE */ |
|---|
| 832 | - result = ask_configfile(debuglvl, "LOGVIEW_BUFSIZE", answer, configfile_location, sizeof(answer)); |
|---|
| 833 | + result = ask_configfile(debuglvl, &conf, "LOGVIEW_BUFSIZE", answer, configfile_location, sizeof(answer)); |
|---|
| 834 | if(result == 1) |
|---|
| 835 | { |
|---|
| 836 | /* ok, found */ |
|---|
| 837 | Index: vuurmuur/vuurmuur/vuurmuur/ruleset.c |
|---|
| 838 | =================================================================== |
|---|
| 839 | --- vuurmuur.orig/vuurmuur/vuurmuur/ruleset.c 2009-06-02 21:35:19.000000000 +0200 |
|---|
| 840 | +++ vuurmuur/vuurmuur/vuurmuur/ruleset.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 841 | @@ -1156,7 +1156,7 @@ |
|---|
| 842 | */ |
|---|
| 843 | |
|---|
| 844 | /* stat_ok */ |
|---|
| 845 | - if(!(stat_ok(debuglvl, path_to_ruleset, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 846 | + if(!(stat_ok(debuglvl, cnf, path_to_ruleset, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 847 | { |
|---|
| 848 | (void)vrprint.error(-1, "Error", "serious file problem (in: %s:%d).", __FUNC__, __LINE__); |
|---|
| 849 | return(-1); |
|---|
| 850 | @@ -1208,7 +1208,7 @@ |
|---|
| 851 | */ |
|---|
| 852 | |
|---|
| 853 | /* stat_ok */ |
|---|
| 854 | - if(!(stat_ok(debuglvl, path_to_ruleset, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 855 | + if(!(stat_ok(debuglvl, cnf, path_to_ruleset, STATOK_WANT_FILE, STATOK_VERBOSE, STATOK_MUST_EXIST))) |
|---|
| 856 | { |
|---|
| 857 | (void)vrprint.error(-1, "Error", "serious file problem (in: %s:%d).", __FUNC__, __LINE__); |
|---|
| 858 | return(-1); |
|---|
| 859 | Index: vuurmuur/vuurmuur/vuurmuur_log/logfile.c |
|---|
| 860 | =================================================================== |
|---|
| 861 | --- vuurmuur.orig/vuurmuur/vuurmuur_log/logfile.c 2009-06-02 21:35:19.000000000 +0200 |
|---|
| 862 | +++ vuurmuur/vuurmuur/vuurmuur_log/logfile.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 863 | @@ -119,7 +119,7 @@ |
|---|
| 864 | |
|---|
| 865 | |
|---|
| 866 | FILE * |
|---|
| 867 | -open_logfile(const int debuglvl, const char *path, const char *mode) |
|---|
| 868 | +open_logfile(const int debuglvl, const struct vuurmuur_config *cnf, const char *path, const char *mode) |
|---|
| 869 | { |
|---|
| 870 | FILE *fp = NULL; |
|---|
| 871 | |
|---|
| 872 | @@ -131,7 +131,7 @@ |
|---|
| 873 | } |
|---|
| 874 | |
|---|
| 875 | /* open the logfile */ |
|---|
| 876 | - if(!(fp = vuurmuur_fopen(debuglvl, path, mode))) |
|---|
| 877 | + if(!(fp = vuurmuur_fopen(debuglvl, cnf, path, mode))) |
|---|
| 878 | { |
|---|
| 879 | (void)vrprint.error(-1, "Error", "the logfile '%s' could not be opened: %s (in: %s:%d).", path, strerror(errno), __FUNC__, __LINE__); |
|---|
| 880 | return(NULL); |
|---|
| 881 | @@ -149,7 +149,7 @@ |
|---|
| 882 | |
|---|
| 883 | |
|---|
| 884 | int |
|---|
| 885 | -open_logfiles(const int debuglvl, FILE **system_log, FILE **vuurmuur_log) |
|---|
| 886 | +open_logfiles(const int debuglvl, const struct vuurmuur_config *cnf, FILE **system_log, FILE **vuurmuur_log) |
|---|
| 887 | { |
|---|
| 888 | /* open the system log */ |
|---|
| 889 | if(!(*system_log = fopen(conf.systemlog_location, "r"))) |
|---|
| 890 | @@ -174,7 +174,7 @@ |
|---|
| 891 | } |
|---|
| 892 | |
|---|
| 893 | /* open the vuurmuur logfile */ |
|---|
| 894 | - if(!(*vuurmuur_log = open_logfile(debuglvl, conf.trafficlog_location, "a"))) |
|---|
| 895 | + if(!(*vuurmuur_log = open_logfile(debuglvl, cnf, conf.trafficlog_location, "a"))) |
|---|
| 896 | { |
|---|
| 897 | (void)vrprint.error(-1, "Error", "opening traffic log file '%s' failed: %s (in: %s:%d).", conf.trafficlog_location, strerror(errno), __FUNC__, __LINE__); |
|---|
| 898 | |
|---|
| 899 | @@ -256,7 +256,7 @@ |
|---|
| 900 | } |
|---|
| 901 | |
|---|
| 902 | /* re-open the vuurmuur logfile */ |
|---|
| 903 | - if(!(*vuurmuur_log = open_logfile(debuglvl, conf.trafficlog_location, "a"))) |
|---|
| 904 | + if(!(*vuurmuur_log = open_logfile(debuglvl, &conf, conf.trafficlog_location, "a"))) |
|---|
| 905 | { |
|---|
| 906 | (void)vrprint.error(-1, "Error", "Re-opening traffic log file '%s' failed: %s.", conf.trafficlog_location, strerror(errno)); |
|---|
| 907 | |
|---|
| 908 | Index: vuurmuur/vuurmuur/vuurmuur_log/vuurmuur_log.c |
|---|
| 909 | =================================================================== |
|---|
| 910 | --- vuurmuur.orig/vuurmuur/vuurmuur_log/vuurmuur_log.c 2009-06-02 21:35:19.000000000 +0200 |
|---|
| 911 | +++ vuurmuur/vuurmuur/vuurmuur_log/vuurmuur_log.c 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 912 | @@ -1390,7 +1390,7 @@ |
|---|
| 913 | } |
|---|
| 914 | |
|---|
| 915 | /* open the logs */ |
|---|
| 916 | - if(open_logfiles(debuglvl, &system_log, &vuurmuur_log) < 0) |
|---|
| 917 | + if(open_logfiles(debuglvl, &conf, &system_log, &vuurmuur_log) < 0) |
|---|
| 918 | { |
|---|
| 919 | (void)vrprint.error(-1, "Error", "opening logfiles failed."); |
|---|
| 920 | exit(EXIT_FAILURE); |
|---|
| 921 | Index: vuurmuur/vuurmuur/vuurmuur_log/vuurmuur_log.h |
|---|
| 922 | =================================================================== |
|---|
| 923 | --- vuurmuur.orig/vuurmuur/vuurmuur_log/vuurmuur_log.h 2009-06-02 21:35:19.000000000 +0200 |
|---|
| 924 | +++ vuurmuur/vuurmuur/vuurmuur_log/vuurmuur_log.h 2009-06-02 21:40:19.000000000 +0200 |
|---|
| 925 | @@ -139,7 +139,7 @@ |
|---|
| 926 | |
|---|
| 927 | |
|---|
| 928 | int reopen_logfiles(const int, FILE **, FILE **); |
|---|
| 929 | -int open_logfiles(const int, FILE **, FILE **); |
|---|
| 930 | +int open_logfiles(const int, const struct vuurmuur_config *cnf, FILE **, FILE **); |
|---|
| 931 | |
|---|
| 932 | |
|---|
| 933 | /* semaphore id */ |
|---|