| 1 | Index: vuurmuur/vuurmuur-conf/src/config_section.c |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- vuurmuur.orig/vuurmuur-conf/src/config_section.c 2009-06-02 21:35:13.000000000 +0200 |
|---|
| 4 | +++ vuurmuur/vuurmuur-conf/src/config_section.c 2009-06-02 22:10:53.000000000 +0200 |
|---|
| 5 | @@ -73,6 +73,7 @@ |
|---|
| 6 | *iptablesrestorelocfld, |
|---|
| 7 | *conntracklocfld, |
|---|
| 8 | *tclocfld, |
|---|
| 9 | + *max_permission, |
|---|
| 10 | |
|---|
| 11 | *oldcreatefld; |
|---|
| 12 | |
|---|
| 13 | @@ -87,9 +88,10 @@ |
|---|
| 14 | rows = 0, |
|---|
| 15 | cols = 0; |
|---|
| 16 | size_t i = 0; |
|---|
| 17 | + char number[5]; |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | - ConfigSection.n_fields = 4; |
|---|
| 21 | + ConfigSection.n_fields = 5; |
|---|
| 22 | ConfigSection.fields = (FIELD **)calloc(ConfigSection.n_fields + 1, sizeof(FIELD *)); |
|---|
| 23 | |
|---|
| 24 | /* external programs */ |
|---|
| 25 | @@ -97,6 +99,8 @@ |
|---|
| 26 | GenConfig.iptablesrestorelocfld = (ConfigSection.fields[1] = new_field(1, 64, 4, 1, 0, 0)); /* */ |
|---|
| 27 | GenConfig.conntracklocfld = (ConfigSection.fields[2] = new_field(1, 64, 7, 1, 0, 0)); /* */ |
|---|
| 28 | GenConfig.tclocfld = (ConfigSection.fields[3] = new_field(1, 64, 10, 1, 0, 0)); /* */ |
|---|
| 29 | + /* Config file permissions */ |
|---|
| 30 | + GenConfig.max_permission = (ConfigSection.fields[4] = new_field(1, 4, 13, 1, 0, 0)); /* max_permissions */ |
|---|
| 31 | |
|---|
| 32 | /* terminate */ |
|---|
| 33 | ConfigSection.fields[ConfigSection.n_fields] = NULL; |
|---|
| 34 | @@ -109,6 +113,8 @@ |
|---|
| 35 | set_field_buffer_wrap(debuglvl, GenConfig.iptablesrestorelocfld, 0, conf.iptablesrestore_location); |
|---|
| 36 | set_field_buffer_wrap(debuglvl, GenConfig.conntracklocfld, 0, conf.conntrack_location); |
|---|
| 37 | set_field_buffer_wrap(debuglvl, GenConfig.tclocfld, 0, conf.tc_location); |
|---|
| 38 | + (void)snprintf(number, sizeof(number), "%o", conf.max_permission); |
|---|
| 39 | + set_field_buffer_wrap(debuglvl, GenConfig.max_permission, 0, number); |
|---|
| 40 | |
|---|
| 41 | /* set buffers done */ |
|---|
| 42 | for(i = 0; i < ConfigSection.n_fields; i++) |
|---|
| 43 | @@ -135,6 +141,7 @@ |
|---|
| 44 | mvwprintw(ConfigSection.win, 4, 2, gettext("Iptables-restore location (full path):")); |
|---|
| 45 | mvwprintw(ConfigSection.win, 7, 2, gettext("Conntrack location (full path):")); |
|---|
| 46 | mvwprintw(ConfigSection.win, 10, 2, gettext("Tc location (full path):")); |
|---|
| 47 | + mvwprintw(ConfigSection.win, 13, 2, gettext("Maximum config and log file and dir permissions (octal):")); |
|---|
| 48 | |
|---|
| 49 | return(retval); |
|---|
| 50 | } |
|---|
| 51 | @@ -208,6 +215,31 @@ |
|---|
| 52 | (void)vrprint.audit("'tc location' %s '%s'.", |
|---|
| 53 | STR_IS_NOW_SET_TO, conf.tc_location); |
|---|
| 54 | } |
|---|
| 55 | + else if(ConfigSection.fields[i] == GenConfig.max_permission) |
|---|
| 56 | + { |
|---|
| 57 | + char buf[5]; |
|---|
| 58 | + char *endptr; |
|---|
| 59 | + long int newval; |
|---|
| 60 | + |
|---|
| 61 | + /* maximum file permissions */ |
|---|
| 62 | + if(!(copy_field2buf(buf, |
|---|
| 63 | + field_buffer(ConfigSection.fields[i], 0), |
|---|
| 64 | + sizeof(buf)))) |
|---|
| 65 | + return(-1); |
|---|
| 66 | + |
|---|
| 67 | + /* Parse it as an octal mode */ |
|---|
| 68 | + newval = strtol(buf, &endptr, 8); |
|---|
| 69 | + |
|---|
| 70 | + /* If strol fails, it will set endptr to buf. Also check that |
|---|
| 71 | + * there was no trailing garbage at the end of the string. */ |
|---|
| 72 | + if (endptr != buf && *endptr == '\0') |
|---|
| 73 | + { |
|---|
| 74 | + conf.max_permission = newval; |
|---|
| 75 | + |
|---|
| 76 | + (void)vrprint.audit("'maximum permissions' %s '%o'.", |
|---|
| 77 | + STR_IS_NOW_SET_TO, conf.max_permission); |
|---|
| 78 | + } |
|---|
| 79 | + } |
|---|
| 80 | else |
|---|
| 81 | { |
|---|
| 82 | (void)vrprint.error(-1, VR_INTERR, "unknown field (in: %s:%d).", __FUNC__, __LINE__); |
|---|
| 83 | @@ -261,7 +293,8 @@ |
|---|
| 84 | if( cur == GenConfig.iptableslocfld || |
|---|
| 85 | cur == GenConfig.iptablesrestorelocfld || |
|---|
| 86 | cur == GenConfig.tclocfld || |
|---|
| 87 | - cur == GenConfig.conntracklocfld) |
|---|
| 88 | + cur == GenConfig.conntracklocfld || |
|---|
| 89 | + cur == GenConfig.max_permission) |
|---|
| 90 | { |
|---|
| 91 | if(nav_field_simpletext(debuglvl, ConfigSection.form, ch) < 0) |
|---|
| 92 | not_defined = 1; |
|---|