pfsense/etc
stilez e89d2995bb Tighten and IPv6-ify gen_subnet() etc
Tightens, canonicalises and improves for IPv6, the functions
gen_subnet(), gen_subnetv6(), gen_subnet_max(), gen_subnetv6_max()

Changes are transparent to calling code.

Issues:

1) gen_subnet() and gen_subnet_max() will validate both IPv4 and IPv6 as valid args, but will then try to process an IPv6 subnet bitwise as x32 LONG without further checking, causing erroneous but apparently valid responses.

2) None of the functions properly sanitise their input: if $bits is >32 or >128, or even a non-integer, erroneous results will be passed back to the calling code as valid data without checking, again causing erroneous but apparently valid responses.

3) 3 of the 4 functions return an empty string for invalid but gen_subnetv6_max() returns a numeric value for invalid. Both responses loose-evaluate as False, but consistency is better.

Fixes and improvements:

1) The unspecified functions gen_subnet() and gen_subnet_max() now handle all args correctly, and don't mishandle if unexpectedly passed IPv6 or bad data.

2) Names are now canonical: gen_subnet(), gen_subnet_max() are now IPv4/v6 agnostic, and IPv4-only versions gen_subnetv4() and gen_subnetv4_max() are added as expected to exist, to match existing functions gen_subnetv6() and gen_subnetv6_max().

3) The return value for bad args is made consistent (empty string = False).

4) gen_subnetv6_max() now uses Net_IPv6's Ip2Bin() and Bin2Ip() functions and simple string manipulation rather than bitwise operations, so it's guaranteed 32-bit safe (compared to 128-bit bitwise operations in current code which seem less certain?)

5) Changes are transparent - the canonical functions still work exactly as before on IPv4 (only with proper bad arg validation) but also now work on IPv6 transparently, and on arbitrary IPv4/IPv6 data, similar to other functions like is_ipaddr().

