samldb: ensure subnets have proper net ranges
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 23 Sep 2015 03:10:56 +0000 (15:10 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 24 Dec 2015 03:09:29 +0000 (04:09 +0100)
commit906a53f442797942e29c899fb7a54a92f970e67e
treeff1d11dc452db7c8577571036ef6bbc10bc02dcf
parentcbb93977cd0e427ba83c2f3dff31668901ad4699
samldb: ensure subnets have proper net ranges

A subnet name needs to be a valid CIDR address range -- that's the
ones that look like 10.9.8.0/22, where the number after the /
determines how many bits are in the address suffix. It can be IPv4 or
IPv6. There are a few odd constraints (see MS-ADTS v20150630
6.1.1.2.2.2.1 "Subnet Object") -- for example, with IPv4, the implied
bit mask can't equal the address. That is, you can't have a subnet
named "255.255.255.0/24" in a Windows subnet. This rule does not apply
to IPv6.

Windows and Samba both make some ensure that subnets have a unique
valid name, though unfortunately Windows 2008R2 is rather slack when
it comes to IPv6. We follow Windows 2012R2, which roughly follows
RFC5952 -- with one caveat: Windows will allow an address like
"::ffff:0:1:2", which translates to the IPv4 address "0.1.0.2" using
the SIIT translation scheme, and which inet_ntop() would render as
"::ffff:0:0.1.0.2". In the Samba implementation we use an inet_pton()/
inet_ntop() round-trip to establish canonicality, so these addresses
fail. Windows wisely does not allow the SIIT style addresses (the
acronym is widely agreed to be off-by-one in the second letter), and
it will regard "::ffff:0:1:2" as simply "::ffff:0:1:2" and allow it.
We would like to do that too.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/samba_tool/sites.py
source4/dsdb/samdb/ldb_modules/samldb.c
source4/dsdb/tests/python/sites.py