Tested and handles valid but uncommon edge cases of /0, /32 (IPv4) and /128 (IPv6) correctly. Also avoids inet_ntop/pton if that's a real issue (previous PR comment had asked to avoid these functions)
2015-01-06 15:14:51 -02:00
..
ascii-art
inc Tighten and IPv6-ify gen_subnet() etc 2015-01-06 15:14:51 -02:00
mtree
phpshellsessions Add RELENG_2_2 to gitsync 2014-12-05 11:05:46 -02:00
skel remove the command number shown in the shell prompt, it's a pointless 2014-10-21 12:46:38 -05:00
ssh
ssl cherry pic from 'hotfix/3347-Certificate_Authority_SAN_names_not_working': 2014-08-14 02:18:32 +02:00
bogons
bogonsv6
ca_countries
crontab
ddb.conf
devd.conf
dh-parameters.1024
dh-parameters.2048
dh-parameters.4096
disktab Update disktab to FreeBSD 10 2014-03-28 23:06:02 +01:00
ecl.php Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
fbtab
gettytab Sync gettytab with FreeBSD 10-STABLE, also reduce customizations, the only difference is al.Pc entry, for Pc with auto login 2014-07-01 13:33:07 -03:00
group Merge pull request #1040 from fichtner/pw_userdel manually since it does not apply cleanly 2014-04-28 07:25:33 +00:00
host.conf
hosts.allow
inetd.conf
login.conf
master.passwd
motd
networks
passwd
pf.os Expose all p0f OS types that it supports so that subtypes of various Operating Systems can be detected 2014-04-29 11:52:11 -04:00
pfSense.obsoletedfiles libreadline.so.6 is not supposed to be obsoleted, fixes #4159 2014-12-31 12:27:05 -02:00
platform
printcap
protocols Update protocols file as well 2014-03-28 22:45:54 +01:00
pubkey.pem
rc Prevent resolvconf(8) from stomping all over our newly generated 2014-12-20 22:13:45 +02:00
rc.backup_dhcpleases.sh
rc.backup_rrd.sh Process RRD backup compression in var 2014-11-28 23:24:10 +05:45
rc.banner
rc.bootup Properly unset booting flags to allow dynamic ipsec tunnels to work correctly 2014-12-04 10:18:44 +01:00
rc.captiveportal_configure standardize URLs 2014-03-14 19:33:03 -05:00
rc.carpbackup Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.carpmaster Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.cdrom
rc.conf_mount_ro standardize URLs 2014-03-14 19:33:03 -05:00
rc.conf_mount_rw standardize URLs 2014-03-14 19:33:03 -05:00
rc.create_full_backup
rc.dhclient_cron standardize URLs 2014-03-14 19:33:03 -05:00
rc.disable_hdd_apm
rc.dumpon Setup ddb on all platforms. On full install it will save the dump, on NanoBSD it will print to console and auto-reboot. 2014-12-10 11:36:26 -05:00
rc.dyndns.update isset($_GET) seems to always evaluate to true, use something more specific. Fixes use of rc.linkup when run from CLI. Others likely fix similar circumstances, though maybe not ones that are used anywhere. 2014-11-05 19:47:22 -06:00
rc.embedded
rc.expireaccounts Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.filter_configure standardize URLs 2014-03-14 19:33:03 -05:00
rc.filter_configure_sync standardize URLs 2014-03-14 19:33:03 -05:00
rc.filter_configure_xmlrpc
rc.filter_synchronize Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.firmware Make sure scripts have necessary attributes and use its shebang line instead of force sh to call it. This will help to prevent or workaround issues similar to #3749 in the future 2014-07-11 08:23:04 -03:00
rc.firmware_auto
rc.halt
rc.initial Use clog -f /var/log/filter.log to view firewall log entries, so they are displayed in the new format. 2014-12-02 12:46:14 -05:00
rc.initial.defaults
rc.initial.firmware_update Remove these booting settings since are useless 2014-11-28 13:00:47 +01:00
rc.initial.halt
rc.initial.password
rc.initial.ping
rc.initial.reboot
rc.initial.setlanip Validation of y/n answers in setlanip 2014-12-12 23:01:07 +05:45
rc.initial.setports
rc.initial.store_config_to_removable_device Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.initial.toggle_sshd Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.interfaces_carp_configure standardize URLs 2014-03-14 19:33:03 -05:00
rc.interfaces_lan_configure standardize URLs 2014-03-14 19:33:03 -05:00
rc.interfaces_opt_configure standardize URLs 2014-03-14 19:33:03 -05:00
rc.interfaces_wan_configure isset($_GET) seems to always evaluate to true, use something more specific. Fixes use of rc.linkup when run from CLI. Others likely fix similar circumstances, though maybe not ones that are used anywhere. 2014-11-05 19:47:22 -06:00
rc.kill_states Remove exit and also properly close open files 2014-12-02 11:28:37 +01:00
rc.linkup Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.nanobsd_switch_boot_slice Remove exit from as much as possible backend code 2014-12-02 11:33:21 +01:00
rc.newipsecdns Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.newroutedns Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.newwanip Reload Unbound after IP changes, to fix issues noted in Ticket #4095. Do so before Dynamic DNS updates occur to ensure the host has functioning DNS. 2014-12-30 23:14:04 -06:00
rc.newwanipv6 Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.notify_message Use require_once in more places 2014-05-09 05:57:42 -07:00
rc.ntpdate
rc.openvpn Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.packages standardize URLs 2014-03-14 19:33:03 -05:00
rc.php_ini_setup Add filter.so to list of extensions loaded for 2.2 2014-08-18 09:34:21 -05:00
rc.php-fpm_restart show user that something is actually happening when they choose php-fpm_restart 2014-11-15 23:37:38 -06:00
rc.prunecaptiveportal
rc.reboot
rc.reload_all standardize URLs 2014-03-14 19:33:03 -05:00
rc.reload_interfaces standardize URLs 2014-03-14 19:33:03 -05:00
rc.resolv_conf_generate Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.restart_webgui Add require_once where needed to avoid redeclaration from nested includes 2014-03-20 19:26:41 +00:00
rc.restore_config_backup
rc.restore_full_backup
rc.savecore
rc.savevoucher
rc.shutdown Remove extra noise from rc.shutdown 2014-08-20 08:40:47 -03:00
rc.start_packages Use the same strategy as on CP by putting a file to detect running instances and if older than 90seconds continue otherwise just let the previous one continue. 2014-11-24 19:59:55 +01:00
rc.stop_packages
rc.update_alias_url_data Fix lineup of copyright lines 2015-01-01 15:11:15 +05:45
rc.update_bogons.sh wait 10 minutes before retrying on soft failures to avoid us getting DoSed 2014-12-02 11:14:03 -06:00
rc.update_urltables Remove exit from as much as possible backend code 2014-12-02 11:33:21 +01:00
services
shells
sshd Remove variable use here since it's confusing sshdcond package, ticket #3959 2014-11-26 08:15:21 -02:00
syslog.conf
ttys Back to cons25 for now since we found some issues with xterm on serial console 2014-07-02 17:24:25 -03:00
version The time has come - bump to 2.2-RC 2014-12-04 17:20:53 -06:00